mpp-sdk
Version:
SDK to talk to the Memento Payments Platform
29 lines (28 loc) • 951 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MPPResult = void 0;
const headers_1 = require("../utils/headers");
class MPPResult {
constructor(response, doRequest) {
this.data = response.data;
this.request_id = response.headers["request-id"];
this.fetched_at = new Date();
this.links = {};
if (doRequest) {
const linkHeader = response.headers.link;
if (linkHeader) {
const links = (0, headers_1.parseLinkHeader)(linkHeader);
for (const link of links) {
const rel = link.attrs["rel"];
if (rel) {
this.links[rel] = () => doRequest({
url: link.uri,
method: "GET",
});
}
}
}
}
}
}
exports.MPPResult = MPPResult;