UNPKG

@devmehq/sdk-js

Version:

DEV.ME SDK for JavaScript & TypeScript for Server & Browser, Compatible with Node.js & React & Vue.js & Angular

107 lines (105 loc) 6.45 kB
"use strict"; /** * DEV.ME API Documentation * **DEV.ME API Platform** - 19 powerful services across 7 categories **Validation & Verification:** [Email Validation API](https://dev.me/products/email) • [Phone Validation API](https://dev.me/products/phone) • [IP Geolocation API](https://dev.me/products/ip) **Financial & Currency:** [Currency Exchange API](https://dev.me/products/currency) • [Currency List API](https://dev.me/products/currency-list) **Domain & Security:** [Domain WHOIS API](https://dev.me/products/domain-whois) • [DNS Lookup API](https://dev.me/products/dns-lookup) • [Domain Tools API](https://dev.me/products/domain-tools) **Content & Media:** [QR Code Generator API](https://dev.me/products/qr-code-generator) • [Image Placeholders API](https://dev.me/products/image-placeholder) • [Image Optimization API](https://dev.me/products/image-optimizer) **URL & Web:** [URL Shortening API](https://dev.me/products/short-url) • [Web Scraping API](https://dev.me/products/url-scrapper) • [URL Metadata API](https://dev.me/products/url-metadata) • [One-Time URL API](https://dev.me/products/onetime-url) **Global Data:** [Country Data API](https://dev.me/products/country) • [City Data API](https://dev.me/products/city) **Management:** [API Key Management](https://dev.me/dashboard) • [API Usage Analytics](https://dev.me/dashboard) **Quick Start:** Use API key `demo-key` for testing • Visit [dev.me](https://dev.me) for complete documentation **Authentication:** Header `x-api-key: YOUR_API_KEY` or Query Parameter `?x-api-key=YOUR_API_KEY` **[Rate Limits](https://dev.me/pricing):** Free (500/mo) • Essential (15K/mo) • Standard (60K/mo) • Professional (1M/mo) • Enterprise (Unlimited) **Support:** support@dev.me • [Documentation](https://dev.me/documentation) * * The version of the OpenAPI document: 1.0.0 * Contact: support@dev.me */ Object.defineProperty(exports, "__esModule", { value: true }); exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0; const base_1 = require("./base"); exports.DUMMY_BASE_URL = 'https://example.com'; /** * * @throws {RequiredError} */ const assertParamExists = (functionName, paramName, paramValue) => { if (paramValue === null || paramValue === undefined) { throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); } }; exports.assertParamExists = assertParamExists; const setApiKeyToObject = async (object, keyParamName, configuration) => { if (configuration === null || configuration === void 0 ? void 0 : configuration.apiKey) { object[keyParamName] = typeof configuration.apiKey === 'function' ? await configuration.apiKey(keyParamName) : await configuration.apiKey; } }; exports.setApiKeyToObject = setApiKeyToObject; const setBasicAuthToObject = (object, configuration) => { if (configuration && (configuration.username || configuration.password)) { object.auth = { username: configuration.username, password: configuration.password }; } }; exports.setBasicAuthToObject = setBasicAuthToObject; const setBearerAuthToObject = async (object, configuration) => { if (configuration === null || configuration === void 0 ? void 0 : configuration.accessToken) { const accessToken = typeof configuration.accessToken === 'function' ? await configuration.accessToken() : await configuration.accessToken; object.Authorization = `Bearer ${accessToken}`; } }; exports.setBearerAuthToObject = setBearerAuthToObject; const setOAuthToObject = async (object, name, scopes, configuration) => { if (configuration === null || configuration === void 0 ? void 0 : configuration.accessToken) { const localVarAccessTokenValue = typeof configuration.accessToken === 'function' ? await configuration.accessToken(name, scopes) : await configuration.accessToken; object.Authorization = `Bearer ${localVarAccessTokenValue}`; } }; exports.setOAuthToObject = setOAuthToObject; 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); } } } const setSearchParams = (url, ...objects) => { const searchParams = new URLSearchParams(url.search); setFlattenedQueryParams(searchParams, objects); url.search = searchParams.toString(); }; exports.setSearchParams = setSearchParams; const serializeDataIfNeeded = (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 || ''; }; exports.serializeDataIfNeeded = serializeDataIfNeeded; const toPathString = (url) => url.pathname + url.search + url.hash; exports.toPathString = toPathString; const createRequestFunction = (axiosArgs, globalAxios, BASE_PATH, configuration) => (axios = globalAxios, basePath = BASE_PATH) => { var _a; const axiosRequestArgs = { ...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); }; exports.createRequestFunction = createRequestFunction;