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.

43 lines (42 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const models_1 = require("../models"); class Budgets { constructor(fcSdk) { this.fcSdk = fcSdk; this.path = "/budgets"; } get(id) { const uri = `${this.path}/${id}`; return this.fcSdk.doGet(uri, this.processResponse); } update(id, updateObject) { const uri = `${this.path}/${id}`; return this.fcSdk.doPut(uri, updateObject.plainObject, this.processResponse); } create(createBudget) { const uri = `${this.path}`; return this.fcSdk.doPost(uri, createBudget.plainObject, this.processResponse); } processResponse(response) { return new models_1.Budget(response); } delete(id) { const uri = `${this.path}/${id}`; return this.fcSdk.doDelete(uri, this.processDeleteResponse); } processDeleteResponse(status) { return status === "" ? 204 : 500; } list(cursor) { const params = cursor ? `?userId=${cursor}` : ""; const uri = `${this.path}${params}`; return this.fcSdk.doGet(uri, this.processlistResponse); } processlistResponse(response) { return response.data ? [...response.data].reverse().map((bud) => new models_1.Budget(bud)) : []; } } exports.default = Budgets;