UNPKG

@magic.batua/utility

Version:

The Utility module manages all the utility bills functionalities of the Magic Batua platform.

46 lines 1.67 kB
"use strict"; /** * @module UtilityBill * @overview Defines the `UtilityBill` class * * @author Animesh Mishra <hello@animesh.ltd> * @copyright © 2018 Animesh Ltd. All Rights Reserved. */ Object.defineProperty(exports, "__esModule", { value: true }); const Electricity_1 = require("./Source/Electricity"); exports.Electricity = Electricity_1.Electricity; const Gas_1 = require("./Source/Gas"); exports.Gas = Gas_1.Gas; const Insurance_1 = require("./Source/Insurance"); exports.Insurance = Insurance_1.Insurance; const Provider_1 = require("./Source/Provider"); exports.Provider = Provider_1.Provider; /** * Models a utility bill. */ class UtilityBill { constructor(instructions, response) { // Set transaction category switch (instructions.constructor) { case Electricity_1.Electricity: this.service = "Electricity"; break; case Gas_1.Gas: this.service = "Gas"; break; default: this.service = "Insurance"; } this.instructions = instructions; this.status = response.status; this.vendorReference = response.rocket_trans_id; this.operatorReference = response.opr_transid; this.amountCharged = Number(response.charged_amt); // response.datetime has "[UTC]" as suffix which needs to be removed // for successful instantiation of a Date object let formattedDate = response.datetime.substr(0, response.datetime.indexOf("[")); this.date = new Date(formattedDate); } } exports.UtilityBill = UtilityBill; //# sourceMappingURL=index.js.map