boldsign
Version:
NodeJS client for boldsign
723 lines • 36 kB
JavaScript
"use strict";
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());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserApi = void 0;
const axios_1 = __importDefault(require("axios"));
const model_1 = require("../model");
const _1 = require("./");
let defaultBasePath = 'https://api.boldsign.com';
class UserApi {
constructor(basePath) {
this._basePath = defaultBasePath;
this._defaultHeaders = { 'User-Agent': _1.USER_AGENT };
this._useQuerystring = true;
this.authentications = {
'default': new model_1.VoidAuth(),
'Bearer': new model_1.ApiKeyAuth('header', 'Authorization'),
'X-API-KEY': new model_1.ApiKeyAuth('header', 'X-API-KEY'),
};
this.interceptors = [];
if (basePath) {
this.basePath = basePath;
}
}
set useQuerystring(value) {
this._useQuerystring = value;
}
set basePath(basePath) {
this._basePath = basePath;
}
set defaultHeaders(defaultHeaders) {
this._defaultHeaders = Object.assign(Object.assign({}, defaultHeaders), { "User-Agent": _1.USER_AGENT });
}
get defaultHeaders() {
return this._defaultHeaders;
}
get basePath() {
return this._basePath;
}
setDefaultAuthentication(auth) {
this.authentications.default = auth;
}
setApiKey(apikey) {
this.authentications["X-API-KEY"].apiKey = apikey;
}
setAccessToken(accessToken) {
this.authentications["Bearer"].apiKey = 'bearer ' + accessToken;
}
addInterceptor(interceptor) {
this.interceptors.push(interceptor);
}
cancelInvitation(userId_1) {
return __awaiter(this, arguments, void 0, function* (userId, options = { headers: {} }) {
const localVarPath = this.basePath + '/v1/users/cancelInvitation';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams['content-type'] = 'application/json';
}
else {
localVarHeaderParams['content-type'] = produces.join(',');
}
let localVarFormParams = {};
let localVarBodyParams = undefined;
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling cancelInvitation.');
}
if (userId !== undefined) {
localVarQueryParameters['UserId'] = model_1.ObjectSerializer.serialize(userId, "string");
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let data = {};
if (localVarUseFormData) {
const formData = (0, _1.toFormData)(localVarFormParams);
data = formData;
localVarHeaderParams = Object.assign(Object.assign({}, localVarHeaderParams), formData.getHeaders());
}
let localVarRequestOptions = {
method: 'POST',
params: localVarQueryParameters,
headers: localVarHeaderParams,
url: localVarPath,
paramsSerializer: this._useQuerystring ? _1.queryParamsSerializer : undefined,
maxContentLength: Infinity,
maxBodyLength: Infinity,
responseType: "json",
};
if (localVarRequestOptions.method !== 'GET') {
localVarRequestOptions.data = data;
}
let authenticationPromise = Promise.resolve();
if (this.authentications["X-API-KEY"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["X-API-KEY"].applyToRequest(localVarRequestOptions));
}
if (this.authentications["Bearer"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["Bearer"].applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
return new Promise((resolve, reject) => {
axios_1.default.request(localVarRequestOptions)
.then((response) => {
handleSuccessfulResponse(resolve, reject, response);
}, (error) => {
if (error.response == null) {
reject(error);
return;
}
if (handleErrorCodeResponse(reject, error.response, 401, "ErrorResult")) {
return;
}
if (handleErrorCodeResponse(reject, error.response, 403, "ErrorResult")) {
return;
}
reject(error);
});
});
});
});
}
changeTeam(userId_1, changeTeamRequest_1) {
return __awaiter(this, arguments, void 0, function* (userId, changeTeamRequest, options = { headers: {} }) {
changeTeamRequest = deserializeIfNeeded(changeTeamRequest, "ChangeTeamRequest");
const localVarPath = this.basePath + '/v1/users/changeTeam';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams['content-type'] = 'application/json';
}
else {
localVarHeaderParams['content-type'] = produces.join(',');
}
let localVarFormParams = {};
let localVarBodyParams = undefined;
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling changeTeam.');
}
if (userId !== undefined) {
localVarQueryParameters['userId'] = model_1.ObjectSerializer.serialize(userId, "string");
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
const result = (0, _1.generateFormData)(changeTeamRequest, model_1.ChangeTeamRequest);
localVarUseFormData = result.localVarUseFormData;
let data = {};
if (localVarUseFormData) {
const formData = (0, _1.toFormData)(result.data);
data = formData;
localVarHeaderParams = Object.assign(Object.assign({}, localVarHeaderParams), formData.getHeaders());
}
else {
data = model_1.ObjectSerializer.serialize(changeTeamRequest, "ChangeTeamRequest");
}
let localVarRequestOptions = {
method: 'PUT',
params: localVarQueryParameters,
headers: localVarHeaderParams,
url: localVarPath,
paramsSerializer: this._useQuerystring ? _1.queryParamsSerializer : undefined,
maxContentLength: Infinity,
maxBodyLength: Infinity,
responseType: "json",
};
if (localVarRequestOptions.method !== 'GET') {
localVarRequestOptions.data = data;
}
let authenticationPromise = Promise.resolve();
if (this.authentications["X-API-KEY"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["X-API-KEY"].applyToRequest(localVarRequestOptions));
}
if (this.authentications["Bearer"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["Bearer"].applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
return new Promise((resolve, reject) => {
axios_1.default.request(localVarRequestOptions)
.then((response) => {
handleSuccessfulResponse(resolve, reject, response);
}, (error) => {
if (error.response == null) {
reject(error);
return;
}
if (handleErrorCodeResponse(reject, error.response, 401, "ErrorResult")) {
return;
}
if (handleErrorCodeResponse(reject, error.response, 403, "ErrorResult")) {
return;
}
reject(error);
});
});
});
});
}
createUser(createUser_1) {
return __awaiter(this, arguments, void 0, function* (createUser, options = { headers: {} }) {
createUser = deserializeIfNeeded(createUser, "Array<CreateUser>");
const localVarPath = this.basePath + '/v1/users/create';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams['content-type'] = 'application/json';
}
else {
localVarHeaderParams['content-type'] = produces.join(',');
}
let localVarFormParams = {};
let localVarBodyParams = undefined;
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
const result = (0, _1.generateFormData)(createUser, (Array));
localVarUseFormData = result.localVarUseFormData;
let data = {};
if (localVarUseFormData) {
const formData = (0, _1.toFormData)(result.data);
data = formData;
localVarHeaderParams = Object.assign(Object.assign({}, localVarHeaderParams), formData.getHeaders());
}
else {
data = model_1.ObjectSerializer.serialize(createUser, "Array<CreateUser>");
}
let localVarRequestOptions = {
method: 'POST',
params: localVarQueryParameters,
headers: localVarHeaderParams,
url: localVarPath,
paramsSerializer: this._useQuerystring ? _1.queryParamsSerializer : undefined,
maxContentLength: Infinity,
maxBodyLength: Infinity,
responseType: "json",
};
if (localVarRequestOptions.method !== 'GET') {
localVarRequestOptions.data = data;
}
let authenticationPromise = Promise.resolve();
if (this.authentications["X-API-KEY"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["X-API-KEY"].applyToRequest(localVarRequestOptions));
}
if (this.authentications["Bearer"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["Bearer"].applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
return new Promise((resolve, reject) => {
axios_1.default.request(localVarRequestOptions)
.then((response) => {
handleSuccessfulResponse(resolve, reject, response);
}, (error) => {
if (error.response == null) {
reject(error);
return;
}
if (handleErrorCodeResponse(reject, error.response, 401, "ErrorResult")) {
return;
}
if (handleErrorCodeResponse(reject, error.response, 403, "ErrorResult")) {
return;
}
reject(error);
});
});
});
});
}
getUser(userId_1) {
return __awaiter(this, arguments, void 0, function* (userId, options = { headers: {} }) {
const localVarPath = this.basePath + '/v1/users/get';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams['content-type'] = 'application/json';
}
else {
localVarHeaderParams['content-type'] = produces.join(',');
}
let localVarFormParams = {};
let localVarBodyParams = undefined;
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling getUser.');
}
if (userId !== undefined) {
localVarQueryParameters['userId'] = model_1.ObjectSerializer.serialize(userId, "string");
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let data = {};
if (localVarUseFormData) {
const formData = (0, _1.toFormData)(localVarFormParams);
data = formData;
localVarHeaderParams = Object.assign(Object.assign({}, localVarHeaderParams), formData.getHeaders());
}
let localVarRequestOptions = {
method: 'GET',
params: localVarQueryParameters,
headers: localVarHeaderParams,
url: localVarPath,
paramsSerializer: this._useQuerystring ? _1.queryParamsSerializer : undefined,
maxContentLength: Infinity,
maxBodyLength: Infinity,
responseType: "json",
};
if (localVarRequestOptions.method !== 'GET') {
localVarRequestOptions.data = data;
}
let authenticationPromise = Promise.resolve();
if (this.authentications["X-API-KEY"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["X-API-KEY"].applyToRequest(localVarRequestOptions));
}
if (this.authentications["Bearer"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["Bearer"].applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
return new Promise((resolve, reject) => {
axios_1.default.request(localVarRequestOptions)
.then((response) => {
handleSuccessfulResponse(resolve, reject, response, "UserProperties");
}, (error) => {
if (error.response == null) {
reject(error);
return;
}
if (handleErrorCodeResponse(reject, error.response, 200, "UserProperties")) {
return;
}
if (handleErrorCodeResponse(reject, error.response, 401, "ErrorResult")) {
return;
}
if (handleErrorCodeResponse(reject, error.response, 403, "ErrorResult")) {
return;
}
reject(error);
});
});
});
});
}
listUsers(page_1, pageSize_1, search_1, userId_1) {
return __awaiter(this, arguments, void 0, function* (page, pageSize, search, userId, options = { headers: {} }) {
const localVarPath = this.basePath + '/v1/users/list';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams['content-type'] = 'application/json';
}
else {
localVarHeaderParams['content-type'] = produces.join(',');
}
let localVarFormParams = {};
let localVarBodyParams = undefined;
if (page === null || page === undefined) {
throw new Error('Required parameter page was null or undefined when calling listUsers.');
}
if (pageSize !== undefined) {
localVarQueryParameters['PageSize'] = model_1.ObjectSerializer.serialize(pageSize, "number");
}
if (page !== undefined) {
localVarQueryParameters['Page'] = model_1.ObjectSerializer.serialize(page, "number");
}
if (search !== undefined) {
localVarQueryParameters['Search'] = model_1.ObjectSerializer.serialize(search, "string");
}
if (userId !== undefined) {
localVarQueryParameters['UserId'] = model_1.ObjectSerializer.serialize(userId, "Array<string>");
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let data = {};
if (localVarUseFormData) {
const formData = (0, _1.toFormData)(localVarFormParams);
data = formData;
localVarHeaderParams = Object.assign(Object.assign({}, localVarHeaderParams), formData.getHeaders());
}
let localVarRequestOptions = {
method: 'GET',
params: localVarQueryParameters,
headers: localVarHeaderParams,
url: localVarPath,
paramsSerializer: this._useQuerystring ? _1.queryParamsSerializer : undefined,
maxContentLength: Infinity,
maxBodyLength: Infinity,
responseType: "json",
};
if (localVarRequestOptions.method !== 'GET') {
localVarRequestOptions.data = data;
}
let authenticationPromise = Promise.resolve();
if (this.authentications["X-API-KEY"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["X-API-KEY"].applyToRequest(localVarRequestOptions));
}
if (this.authentications["Bearer"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["Bearer"].applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
return new Promise((resolve, reject) => {
axios_1.default.request(localVarRequestOptions)
.then((response) => {
handleSuccessfulResponse(resolve, reject, response, "UserRecords");
}, (error) => {
if (error.response == null) {
reject(error);
return;
}
if (handleErrorCodeResponse(reject, error.response, 200, "UserRecords")) {
return;
}
if (handleErrorCodeResponse(reject, error.response, 401, "ErrorResult")) {
return;
}
reject(error);
});
});
});
});
}
resendInvitation(userId_1) {
return __awaiter(this, arguments, void 0, function* (userId, options = { headers: {} }) {
const localVarPath = this.basePath + '/v1/users/resendInvitation';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams['content-type'] = 'application/json';
}
else {
localVarHeaderParams['content-type'] = produces.join(',');
}
let localVarFormParams = {};
let localVarBodyParams = undefined;
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling resendInvitation.');
}
if (userId !== undefined) {
localVarQueryParameters['UserId'] = model_1.ObjectSerializer.serialize(userId, "string");
}
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let data = {};
if (localVarUseFormData) {
const formData = (0, _1.toFormData)(localVarFormParams);
data = formData;
localVarHeaderParams = Object.assign(Object.assign({}, localVarHeaderParams), formData.getHeaders());
}
let localVarRequestOptions = {
method: 'POST',
params: localVarQueryParameters,
headers: localVarHeaderParams,
url: localVarPath,
paramsSerializer: this._useQuerystring ? _1.queryParamsSerializer : undefined,
maxContentLength: Infinity,
maxBodyLength: Infinity,
responseType: "json",
};
if (localVarRequestOptions.method !== 'GET') {
localVarRequestOptions.data = data;
}
let authenticationPromise = Promise.resolve();
if (this.authentications["X-API-KEY"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["X-API-KEY"].applyToRequest(localVarRequestOptions));
}
if (this.authentications["Bearer"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["Bearer"].applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
return new Promise((resolve, reject) => {
axios_1.default.request(localVarRequestOptions)
.then((response) => {
handleSuccessfulResponse(resolve, reject, response);
}, (error) => {
if (error.response == null) {
reject(error);
return;
}
if (handleErrorCodeResponse(reject, error.response, 401, "ErrorResult")) {
return;
}
if (handleErrorCodeResponse(reject, error.response, 403, "ErrorResult")) {
return;
}
reject(error);
});
});
});
});
}
updateMetaData(updateUserMetaData_1) {
return __awaiter(this, arguments, void 0, function* (updateUserMetaData, options = { headers: {} }) {
updateUserMetaData = deserializeIfNeeded(updateUserMetaData, "UpdateUserMetaData");
const localVarPath = this.basePath + '/v1/users/updateMetaData';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams['content-type'] = 'application/json';
}
else {
localVarHeaderParams['content-type'] = produces.join(',');
}
let localVarFormParams = {};
let localVarBodyParams = undefined;
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
const result = (0, _1.generateFormData)(updateUserMetaData, model_1.UpdateUserMetaData);
localVarUseFormData = result.localVarUseFormData;
let data = {};
if (localVarUseFormData) {
const formData = (0, _1.toFormData)(result.data);
data = formData;
localVarHeaderParams = Object.assign(Object.assign({}, localVarHeaderParams), formData.getHeaders());
}
else {
data = model_1.ObjectSerializer.serialize(updateUserMetaData, "UpdateUserMetaData");
}
let localVarRequestOptions = {
method: 'PUT',
params: localVarQueryParameters,
headers: localVarHeaderParams,
url: localVarPath,
paramsSerializer: this._useQuerystring ? _1.queryParamsSerializer : undefined,
maxContentLength: Infinity,
maxBodyLength: Infinity,
responseType: "json",
};
if (localVarRequestOptions.method !== 'GET') {
localVarRequestOptions.data = data;
}
let authenticationPromise = Promise.resolve();
if (this.authentications["X-API-KEY"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["X-API-KEY"].applyToRequest(localVarRequestOptions));
}
if (this.authentications["Bearer"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["Bearer"].applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
return new Promise((resolve, reject) => {
axios_1.default.request(localVarRequestOptions)
.then((response) => {
handleSuccessfulResponse(resolve, reject, response);
}, (error) => {
if (error.response == null) {
reject(error);
return;
}
if (handleErrorCodeResponse(reject, error.response, 401, "ErrorResult")) {
return;
}
if (handleErrorCodeResponse(reject, error.response, 403, "ErrorResult")) {
return;
}
reject(error);
});
});
});
});
}
updateUser(updateUser_1) {
return __awaiter(this, arguments, void 0, function* (updateUser, options = { headers: {} }) {
updateUser = deserializeIfNeeded(updateUser, "UpdateUser");
const localVarPath = this.basePath + '/v1/users/update';
let localVarQueryParameters = {};
let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
const produces = ['application/json'];
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams['content-type'] = 'application/json';
}
else {
localVarHeaderParams['content-type'] = produces.join(',');
}
let localVarFormParams = {};
let localVarBodyParams = undefined;
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
const result = (0, _1.generateFormData)(updateUser, model_1.UpdateUser);
localVarUseFormData = result.localVarUseFormData;
let data = {};
if (localVarUseFormData) {
const formData = (0, _1.toFormData)(result.data);
data = formData;
localVarHeaderParams = Object.assign(Object.assign({}, localVarHeaderParams), formData.getHeaders());
}
else {
data = model_1.ObjectSerializer.serialize(updateUser, "UpdateUser");
}
let localVarRequestOptions = {
method: 'PUT',
params: localVarQueryParameters,
headers: localVarHeaderParams,
url: localVarPath,
paramsSerializer: this._useQuerystring ? _1.queryParamsSerializer : undefined,
maxContentLength: Infinity,
maxBodyLength: Infinity,
responseType: "json",
};
if (localVarRequestOptions.method !== 'GET') {
localVarRequestOptions.data = data;
}
let authenticationPromise = Promise.resolve();
if (this.authentications["X-API-KEY"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["X-API-KEY"].applyToRequest(localVarRequestOptions));
}
if (this.authentications["Bearer"].apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications["Bearer"].applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
return new Promise((resolve, reject) => {
axios_1.default.request(localVarRequestOptions)
.then((response) => {
handleSuccessfulResponse(resolve, reject, response);
}, (error) => {
if (error.response == null) {
reject(error);
return;
}
if (handleErrorCodeResponse(reject, error.response, 401, "ErrorResult")) {
return;
}
if (handleErrorCodeResponse(reject, error.response, 403, "ErrorResult")) {
return;
}
reject(error);
});
});
});
});
}
}
exports.UserApi = UserApi;
function deserializeIfNeeded(obj, classname) {
if (obj !== null && obj !== undefined && obj.constructor.name !== classname) {
return model_1.ObjectSerializer.deserialize(obj, classname);
}
return obj;
}
function handleSuccessfulResponse(resolve, reject, response, returnType) {
let body = response.data;
if (response.status &&
response.status >= 200 &&
response.status <= 299) {
if (returnType) {
body = model_1.ObjectSerializer.deserialize(body, returnType);
}
resolve(body);
}
else {
reject(new _1.HttpError(response, body, response.status));
}
}
function handleErrorCodeResponse(reject, response, code, returnType) {
if (response.status !== code) {
return false;
}
let body = response.data;
if (code === 401) {
body = "Unauthorized request (401): Invalid authentication.";
}
reject(new _1.HttpError(response, body, response.status));
return true;
}
function handleErrorRangeResponse(reject, response, code, returnType) {
let rangeCodeLeft = Number(code[0] + "00");
let rangeCodeRight = Number(code[0] + "99");
if (response.status >= rangeCodeLeft && response.status <= rangeCodeRight) {
const body = model_1.ObjectSerializer.deserialize(response.data, returnType);
reject(new _1.HttpError(response, body, response.status));
return true;
}
return false;
}
//# sourceMappingURL=userApi.js.map