feat(Copper Node): Update credential to support HTTP Request node (#9837)

This commit is contained in:
Jochem
2024-07-03 09:59:44 +02:00
committed by GitHub
parent 403e19b3e3
commit e6ad5a7193
2 changed files with 28 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ import type {
IHookFunctions,
IHttpRequestMethods,
ILoadOptionsFunctions,
IRequestOptions,
IHttpRequestOptions,
IWebhookFunctions,
JsonObject,
} from 'n8n-workflow';
@@ -35,19 +35,14 @@ export async function copperApiRequest(
uri = '',
option: IDataObject = {},
) {
const credentials = (await this.getCredentials('copperApi')) as { apiKey: string; email: string };
let options: IRequestOptions = {
let options: IHttpRequestOptions = {
headers: {
'X-PW-AccessToken': credentials.apiKey,
'X-PW-Application': 'developer_api',
'X-PW-UserEmail': credentials.email,
'Content-Type': 'application/json',
},
method,
qs,
body,
uri: uri || `https://api.prosperworks.com/developer_api/v1${resource}`,
url: uri || `https://api.copper.com/developer_api/v1${resource}`,
json: true,
};
@@ -62,7 +57,7 @@ export async function copperApiRequest(
}
try {
return await this.helpers.request(options);
return await this.helpers.requestWithAuthentication.call(this, 'copperApi', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}