1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const querystring_1 = tslib_1.__importDefault(require("querystring"));
|
5 | const authorization_1 = tslib_1.__importDefault(require("./authorization/authorization"));
|
6 | const helpers_1 = require("./authorization/helpers");
|
7 | function buildBody(bodyParams) {
|
8 | return querystring_1.default.stringify(bodyParams, "&", "=", {
|
9 | encodeURIComponent: helpers_1.percentEncode,
|
10 | });
|
11 | }
|
12 | function 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 | }
|
32 | exports.default = oAuthV1Request;
|