first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import map from 'lodash/map';
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
IHttpRequestMethods,
|
||||
ILoadOptionsFunctions,
|
||||
IRequestOptions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function mandrillApiRequest(
|
||||
this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
resource: string,
|
||||
method: IHttpRequestMethods,
|
||||
action: string,
|
||||
|
||||
body: any = {},
|
||||
headers?: IDataObject,
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('mandrillApi');
|
||||
|
||||
const data = Object.assign({}, body, { key: credentials.apiKey });
|
||||
|
||||
const endpoint = 'mandrillapp.com/api/1.0';
|
||||
|
||||
const options: IRequestOptions = {
|
||||
headers,
|
||||
method,
|
||||
uri: `https://${endpoint}${resource}${action}.json`,
|
||||
body: data,
|
||||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
return await this.helpers.request(options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
export function getToEmailArray(toEmail: string): any {
|
||||
let toEmailArray;
|
||||
if (toEmail.split(',').length > 0) {
|
||||
const array = toEmail.split(',');
|
||||
toEmailArray = map(array, (email) => {
|
||||
return {
|
||||
email,
|
||||
type: 'to',
|
||||
};
|
||||
});
|
||||
} else {
|
||||
toEmailArray = [
|
||||
{
|
||||
email: toEmail,
|
||||
type: 'to',
|
||||
},
|
||||
];
|
||||
}
|
||||
return toEmailArray;
|
||||
}
|
||||
|
||||
export function getGoogleAnalyticsDomainsArray(s: string): string[] {
|
||||
let array: string[] = [];
|
||||
if (s.split(',').length > 0) {
|
||||
array = s.split(',');
|
||||
} else {
|
||||
array = [s];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
export function getTags(s: string): any[] {
|
||||
let array = [];
|
||||
if (s.split(',').length > 0) {
|
||||
array = s.split(',');
|
||||
} else {
|
||||
array = [s];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
export function validateJSON(json: string | undefined): any {
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(json!);
|
||||
} catch (exception) {
|
||||
result = [];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user