n8n/packages/nodes-base/credentials/TwilioApi.credentials.ts

85 lines
1.5 KiB
TypeScript
Raw Normal View History

import type { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow';
2019-06-23 03:35:23 -07:00
export class TwilioApi implements ICredentialType {
name = 'twilioApi';
2019-06-23 03:35:23 -07:00
displayName = 'Twilio API';
documentationUrl = 'twilio';
properties: INodeProperties[] = [
{
displayName: 'Auth Type',
name: 'authType',
type: 'options',
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',
type: 'string',
2019-06-23 03:35:23 -07:00
default: '',
},
{
displayName: 'Auth Token',
name: 'authToken',
type: 'string',
typeOptions: { password: true },
2019-06-23 03:35:23 -07:00
default: '',
displayOptions: {
show: {
authType: ['authToken'],
},
},
},
{
displayName: 'API Key SID',
name: 'apiKeySid',
type: 'string',
typeOptions: { password: true },
default: '',
displayOptions: {
show: {
authType: ['apiKey'],
},
},
},
{
displayName: 'API Key Secret',
name: 'apiKeySecret',
type: 'string',
typeOptions: {
password: true,
},
default: '',
displayOptions: {
show: {
authType: ['apiKey'],
},
},
2019-06-23 03:35:23 -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
}