@affinidi-tdk/credential-verification-client
Version:
Affinidi TDK typescript client for Affinidi CREDENTIAL VERIFICATION
96 lines (95 loc) • 3.53 kB
JavaScript
/* tslint:disable */
/* eslint-disable */
/**
* VerificationService
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
* Contact: info@affinidi.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import globalAxios, { AxiosError } from 'axios';
import axiosRetry from 'axios-retry';
export class SdkError extends Error {
constructor(originalError = {}) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
const isAxiosError = originalError instanceof AxiosError;
if (!isAxiosError) {
throw originalError;
}
super((_b = (_a = originalError.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message);
this.name = (_d = (_c = originalError.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.name;
this.details = (_f = (_e = originalError.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.details;
this.message = (_h = (_g = originalError.response) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.message;
this.traceId = (_k = (_j = originalError.response) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.traceId;
this.httpStatusCode = (_l = originalError.response) === null || _l === void 0 ? void 0 : _l.status;
}
}
export const BASE_PATH = 'https://apse1.api.affinidi.io/ver'.replace(/\/+$/, '');
const DEFAULT_REQUEST_RETRIES = 3;
/**
*
* @export
*/
export const COLLECTION_FORMATS = {
csv: ',',
ssv: ' ',
tsv: '\t',
pipes: '|',
};
/**
*
* @export
* @class BaseAPI
*/
export class BaseAPI {
constructor(configuration, retryConfig, basePath = BASE_PATH, axios = globalAxios) {
var _a;
this.basePath = basePath;
this.axios = axios;
if (configuration) {
this.configuration = configuration;
this.basePath = (_a = configuration.basePath) !== null && _a !== void 0 ? _a : basePath;
}
this.retryConfig = {
retries: (retryConfig === null || retryConfig === void 0 ? void 0 : retryConfig.retries) >= 0 &&
(retryConfig === null || retryConfig === void 0 ? void 0 : retryConfig.retries) <= DEFAULT_REQUEST_RETRIES
? retryConfig.retries
: DEFAULT_REQUEST_RETRIES,
retryDelay: (retryConfig === null || retryConfig === void 0 ? void 0 : retryConfig.isExponentialDelay)
? axiosRetry.exponentialDelay
: () => {
return 0;
},
retryCondition: (error) => {
if (axiosRetry.isNetworkOrIdempotentRequestError(error) ||
axiosRetry.isNetworkError(error)) {
return true;
}
throw new SdkError(error);
},
};
axiosRetry(globalAxios, this.retryConfig);
}
}
/**
*
* @export
* @class RequiredError
* @extends {Error}
*/
export class RequiredError extends Error {
constructor(field, msg) {
super(msg);
this.field = field;
this.name = 'RequiredError';
}
}
/**
*
* @export
*/
export const operationServerMap = {};