mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat(Postmark Trigger Node): Update credentials so they can be used with the HTTP Request Node (#4790)
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class PostmarkApi implements ICredentialType {
|
export class PostmarkApi implements ICredentialType {
|
||||||
name = 'postmarkApi';
|
name = 'postmarkApi';
|
||||||
@@ -12,4 +17,19 @@ export class PostmarkApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
'X-Postmark-Server-Token': '={{$credentials.serverToken}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.postmarkapp.com',
|
||||||
|
url: '/server',
|
||||||
|
method: 'GET',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,10 @@ export async function postmarkApiRequest(
|
|||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
// tslint:disable-next-line:no-any
|
// tslint:disable-next-line:no-any
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = await this.getCredentials('postmarkApi');
|
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
'X-Postmark-Server-Token': credentials.serverToken,
|
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
@@ -32,7 +29,7 @@ export async function postmarkApiRequest(
|
|||||||
options = Object.assign({}, options, option);
|
options = Object.assign({}, options, option);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'postmarkApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user