UNPKG

n8n-nodes-quipu

Version:

Quipu integration for n8n - invoice and taxes software for freelancers and companies

75 lines 2.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.QuipuApi = void 0; class QuipuApi { constructor() { this.name = "quipuApi"; this.displayName = "Quipu API"; this.documentationUrl = "https://getquipu.com/en/integrations"; this.properties = [ { displayName: "Client ID", name: "clientId", type: "string", default: "", }, { displayName: "Client Secret", name: "clientSecret", type: "string", default: "", typeOptions: { password: true, }, }, { displayName: "Environment", name: "environment", type: "options", default: "production", options: [ { name: "Production", value: "production", }, ], }, ]; } async authenticate(credentials, requestOptions) { const response = await this.getToken(credentials); const { access_token } = response; requestOptions.headers = { ...requestOptions.headers, Accept: "application/vnd.quipu.v1+json", Authorization: `Bearer ${access_token}`, }; return requestOptions; } async getToken(credentials) { const { clientId, clientSecret } = credentials; const baseUrl = "https://getquipu.com"; const options = { headers: { "Content-Type": "application/x-www-form-urlencoded", }, method: "POST", form: { grant_type: "client_credentials", scope: "ecommerce", client_id: clientId, client_secret: clientSecret, }, uri: `${baseUrl}/oauth/token`, json: true, }; try { return await this.helpers.request(options); } catch (error) { throw new Error("Failed to get access token from Quipu API: " + error); } } } exports.QuipuApi = QuipuApi; //# sourceMappingURL=QuipuApi.credentials.js.map