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
3 changed files with 19 additions and 6 deletions

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);