UNPKG

finerio-pfm-unnax

Version:

This SDK lets you connect to [Finerio PFM API Unnax](http://ec2-3-16-174-50.us-east-2.compute.amazonaws.com:8082/swagger-ui/index.html#/) in an easier way.

40 lines (39 loc) 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const models_1 = require("../models"); class Accounts { constructor(fcSdk) { this.fcSdk = fcSdk; this.path = "/accounts"; } processResponse(response) { return new models_1.Account(response); } processDeleteResponse(status) { return status === "" ? 204 : 500; } processListResponse(response) { if (!response.data) { return []; } return response.data.map((account) => new models_1.Account(account)); } get(id) { return this.fcSdk.doGet(`${this.path}/${id}`, this.processResponse); } update(id, updateObject) { return this.fcSdk.doPut(`${this.path}/${id}`, updateObject ? updateObject.plainObject : {}, this.processResponse); } create(accountToCreate) { return this.fcSdk.doPost(this.path, accountToCreate.plainObject, this.processResponse); } delete(id) { return this.fcSdk.doDelete(`${this.path}/${id}`, this.processDeleteResponse); } list(cursor) { const params = cursor ? `?cursor=${cursor}` : ""; const uri = `${this.path}${params}`; return this.fcSdk.doGet(uri, this.processListResponse); } } exports.default = Accounts;