@cardscan.ai/cardscan-client
Version:
Typescript client for the CardScan API
79 lines (78 loc) • 2.86 kB
JavaScript
"use strict";
/* tslint:disable */
/* eslint-disable */
/**
* CardScan API
* The official documentation for the CardScan API Clients.
*
* The version of the OpenAPI document: 1.0.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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Configuration = void 0;
const loglevel_1 = __importDefault(require("loglevel"));
class Configuration {
constructor(param) {
/**
* A websocket connection will be created on class instantiation if this param is true
* */
this.preInitializeWebsocket = false;
this.apiKey = param.apiKey;
this.username = param.username;
this.password = param.password;
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
this.environment = param.environment;
this.logging = param.logging;
this.preInitializeWebsocket = param.preInitializeWebsocket;
this.nameCase = param.nameCase;
if (!this.basePath) {
if (this.environment === "sandbox") {
this.basePath = "https://sandbox.cardscan.ai/v1";
}
else {
this.basePath = "https://api.cardscan.ai/v1";
}
}
if (param.websocketUrl) {
this.websocketUrl = param.websocketUrl;
}
else if (this.environment === "sandbox")
this.websocketUrl = "wss://sandbox-ws.cardscan.ai";
else {
this.websocketUrl = "wss://ws.cardscan.ai";
}
this.logger = loglevel_1.default;
this.logger.setLevel(this.logging || "silent");
}
log(msg, level) {
if (this.logging && this.logging !== 'silent') {
this.logger[level](`[CardScan-client] ${msg}`);
}
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
}
exports.Configuration = Configuration;