UNPKG

@pokt-network/pocket-js

Version:

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

83 lines 2.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.QueryNodeClaimsResponse = void 0; var msg_claim_1 = require("./msg-claim"); /** * * * @class QueryNodeClaimsResponse */ var QueryNodeClaimsResponse = /** @class */ (function () { /** * Query Node Claims Response. * @constructor * @param {MsgClaim[]} msgClaims - Stored receipt object. */ function QueryNodeClaimsResponse(msgClaims, page, totalPages) { this.msgClaims = msgClaims; this.page = page; this.totalPages = totalPages; if (!this.isValid()) { throw new TypeError("Invalid QueryNodeClaimsResponse properties."); } } /** * * Creates a QueryNodeClaimsResponse object using a JSON string * @param {String} json - JSON string. * @returns {QueryNodeClaimsResponse} - QueryNodeClaimsResponse object. * @memberof QueryNodeClaimsResponse */ QueryNodeClaimsResponse.fromJSON = function (json) { try { var jsonObject = JSON.parse(json); var msgClaims_1 = []; if (jsonObject.result) { jsonObject.result.forEach(function (claim) { var msgClaim = msg_claim_1.MsgClaim.fromJSON(JSON.stringify(claim)); msgClaims_1.push(msgClaim); }); } return new QueryNodeClaimsResponse(msgClaims_1, jsonObject.page, jsonObject.total_pages); } catch (error) { throw error; } }; /** * * Creates a JSON object with the QueryNodeClaimsResponse properties * @returns {JSON} - JSON Object. * @memberof QueryNodeClaimsResponse */ QueryNodeClaimsResponse.prototype.toJSON = function () { var msgClaimsList = []; this.msgClaims.forEach(function (msgClaim) { msgClaimsList.push(msgClaim.toJSON()); }); return { page: this.page, total_pages: this.totalPages, result: msgClaimsList }; }; /** * * Check if the QueryNodeClaimsResponse object is valid * @returns {boolean} - True or false. * @memberof QueryNodeClaimsResponse */ QueryNodeClaimsResponse.prototype.isValid = function () { if (this.msgClaims.length > 0) { this.msgClaims.forEach(function (msg) { if (!msg.isValid()) { return false; } }); } return true; }; return QueryNodeClaimsResponse; }()); exports.QueryNodeClaimsResponse = QueryNodeClaimsResponse; //# sourceMappingURL=query-node-claims-response.js.map