UNPKG

@pokt-network/pocket-js

Version:

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

77 lines 2.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.QueryAppsResponse = void 0; var application_1 = require("../application"); /** * * * @class QueryAppsResponse */ var QueryAppsResponse = /** @class */ (function () { /** * QueryAppsResponse. * @constructor * @param {Application[]} applications - Amount staked by the node. * @param {number} page - Current page. * @param {number} totalPages - Total amount of pages. */ function QueryAppsResponse(applications, page, totalPages) { this.applications = applications; this.page = page; this.totalPages = totalPages; } /** * * Creates a QueryAppsResponse object using a JSON string * @param {string} json - JSON string. * @returns {QueryAppsResponse} - QueryAppsResponse object. * @memberof QueryAppsResponse */ QueryAppsResponse.fromJSON = function (json) { try { var jsonObject = JSON.parse(json); var apps_1 = []; if (Array.isArray(jsonObject.result)) { jsonObject.result.forEach(function (appJSON) { var app = application_1.Application.fromJSON(JSON.stringify(appJSON)); apps_1.push(app); }); } return new QueryAppsResponse(apps_1, jsonObject.page, jsonObject.total_pages); } catch (error) { throw error; } }; /** * * Creates a JSON object with the QueryAppsResponse properties * @returns {JSON} - JSON Object. * @memberof QueryAppsResponse */ QueryAppsResponse.prototype.toJSON = function () { var appListJSON = []; this.applications.forEach(function (app) { appListJSON.push(app.toJSON()); }); return { result: appListJSON, page: this.page, total_pages: this.totalPages }; }; /** * * Check if the QueryAppsResponse object is valid * @returns {boolean} - True or false. * @memberof QueryAppsResponse */ QueryAppsResponse.prototype.isValid = function () { return this.applications !== undefined && this.page >= 0 && this.totalPages >= 0; }; return QueryAppsResponse; }()); exports.QueryAppsResponse = QueryAppsResponse; //# sourceMappingURL=query-apps-response.js.map