mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(Iterable Node): Add support for EDC and USDC selection (#10908)
This commit is contained in:
@@ -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 {
|
export class IterableApi implements ICredentialType {
|
||||||
name = 'iterableApi';
|
name = 'iterableApi';
|
||||||
@@ -15,5 +20,38 @@ export class IterableApi implements ICredentialType {
|
|||||||
typeOptions: { password: true },
|
typeOptions: { password: true },
|
||||||
default: '',
|
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',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import type {
|
|||||||
IDataObject,
|
IDataObject,
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
IHttpRequestMethods,
|
IHttpRequestMethods,
|
||||||
|
IHttpRequestOptions,
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
IRequestOptions,
|
|
||||||
JsonObject,
|
JsonObject,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import { NodeApiError } from 'n8n-workflow';
|
import { NodeApiError } from 'n8n-workflow';
|
||||||
@@ -12,7 +12,6 @@ export async function iterableApiRequest(
|
|||||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||||
method: IHttpRequestMethods,
|
method: IHttpRequestMethods,
|
||||||
resource: string,
|
resource: string,
|
||||||
|
|
||||||
body: any = {},
|
body: any = {},
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
uri?: string,
|
uri?: string,
|
||||||
@@ -20,15 +19,14 @@ export async function iterableApiRequest(
|
|||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = await this.getCredentials('iterableApi');
|
const credentials = await this.getCredentials('iterableApi');
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IHttpRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Api_Key: credentials.apiKey,
|
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
qs,
|
qs,
|
||||||
uri: uri || `https://api.iterable.com/api${resource}`,
|
url: uri || `${credentials.region}/api${resource}`,
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
@@ -38,8 +36,7 @@ export async function iterableApiRequest(
|
|||||||
if (Object.keys(body as IDataObject).length === 0) {
|
if (Object.keys(body as IDataObject).length === 0) {
|
||||||
delete options.body;
|
delete options.body;
|
||||||
}
|
}
|
||||||
//@ts-ignore
|
return await this.helpers.httpRequestWithAuthentication.call(this, 'iterableApi', options);
|
||||||
return await this.helpers.request.call(this, options);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user