feat(Iterable Node): Add support for EDC and USDC selection (#10908)
Some checks failed
Test Master / install-and-build (push) Has been cancelled
Test Master / Unit tests (18.x) (push) Has been cancelled
Test Master / Unit tests (20.x) (push) Has been cancelled
Test Master / Unit tests (22.4) (push) Has been cancelled
Test Master / Lint (push) Has been cancelled
Test Master / Notify Slack on failure (push) Has been cancelled

This commit is contained in:
Jon 2024-09-28 11:56:55 +01:00 committed by GitHub
parent 0ff0f1aa11
commit 0ca9c076ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 8 deletions

View file

@ -1,4 +1,9 @@
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
import type {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class IterableApi implements ICredentialType {
name = 'iterableApi';
@ -15,5 +20,38 @@ export class IterableApi implements ICredentialType {
typeOptions: { password: true },
default: '',
},
{
displayName: 'Region',
name: 'region',
type: 'options',
options: [
{
name: 'EDC',
value: 'https://api.eu.iterable.com',
},
{
name: 'USDC',
value: 'https://api.iterable.com',
},
],
default: 'https://api.iterable.com',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Api_Key: '={{$credentials.apiKey}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials?.region}}',
url: '/api/webhooks',
method: 'GET',
},
};
}

View file

@ -2,8 +2,8 @@ import type {
IDataObject,
IExecuteFunctions,
IHttpRequestMethods,
IHttpRequestOptions,
ILoadOptionsFunctions,
IRequestOptions,
JsonObject,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
@ -12,7 +12,6 @@ export async function iterableApiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions,
method: IHttpRequestMethods,
resource: string,
body: any = {},
qs: IDataObject = {},
uri?: string,
@ -20,15 +19,14 @@ export async function iterableApiRequest(
): Promise<any> {
const credentials = await this.getCredentials('iterableApi');
const options: IRequestOptions = {
const options: IHttpRequestOptions = {
headers: {
'Content-Type': 'application/json',
Api_Key: credentials.apiKey,
},
method,
body,
qs,
uri: uri || `https://api.iterable.com/api${resource}`,
url: uri || `${credentials.region}/api${resource}`,
json: true,
};
try {
@ -38,8 +36,7 @@ export async function iterableApiRequest(
if (Object.keys(body as IDataObject).length === 0) {
delete options.body;
}
//@ts-ignore
return await this.helpers.request.call(this, options);
return await this.helpers.httpRequestWithAuthentication.call(this, 'iterableApi', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}