UNPKG

n8n-nodes-wechat-work

Version:
37 lines 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const n8n_workflow_1 = require("n8n-workflow"); class WechatWorkRequestUtils { static async originRequest(options, clearAccessToken = false) { const credentials = await this.getCredentials('wechatWorkCredentialsApi'); return this.helpers.requestWithAuthentication.call(this, 'wechatWorkCredentialsApi', options, { credentialsDecrypted: { data: { ...credentials, accessToken: clearAccessToken ? '' : credentials.accessToken, }, }, }); } static async request(options) { return WechatWorkRequestUtils.originRequest.call(this, options).then((text) => { const data = JSON.parse(text); if (data.errcode === 42001) { return WechatWorkRequestUtils.originRequest.call(this, options, true) .then((text) => { const data = JSON.parse(text); if (data.errcode !== 0) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), `WechatWork Error: ${data.errcode}, ${data.errmsg}`); } return data; }); } if (data.errcode !== 0) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), `WechatWork Error: ${data.errcode}, ${data.errmsg}`); } return data; }); } } exports.default = WechatWorkRequestUtils; //# sourceMappingURL=WechatWorkRequestUtils.js.map