2022-09-29 17:17:46 -07:00
|
|
|
import {
|
|
|
|
IAuthenticateGeneric,
|
|
|
|
ICredentialTestRequest,
|
|
|
|
ICredentialType,
|
|
|
|
INodeProperties,
|
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
export class WhatsAppApi implements ICredentialType {
|
|
|
|
name = 'whatsAppApi';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-09-29 17:17:46 -07:00
|
|
|
displayName = 'WhatsApp API';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-09-29 17:17:46 -07:00
|
|
|
documentationUrl = 'whatsApp';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-09-29 17:17:46 -07:00
|
|
|
properties: INodeProperties[] = [
|
|
|
|
{
|
|
|
|
displayName: 'Access Token',
|
|
|
|
type: 'string',
|
2022-11-01 09:41:45 -07:00
|
|
|
typeOptions: { password: true },
|
2022-09-29 17:17:46 -07:00
|
|
|
name: 'accessToken',
|
|
|
|
default: '',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Bussiness Account ID',
|
|
|
|
type: 'string',
|
|
|
|
name: 'businessAccountId',
|
|
|
|
default: '',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
|
|
type: 'generic',
|
|
|
|
properties: {
|
|
|
|
headers: {
|
|
|
|
Authorization: '=Bearer {{$credentials.accessToken}}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: 'https://graph.facebook.com/v13.0',
|
|
|
|
url: '/',
|
|
|
|
ignoreHttpStatusErrors: true,
|
|
|
|
},
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
type: 'responseSuccessBody',
|
|
|
|
properties: {
|
|
|
|
key: 'error.type',
|
|
|
|
value: 'OAuthException',
|
|
|
|
message: 'Invalid access token',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|