2019-06-23 03:35:23 -07:00
|
|
|
import {
|
2022-07-10 03:32:19 -07:00
|
|
|
IAuthenticateGeneric,
|
|
|
|
ICredentialDataDecryptedObject,
|
|
|
|
ICredentialTestRequest,
|
2019-06-23 03:35:23 -07:00
|
|
|
ICredentialType,
|
2022-07-10 03:32:19 -07:00
|
|
|
IHttpRequestOptions,
|
2021-06-12 09:39:55 -07:00
|
|
|
INodeProperties,
|
2019-06-23 03:35:23 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
|
|
|
|
export class TwilioApi implements ICredentialType {
|
|
|
|
name = 'twilioApi';
|
|
|
|
displayName = 'Twilio API';
|
2020-08-17 05:42:09 -07:00
|
|
|
documentationUrl = 'twilio';
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2021-05-18 17:05:49 -07:00
|
|
|
{
|
|
|
|
displayName: 'Auth Type',
|
|
|
|
name: 'authType',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'options',
|
2021-05-18 17:05:49 -07:00
|
|
|
default: 'authToken',
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Auth Token',
|
|
|
|
value: 'authToken',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'API Key',
|
|
|
|
value: 'apiKey',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
{
|
|
|
|
displayName: 'Account SID',
|
|
|
|
name: 'accountSid',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2019-06-23 03:35:23 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Auth Token',
|
|
|
|
name: 'authToken',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2019-06-23 03:35:23 -07:00
|
|
|
default: '',
|
2021-05-18 17:05:49 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
authType: [
|
|
|
|
'authToken',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'API Key SID',
|
|
|
|
name: 'apiKeySid',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2021-05-18 17:05:49 -07:00
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
authType: [
|
|
|
|
'apiKey',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'API Key Secret',
|
|
|
|
name: 'apiKeySecret',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2021-05-18 17:05:49 -07:00
|
|
|
typeOptions: {
|
|
|
|
password: true,
|
|
|
|
},
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
authType: [
|
|
|
|
'apiKey',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
];
|
2022-07-10 03:32:19 -07:00
|
|
|
|
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
|
|
type: 'generic',
|
|
|
|
properties: {
|
|
|
|
auth: {
|
|
|
|
username: '={{ $credentials.authType === "apiKey" ? $credentials.apiKeySid : $credentials.accountSid }}',
|
|
|
|
password: '={{ $credentials.authType === "apiKey" ? $credentials.apiKeySecret : $credentials.authToken }}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|