Skip to content

Commit

Permalink
test: added test requests and simplified authenticationMethod selection
Browse files Browse the repository at this point in the history
  • Loading branch information
vcrwr committed Oct 13, 2022
1 parent 4ecef59 commit d663527
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
9 changes: 8 additions & 1 deletion packages/nodes-base/credentials/HubspotApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow';
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';

export class HubspotApi implements ICredentialType {
name = 'hubspotApi';
Expand All @@ -21,4 +21,11 @@ export class HubspotApi implements ICredentialType {
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.hubapi.com',
url: '/account-info/v3/details',
},
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow';
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';

export class HubspotAppToken implements ICredentialType {
name = 'hubspotAppToken';
Expand All @@ -21,4 +21,11 @@ export class HubspotAppToken implements ICredentialType {
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.hubapi.com',
url: '/account-info/v3/details',
},
};
}
6 changes: 2 additions & 4 deletions packages/nodes-base/nodes/Hubspot/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions
};

try {
if (authenticationMethod === 'apiKey') {
return this.helpers.requestWithAuthentication.call(this, 'hubspotApi', options);
} else if (authenticationMethod === 'appToken') {
return this.helpers.requestWithAuthentication.call(this, 'hubspotAppToken', options);
if (authenticationMethod === 'apiKey' || authenticationMethod === 'appToken') {
return this.helpers.requestWithAuthentication.call(this, authenticationMethod, options);
} else if (authenticationMethod === 'developerApi') {
if (endpoint.includes('webhooks')) {

Expand Down

0 comments on commit d663527

Please sign in to comment.