-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.js
142 lines (142 loc) · 4.72 KB
/
common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
"use strict";
/* tslint:disable */
/* eslint-disable */
/**
* UsersManager
* Scribe user management
*
* The version of the OpenAPI document: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
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) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const base_1 = require("./base");
/**
*
* @export
*/
exports.DUMMY_BASE_URL = 'https://example.com';
/**
*
* @throws {RequiredError}
* @export
*/
exports.assertParamExists = function (functionName, paramName, paramValue) {
if (paramValue === null || paramValue === undefined) {
throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
}
};
/**
*
* @export
*/
exports.setApiKeyToObject = function (object, keyParamName, configuration) {
return __awaiter(this, void 0, void 0, function* () {
if (configuration && configuration.apiKey) {
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
? yield configuration.apiKey(keyParamName)
: yield configuration.apiKey;
object[keyParamName] = localVarApiKeyValue;
}
});
};
/**
*
* @export
*/
exports.setBasicAuthToObject = function (object, configuration) {
if (configuration && (configuration.username || configuration.password)) {
object["auth"] = { username: configuration.username, password: configuration.password };
}
};
/**
*
* @export
*/
exports.setBearerAuthToObject = function (object, configuration) {
return __awaiter(this, void 0, void 0, function* () {
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? yield configuration.accessToken()
: yield configuration.accessToken;
object["Authorization"] = "Bearer " + accessToken;
}
});
};
/**
*
* @export
*/
exports.setOAuthToObject = function (object, name, scopes, configuration) {
return __awaiter(this, void 0, void 0, function* () {
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? yield configuration.accessToken(name, scopes)
: yield configuration.accessToken;
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
}
});
};
/**
*
* @export
*/
exports.setSearchParams = function (url, ...objects) {
const searchParams = new URLSearchParams(url.search);
for (const object of objects) {
for (const key in object) {
if (Array.isArray(object[key])) {
searchParams.delete(key);
for (const item of object[key]) {
searchParams.append(key, item);
}
}
else {
searchParams.set(key, object[key]);
}
}
}
url.search = searchParams.toString();
};
/**
*
* @export
*/
exports.serializeDataIfNeeded = function (value, requestOptions, configuration) {
const nonString = typeof value !== 'string';
const needsSerialization = nonString && configuration && configuration.isJsonMime
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
: nonString;
return needsSerialization
? JSON.stringify(value !== undefined ? value : {})
: (value || "");
};
/**
*
* @export
*/
exports.toPathString = function (url) {
return url.pathname + url.search + url.hash;
};
/**
*
* @export
*/
exports.createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
return (axios = globalAxios, basePath = BASE_PATH) => {
const axiosRequestArgs = Object.assign(Object.assign({}, axiosArgs.options), { url: ((configuration === null || configuration === void 0 ? void 0 : configuration.basePath) || basePath) + axiosArgs.url });
return axios.request(axiosRequestArgs);
};
};