| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- "use strict";
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- const request = require("request-promise");
- class WebClientNode {
- request(options) {
- return __awaiter(this, void 0, void 0, function* () {
- const rpOptions = {
- body: options.body,
- method: options.method,
- uri: options.url,
- headers: options.headers
- };
- const result = yield request(rpOptions);
- return result;
- });
- }
- requestJSON(options) {
- return __awaiter(this, void 0, void 0, function* () {
- if (!options.headers) {
- options.headers = {};
- }
- if (options.body) {
- options.headers['content-type'] = 'application/json';
- if (typeof options.body === 'object') {
- options.body = JSON.stringify(options.body);
- }
- }
- options.headers.accept = 'application/json';
- const rpOptions = {
- body: options.body,
- formData: options.formData || {},
- headers: options.headers,
- method: options.method,
- uri: options.url,
- };
- const result = yield request(rpOptions);
- return JSON.parse(result);
- });
- }
- }
- exports.default = WebClientNode;
- //# sourceMappingURL=webclient-node.js.map
|