mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(ERPNext Node): Add credential test and add support for unauthorized certs (#3732)
* ✨ Add cred injection, cred testing, allow unauthorized certs * Add support for skipping SSL for cred testing * 📘 Add partial override for request options types (#3739) * Change field names and fix error handling * Fix typo Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
NodeApiError,
|
||||
NodeOperationError
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function erpNextApiRequest(
|
||||
@@ -31,13 +30,13 @@ export async function erpNextApiRequest(
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `token ${credentials.apiKey}:${credentials.apiSecret}`,
|
||||
},
|
||||
method,
|
||||
body,
|
||||
qs: query,
|
||||
uri: uri || `${baseUrl}${resource}`,
|
||||
json: true,
|
||||
rejectUnauthorized: !credentials.allowUnauthorizedCerts as boolean,
|
||||
};
|
||||
|
||||
options = Object.assign({}, options, option);
|
||||
@@ -50,7 +49,7 @@ export async function erpNextApiRequest(
|
||||
delete options.qs;
|
||||
}
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
return await this.helpers.requestWithAuthentication.call(this, 'erpNextApi',options);
|
||||
} catch (error) {
|
||||
if (error.statusCode === 403) {
|
||||
throw new NodeApiError(this.getNode(), { message: 'DocType unavailable.' });
|
||||
@@ -105,4 +104,5 @@ type ERPNextApiCredentials = {
|
||||
environment: 'cloudHosted' | 'selfHosted';
|
||||
subdomain?: string;
|
||||
domain?: string;
|
||||
allowUnauthorizedCerts?: boolean;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user