UNPKG

@pokt-network/pocket-js

Version:

Pocket-js core package with the main functionalities to interact with the Pocket Network.

81 lines 2.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.QueryNodeReceiptsResponse = void 0; var stored_receipt_1 = require("../stored-receipt"); /** * * * @class QueryNodeReceiptsResponse */ var QueryNodeReceiptsResponse = /** @class */ (function () { /** * QueryNodeReceiptsResponse. * @constructor * @param {StoredReceipt[]} storedReceipts - Stored receipts array. */ function QueryNodeReceiptsResponse(storedReceipts, page, totalPages) { this.storedReceipts = storedReceipts; this.page = page; this.totalPages = totalPages; } /** * * Creates a QueryNodeReceiptsResponse object using a JSON string * @param {String} json - JSON string. * @returns {QueryNodeReceiptsResponse} - QueryNodeReceiptsResponse object. * @memberof QueryNodeReceiptsResponse */ QueryNodeReceiptsResponse.fromJSON = function (json) { try { var jsonObject = JSON.parse(json); var receipts_1 = []; if (jsonObject.result) { jsonObject.result.forEach(function (receiptJSON) { var receipt = stored_receipt_1.StoredReceipt.fromJSON(JSON.stringify(receiptJSON)); receipts_1.push(receipt); }); } return new QueryNodeReceiptsResponse(receipts_1, jsonObject.page, jsonObject.total_pages); } catch (error) { throw error; } }; /** * * Creates a JSON object with the QueryNodeReceiptsResponse properties * @returns {JSON} - JSON Object. * @memberof QueryNodeReceiptsResponse */ QueryNodeReceiptsResponse.prototype.toJSON = function () { var receiptsListJSON = []; this.storedReceipts.forEach(function (receipt) { receiptsListJSON.push(receipt.toJSON()); }); var jsonObject = { result: receiptsListJSON, page: this.page, total_pages: this.totalPages }; return jsonObject; }; /** * * Check if the QueryNodeReceiptsResponse object is valid * @returns {boolean} - True or false. * @memberof QueryNodeReceiptsResponse */ QueryNodeReceiptsResponse.prototype.isValid = function () { if (this.storedReceipts.length > 0) { this.storedReceipts.forEach(function (receipt) { if (!receipt.isValid()) { return false; } }); } return true; }; return QueryNodeReceiptsResponse; }()); exports.QueryNodeReceiptsResponse = QueryNodeReceiptsResponse; //# sourceMappingURL=query-node-receipts-response.js.map