UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

45 lines 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dhlApiRequest = dhlApiRequest; exports.validateCredentials = validateCredentials; const n8n_workflow_1 = require("n8n-workflow"); async function dhlApiRequest(method, path, body = {}, qs = {}, uri, option = {}) { const credentials = await this.getCredentials('dhlApi'); let options = { headers: { 'DHL-API-Key': credentials.apiKey, }, method, qs, body, uri: uri || `https://api-eu.dhl.com${path}`, json: true, }; options = Object.assign({}, options, option); if (Object.keys(options.body).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { throw new n8n_workflow_1.NodeApiError(this.getNode(), error); } } async function validateCredentials(decryptedCredentials) { const credentials = decryptedCredentials; const { apiKey } = credentials; const options = { headers: { 'DHL-API-Key': apiKey, }, qs: { trackingNumber: 123, }, method: 'GET', uri: 'https://api-eu.dhl.com/track/shipments', json: true, }; return await this.helpers.request(options); } //# sourceMappingURL=GenericFunctions.js.map