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: {
|
2022-07-24 08:36:17 -07:00
|
|
|
authType: ['authToken'],
|
2021-05-18 17:05:49 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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: {
|
2022-07-24 08:36:17 -07:00
|
|
|
authType: ['apiKey'],
|
2021-05-18 17:05:49 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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: {
|
2022-07-24 08:36:17 -07:00
|
|
|
authType: ['apiKey'],
|
2021-05-18 17:05:49 -07:00
|
|
|
},
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
];
|
2022-07-10 03:32:19 -07:00
|
|
|
|
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
|
|
type: 'generic',
|
|
|
|
properties: {
|
|
|
|
auth: {
|
2022-07-24 08:36:17 -07:00
|
|
|
username:
|
|
|
|
'={{ $credentials.authType === "apiKey" ? $credentials.apiKeySid : $credentials.accountSid }}',
|
|
|
|
password:
|
|
|
|
'={{ $credentials.authType === "apiKey" ? $credentials.apiKeySecret : $credentials.authToken }}',
|
2022-07-10 03:32:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|