@pokt-network/pocket-js
Version:
Pocket-js core package with the main functionalities to interact with the Pocket Network.
54 lines • 1.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DispatchRequest = void 0;
var session_header_1 = require("./session-header");
/**
*
*
* @class DispatchRequest
*/
var DispatchRequest = /** @class */ (function () {
/**
* Dispatch Request.
* @constructor
* @param {SessionHeader} sessionHeader - Session header object.
*/
function DispatchRequest(sessionHeader) {
this.sessionHeader = sessionHeader;
if (!this.isValid()) {
throw new TypeError("Invalid properties length.");
}
}
/**
*
* Creates a DispatchRequest object using a JSON string
* @param {String} json - JSON string.
* @returns {DispatchRequest} - DispatchRequest object.
* @memberof DispatchRequest
*/
DispatchRequest.fromJSON = function (json) {
var jsonObj = JSON.parse(json);
return new DispatchRequest(session_header_1.SessionHeader.fromJSON(JSON.stringify(jsonObj.session_header)));
};
/**
*
* Creates a JSON object with the DispatchRequest properties
* @returns {JSON} - JSON Object.
* @memberof DispatchRequest
*/
DispatchRequest.prototype.toJSON = function () {
return this.sessionHeader.toJSON();
};
/**
*
* Check if the DispatchRequest object is valid
* @returns {boolean} - True or false.
* @memberof DispatchRequest
*/
DispatchRequest.prototype.isValid = function () {
return this.sessionHeader.isValid();
};
return DispatchRequest;
}());
exports.DispatchRequest = DispatchRequest;
//# sourceMappingURL=dispatch-request.js.map