feat(Twake Node): Update icon, add cred test and custom operation support (#3431)

* Update icon, add cred injection and test, update url for integration

*  Fix error display for some edge cases

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
agobrech 2022-06-19 05:10:08 +02:00 committed by GitHub
parent d417ea7ffa
commit 6d64e84f5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View file

@ -1,4 +1,6 @@
import {
IAuthenticateBearer,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
@ -15,4 +17,18 @@ export class TwakeCloudApi implements ICredentialType {
default: '',
},
];
authenticate = {
type: 'bearer',
properties: {
tokenPropertyName: 'workspaceKey',
},
} as IAuthenticateBearer;
test: ICredentialTestRequest = {
request: {
baseURL: 'https://plugins.twake.app/plugins/n8n',
url: '/channel',
method: 'POST',
},
};
}

View file

@ -28,15 +28,12 @@ export async function twakeApiRequest(this: IHookFunctions | IExecuteFunctions |
method,
body,
qs: query,
uri: uri || `https://connectors.albatros.twakeapp.com/n8n${resource}`,
uri: uri || `https://plugins.twake.app/plugins/n8n${resource}`,
json: true,
};
// if (authenticationMethod === 'cloud') {
const credentials = await this.getCredentials('twakeCloudApi');
options.headers!.Authorization = `Bearer ${credentials.workspaceKey}`;
// } else {
// const credentials = await this.getCredentials('twakeServerApi');
// options.auth = { user: credentials!.publicId as string, pass: credentials!.privateApiKey as string };
@ -44,9 +41,9 @@ export async function twakeApiRequest(this: IHookFunctions | IExecuteFunctions |
// }
try {
return await this.helpers.request!(options);
return await this.helpers.requestWithAuthentication.call(this, 'twakeCloudApi', options);
} catch (error) {
if (error.error.code === 'ECONNREFUSED') {
if (error.error?.code === 'ECONNREFUSED') {
throw new NodeApiError(this.getNode(), error, { message: 'Twake host is not accessible!' });
}
throw new NodeApiError(this.getNode(), error);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB