UNPKG

1.1 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const querystring_1 = tslib_1.__importDefault(require("querystring"));
5const authorization_1 = tslib_1.__importDefault(require("./authorization/authorization"));
6const helpers_1 = require("./authorization/helpers");
7function buildBody(bodyParams) {
8 return querystring_1.default.stringify(bodyParams, "&", "=", {
9 encodeURIComponent: helpers_1.percentEncode,
10 });
11}
12function oAuthV1Request({ baseURL, method, params = {}, data = {}, oAuthOptions, }) {
13 const stringData = buildBody(data);
14 return {
15 baseURL,
16 method,
17 params,
18 data: stringData,
19 headers: {
20 "Content-Type": "application/x-www-form-urlencoded",
21 "Content-Length": Buffer.byteLength(stringData),
22 Authorization: authorization_1.default({
23 baseURL,
24 method,
25 params,
26 data,
27 oAuthOptions,
28 }),
29 },
30 };
31}
32exports.default = oAuthV1Request;