UNPKG

@skriptfabrik/n8n-nodes-otto-market

Version:
80 lines 2.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OttoMarket = void 0; const tslib_1 = require("tslib"); const querystring = require("querystring"); class OttoMarket { constructor() { this.name = 'ottoMarketApi'; this.displayName = 'OTTO Market'; this.documentationUrl = "https://api.otto.market/docs#section/OTTO-Market-API-Developer's-Guide/Authorization-(OAuth2)"; this.properties = [ { displayName: 'Username', name: 'username', type: 'string', placeholder: 'username', required: true, default: undefined, }, { displayName: 'Password', name: 'password', type: 'string', typeOptions: { password: true, }, required: true, default: undefined, }, { displayName: 'Access Token', name: 'accessToken', type: 'hidden', typeOptions: { expirable: true, }, default: undefined, }, ]; this.authenticate = { type: 'generic', properties: { headers: { Authorization: '=Bearer {{$credentials.accessToken}}', }, }, }; this.test = { request: { baseURL: 'https://api.otto.market', url: '/v3/products', qs: { limit: 1, }, }, }; } preAuthentication(credentials) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const response = (yield this.helpers.httpRequest({ method: 'POST', url: 'https://api.otto.market/v1/token', headers: { 'content-type': 'application/x-www-form-urlencoded', }, body: querystring.stringify({ username: credentials['username'], password: credentials['password'], grant_type: 'password', client_id: 'token-otto-api', }), })); return { accessToken: response.access_token, }; }); } } exports.OttoMarket = OttoMarket; //# sourceMappingURL=OttoMarket.credentials.js.map