UNPKG

digitalfemsa

Version:
184 lines (183 loc) 6.32 kB
/* tslint:disable */ /* eslint-disable */ /** * Femsa API * Femsa sdk * * The version of the OpenAPI document: 2.1.0 * Contact: engineering@femsa.com * * 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()); }); }; import { RequiredError } from "./base"; import { arch, platform, release } from 'os'; import * as fs from 'fs'; import * as https from 'https'; import * as path from 'path'; /** * * @export */ export const DUMMY_BASE_URL = 'https://example.com'; /** * * @export */ export const digitalfemsaHeaders = { bindings_version: ['DigitalFemsa::', "1.0.0"].join(''), lang: 'node', lang_version: process.version, publisher: 'digitalfemsa', uname: [arch, platform, release].join(' ') }; /** * * @throws {RequiredError} * @export */ export const assertParamExists = function (functionName, paramName, paramValue) { if (paramValue === null || paramValue === undefined) { throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); } }; /** * * @export */ export const 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 */ export const setBasicAuthToObject = function (object, configuration) { if (configuration && (configuration.username || configuration.password)) { object["auth"] = { username: configuration.username, password: configuration.password }; } }; /** * * @export */ export const 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; } setCommonHeaders(object); }); }; /** * * @export */ export const 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; } }); }; function setFlattenedQueryParams(urlSearchParams, parameter, key = "") { if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); } else { Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)); } } else { if (urlSearchParams.has(key)) { urlSearchParams.append(key, parameter); } else { urlSearchParams.set(key, parameter); } } } /** * * @export */ export const setSearchParams = function (url, ...objects) { const searchParams = new URLSearchParams(url.search); setFlattenedQueryParams(searchParams, objects); url.search = searchParams.toString(); }; /** * * @export */ export const 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 */ export const toPathString = function (url) { return url.pathname + url.search + url.hash; }; /** * * @export */ export const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) { return (axios = globalAxios, basePath = BASE_PATH) => { var _a; if (!axiosArgs.options.httpsAgent) { const certPath = path.join(__dirname, '/cert/ca_bundle.crt'); axiosArgs.options.httpsAgent = new https.Agent({ ca: fs.readFileSync(certPath), rejectUnauthorized: false }); } const axiosRequestArgs = Object.assign(Object.assign({}, axiosArgs.options), { url: (axios.defaults.baseURL ? '' : (_a = configuration === null || configuration === void 0 ? void 0 : configuration.basePath) !== null && _a !== void 0 ? _a : basePath) + axiosArgs.url }); return axios.request(axiosRequestArgs); }; }; /** * * @export */ export const setCommonHeaders = function (object) { return __awaiter(this, void 0, void 0, function* () { object["User-Agent"] = "App/v2 NodeBindings/" + "1.0.0"; object["X-App-Client-User-Agent"] = JSON.stringify(digitalfemsaHeaders); object["Accept"] = "application/vnd.app-v2.1.0+json"; }); };