UNPKG

fsm-sdk

Version:

Node.JS sdk to interface with SAP Field Service Management APIs.

44 lines 2.36 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AccountAPIService = void 0; const http_service_1 = require("../http/http-service"); const request_options_factory_1 = require("../request-options.factory"); class AccountAPIService { constructor(_config, _auth) { this._config = _config; this._auth = _auth; this.http = new http_service_1.HttpService(_config); } getApiPath() { return 'm' + `aster/v1`; // inclusive wording check failing, can not rename the API path :) } getCompaniesByAccount(accountId) { return __awaiter(this, void 0, void 0, function* () { const token = yield this._auth.ensureToken(this._config); return yield this.http.request(`${this._config.baseUrl}/api/${this.getApiPath()}/v1/accounts/${accountId}/companies`, { method: 'GET', headers: Object.assign({ 'content-type': 'application/json' }, request_options_factory_1.RequestOptionsFactory.getRequestHeaders(token, this._config)), }); }); } getAccounts() { return __awaiter(this, void 0, void 0, function* () { const token = yield this._auth.ensureToken(this._config); return yield this.http.request(`${this._config.baseUrl}/api/${this.getApiPath()}/accounts`, { method: 'GET', headers: Object.assign({ 'content-type': 'application/json' }, request_options_factory_1.RequestOptionsFactory.getRequestHeaders(token, this._config)), }); }); } } exports.AccountAPIService = AccountAPIService; //# sourceMappingURL=account-api.service.js.map