mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ small improvements
This commit is contained in:
parent
e411e46ef7
commit
f03936b468
|
@ -13,7 +13,7 @@ export async function gumroadApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||||
if (credentials === undefined) {
|
if (credentials === undefined) {
|
||||||
throw new Error('No credentials got returned!');
|
throw new Error('No credentials got returned!');
|
||||||
}
|
}
|
||||||
body = Object.assign({ access_token: credentials.accessToken }, body)
|
body = Object.assign({ access_token: credentials.accessToken }, body);
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
method,
|
method,
|
||||||
|
@ -30,9 +30,9 @@ export async function gumroadApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let errorMessage = error
|
let errorMessage = error;
|
||||||
if (!error.success) {
|
if (!error.success) {
|
||||||
errorMessage.message
|
errorMessage.message;
|
||||||
}
|
}
|
||||||
throw new Error('Gumroad Error: ' + errorMessage);
|
throw new Error('Gumroad Error: ' + errorMessage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,9 +79,7 @@ export class GumroadTrigger implements INodeType {
|
||||||
description: 'The resource is gonna fire the event',
|
description: 'The resource is gonna fire the event',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
webhookMethods = {
|
webhookMethods = {
|
||||||
default: {
|
default: {
|
||||||
|
@ -90,12 +88,12 @@ export class GumroadTrigger implements INodeType {
|
||||||
if (webhookData.webhookId === undefined) {
|
if (webhookData.webhookId === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const endpoint = `/resource_subscriptions`;
|
const endpoint = '/resource_subscriptions';
|
||||||
const { resource_subscriptions } = await gumroadApiRequest.call(this, 'GET', endpoint);
|
const { resource_subscriptions } = await gumroadApiRequest.call(this, 'GET', endpoint);
|
||||||
if (Array.isArray(resource_subscriptions)) {
|
if (Array.isArray(resource_subscriptions)) {
|
||||||
for (const resource of resource_subscriptions) {
|
for (const resource of resource_subscriptions) {
|
||||||
if (resource.id === webhookData.webhookId) {
|
if (resource.id === webhookData.webhookId) {
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue