feat: Add Twilio Trigger Node (#8859)

Co-authored-by: Michael Kret <michael.k@radency.com>
Co-authored-by: Giulio Andreini <andreini@netseven.it>
This commit is contained in:
Bram Kn
2024-03-29 09:24:25 +01:00
committed by GitHub
parent 2aab78b058
commit c204995d9c
4 changed files with 236 additions and 0 deletions

View File

@@ -4,6 +4,8 @@ import type {
IDataObject,
IHttpRequestMethods,
IRequestOptions,
IHttpRequestOptions,
ILoadOptionsFunctions,
} from 'n8n-workflow';
/**
@@ -40,6 +42,24 @@ export async function twilioApiRequest(
return await this.helpers.requestWithAuthentication.call(this, 'twilioApi', options);
}
export async function twilioTriggerApiRequest(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
method: IHttpRequestMethods,
endpoint: string,
body: FormData | IDataObject = {},
): Promise<any> {
const options: IHttpRequestOptions = {
method,
body,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
url: `https://events.twilio.com/v1/${endpoint}`,
json: true,
};
return await this.helpers.requestWithAuthentication.call(this, 'twilioApi', options);
}
const XML_CHAR_MAP: { [key: string]: string } = {
'<': '&lt;',
'>': '&gt;',