2020-08-25 23:36:04 +00:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.http = void 0;
|
2020-08-26 00:20:01 +00:00
|
|
|
var fetch = require('node-fetch');
|
2021-02-26 04:00:44 +00:00
|
|
|
var https = require('https');
|
2020-08-25 23:36:04 +00:00
|
|
|
var Http = (function () {
|
|
|
|
function Http() {
|
|
|
|
}
|
2021-02-26 04:00:44 +00:00
|
|
|
Http.prototype.make = function (url, headers, body, ignoreCertificate) {
|
2020-08-26 00:31:06 +00:00
|
|
|
var _this = this;
|
2020-08-26 00:34:42 +00:00
|
|
|
return new Promise(function (resolve, reject) {
|
2021-02-26 04:00:44 +00:00
|
|
|
fetch(url, _this.getOptions('post', headers, body, ignoreCertificate)).then(function (res) { return resolve(res); });
|
2020-08-25 23:36:04 +00:00
|
|
|
});
|
|
|
|
};
|
2021-02-26 04:00:44 +00:00
|
|
|
Http.prototype.getOptions = function (method, headers, body, ignoreCertificate) {
|
2020-08-26 00:20:01 +00:00
|
|
|
var options = {
|
2020-08-26 00:41:58 +00:00
|
|
|
headers: headers ? JSON.parse(headers) : {},
|
2020-08-26 00:20:01 +00:00
|
|
|
method: method
|
|
|
|
};
|
2020-08-26 00:41:58 +00:00
|
|
|
if (body) {
|
|
|
|
options.body = body;
|
|
|
|
}
|
2021-02-26 04:00:44 +00:00
|
|
|
if (ignoreCertificate) {
|
|
|
|
options.agent = new https.Agent({ rejectUnauthorized: false });
|
|
|
|
}
|
2020-08-26 00:20:01 +00:00
|
|
|
options.headers['content-type'] = 'application/json';
|
|
|
|
return options;
|
2020-08-25 23:36:04 +00:00
|
|
|
};
|
|
|
|
return Http;
|
|
|
|
}());
|
|
|
|
exports.http = new Http();
|
|
|
|
//# sourceMappingURL=http.js.map
|