mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
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:
parent
d417ea7ffa
commit
6d64e84f5e
|
@ -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',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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 |
Loading…
Reference in a new issue