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.

46 lines (45 loc) 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const models_1 = require("../models"); class Transactions { constructor(fcSdk) { this.fcSdk = fcSdk; this.path = "/transactions"; } processResponseBuild() { return (response) => { return new models_1.Transaction(Object.assign({}, response)); }; } processDeleteResponse(status) { return status === "" ? 204 : 500; } processListResponseBuild() { return (response) => { return new models_1.TransactionList({ transactions: response.transactions.map((transaction) => new models_1.Transaction(Object.assign({}, transaction))), currentPage: response.currentPage, totalPages: response.totalPages, totalItems: response.totalItems, }); }; } get(id) { return this.fcSdk.doGet(`${this.path}/${id}`, this.processResponseBuild()); } update(id, updateObject) { return this.fcSdk.doPut(`${this.path}/${id}`, updateObject ? updateObject.plainObject : {}, this.processResponseBuild()); } create(transactionToCreate) { return this.fcSdk.doPost(this.path, transactionToCreate.plainObject, this.processResponseBuild()); } delete(id) { return this.fcSdk.doDelete(`${this.path}/${id}`, this.processDeleteResponse); } list(listOptions) { const params = listOptions ? this.fcSdk.getUriParams(listOptions) : ""; const uri = `${this.path}${params}`; return this.fcSdk.doGet(uri, this.processListResponseBuild()); } } exports.default = Transactions;