UNPKG

card-management-sdk

Version:

The Shell Card Management API is REST-based and employs OAUTH 2.0,Basic and ApiKey authentication. The API endpoints accept JSON-encoded request bodies, return JSON-encoded responses and use standard HTTP response codes. All resources are located in the S

142 lines 7.29 kB
"use strict"; /** * Shell Card Management APIsLib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Configuration = exports.Environment = void 0; var oAuthToken_js_1 = require("./models/oAuthToken.js"); var schema_js_1 = require("./schema.js"); /** Environments available for API */ var Environment; (function (Environment) { Environment["SIT"] = "SIT"; Environment["Production"] = "Production"; })(Environment || (exports.Environment = Environment = {})); var Configuration; (function (Configuration) { function fromJsonConfig(jsonConfig) { var configurationObject = JSON.parse(jsonConfig); var result = (0, schema_js_1.validateAndMap)(jsonConfig, configurationObject); if (result.errors) { throw new Error('Invalid configuration provided. Please check the following errors:\n' + result.errors.map(function (e) { return e.message; }).join('\n')); } return result.result; } Configuration.fromJsonConfig = fromJsonConfig; function fromEnvironment(envVariables) { var _a, _b; var config = {}; config.timeout = envVariables.TIMEOUT; config.environment = envVariables.ENVIRONMENT; if (envVariables.O_AUTH_CLIENT_ID && envVariables.O_AUTH_CLIENT_SECRET) { config.clientCredentialsAuthCredentials = { oAuthClientId: envVariables.O_AUTH_CLIENT_ID, oAuthClientSecret: envVariables.O_AUTH_CLIENT_SECRET, oAuthToken: envVariables.O_AUTH_TOKEN, oAuthClockSkew: envVariables.O_AUTH_CLOCK_SKEW, }; } config.httpClientOptions = { timeout: envVariables.TIMEOUT, retryConfig: { retryOnTimeout: envVariables.RETRY_ON_TIMEOUT, retryInterval: envVariables.RETRY_INTERVAL, maxNumberOfRetries: envVariables.MAX_NUMBER_OF_RETRIES, maximumRetryWaitTime: envVariables.MAX_RETRY_WAIT_TIME, backoffFactor: envVariables.RETRY_BACKOFF_FACTOR, httpStatusCodesToRetry: (_a = envVariables.HTTP_STATUS_CODES_TO_RETRY) === null || _a === void 0 ? void 0 : _a.split(',').map(function (s) { return s.trim(); }), httpMethodsToRetry: (_b = envVariables.HTTP_METHODS_TO_RETRY) === null || _b === void 0 ? void 0 : _b.split(',').map(function (s) { return s.trim(); }), }, }; if (envVariables.PROXY_ADDRESS) { config.httpClientOptions.proxySettings = { address: envVariables.PROXY_ADDRESS, port: envVariables.PROXY_PORT, }; if (envVariables.PROXY_AUTH_USERNAME && envVariables.PROXY_AUTH_PASSWORD) { config.httpClientOptions.proxySettings.auth = { username: envVariables.PROXY_AUTH_USERNAME, password: envVariables.PROXY_AUTH_PASSWORD, }; } } var result = (0, schema_js_1.validateAndMap)(config, configurationSchema); if (result.errors) { throw new Error('Invalid configuration provided. Please check the following errors:\n' + result.errors.map(function (e) { return e.message; }).join('\n')); } return result.result; } Configuration.fromEnvironment = fromEnvironment; })(Configuration || (exports.Configuration = Configuration = {})); var configurationSchema = (0, schema_js_1.object)({ timeout: ['timeout', (0, schema_js_1.optional)((0, schema_js_1.number)())], environment: ['environment', (0, schema_js_1.optional)((0, schema_js_1.stringEnum)(Environment))], oAuthClientId: ['oAuthClientId', (0, schema_js_1.optional)((0, schema_js_1.string)())], oAuthClientSecret: ['oAuthClientSecret', (0, schema_js_1.optional)((0, schema_js_1.string)())], oAuthToken: ['oAuthToken', (0, schema_js_1.optional)((0, schema_js_1.optional)(oAuthToken_js_1.oAuthTokenSchema))], clientCredentialsAuthCredentials: [ 'clientCredentialsAuthCredentials', (0, schema_js_1.optional)((0, schema_js_1.object)({ oAuthClientId: ['oAuthClientId', (0, schema_js_1.string)()], oAuthClientSecret: ['oAuthClientSecret', (0, schema_js_1.string)()], oAuthClockSkew: ['oAuthClockSkew', (0, schema_js_1.optional)((0, schema_js_1.number)())], })), ], httpClientOptions: [ 'httpClientOptions', (0, schema_js_1.optional)((0, schema_js_1.object)({ timeout: ['timeout', (0, schema_js_1.optional)((0, schema_js_1.number)())], retryConfig: [ 'retryConfig', (0, schema_js_1.optional)((0, schema_js_1.object)({ maxNumberOfRetries: ['maxNumberOfRetries', (0, schema_js_1.optional)((0, schema_js_1.number)())], retryOnTimeout: ['retryOnTimeout', (0, schema_js_1.optional)((0, schema_js_1.boolean)())], retryInterval: ['retryInterval', (0, schema_js_1.optional)((0, schema_js_1.number)())], maximumRetryWaitTime: [ 'maximumRetryWaitTime', (0, schema_js_1.optional)((0, schema_js_1.number)()), ], backoffFactor: ['backoffFactor', (0, schema_js_1.optional)((0, schema_js_1.number)())], httpStatusCodesToRetry: [ 'httpStatusCodesToRetry', (0, schema_js_1.optional)((0, schema_js_1.array)((0, schema_js_1.number)())), ], httpMethodsToRetry: [ 'httpMethodsToRetry', (0, schema_js_1.optional)((0, schema_js_1.array)((0, schema_js_1.anyOf)([ (0, schema_js_1.literal)('GET'), (0, schema_js_1.literal)('DELETE'), (0, schema_js_1.literal)('HEAD'), (0, schema_js_1.literal)('OPTIONS'), (0, schema_js_1.literal)('POST'), (0, schema_js_1.literal)('PUT'), (0, schema_js_1.literal)('PATCH'), (0, schema_js_1.literal)('LINK'), (0, schema_js_1.literal)('UNLINK'), ]))), ], })), ], proxySettings: [ 'proxySettings', (0, schema_js_1.optional)((0, schema_js_1.object)({ address: ['address', (0, schema_js_1.string)()], port: ['port', (0, schema_js_1.optional)((0, schema_js_1.number)())], auth: [ 'auth', (0, schema_js_1.optional)((0, schema_js_1.object)({ username: ['username', (0, schema_js_1.string)()], password: ['password', (0, schema_js_1.string)()], })), ], })), ], })), ], }); //# sourceMappingURL=configuration.js.map