@adyen/api-library
Version:
The Adyen API Library for NodeJS enables you to work with Adyen APIs.
93 lines • 4.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TERMINAL_API_ENDPOINTS_MAP = exports.RegionEnum = exports.EnvironmentEnum = exports.TERMINAL_API_ENDPOINT_TEST = void 0;
// Test endpoint for Terminal API
exports.TERMINAL_API_ENDPOINT_TEST = "https://terminal-api-test.adyen.com";
// Live endpoints for Terminal API
const TERMINAL_API_ENDPOINT_LIVE = "https://terminal-api-live.adyen.com";
const TERMINAL_API_ENDPOINT_AU_LIVE = "https://terminal-api-live-au.adyen.com";
const TERMINAL_API_ENDPOINT_US_LIVE = "https://terminal-api-live-us.adyen.com";
const TERMINAL_API_ENDPOINT_APSE_LIVE = "https://terminal-api-live-apse.adyen.com";
/**
* Supported environments for the Adyen APIs.
*/
var EnvironmentEnum;
(function (EnvironmentEnum) {
EnvironmentEnum["LIVE"] = "LIVE";
EnvironmentEnum["TEST"] = "TEST";
})(EnvironmentEnum = exports.EnvironmentEnum || (exports.EnvironmentEnum = {}));
/**
* Supported Regions for Terminal API integration.
*/
var RegionEnum;
(function (RegionEnum) {
RegionEnum["EU"] = "EU";
RegionEnum["AU"] = "AU";
RegionEnum["US"] = "US";
RegionEnum["APSE"] = "APSE";
})(RegionEnum = exports.RegionEnum || (exports.RegionEnum = {}));
// Terminal API Endpoints Map
exports.TERMINAL_API_ENDPOINTS_MAP = {
[RegionEnum.EU]: TERMINAL_API_ENDPOINT_LIVE,
[RegionEnum.AU]: TERMINAL_API_ENDPOINT_AU_LIVE,
[RegionEnum.US]: TERMINAL_API_ENDPOINT_US_LIVE,
[RegionEnum.APSE]: TERMINAL_API_ENDPOINT_APSE_LIVE
};
const DEFAULT_TIMEOUT = 30000; // Default timeout value (30 sec)
class Config {
constructor(options = {}) {
var _a, _b;
if (options.username)
this.username = options.username;
if (options.password)
this.password = options.password;
if (options.environment)
this.environment = options.environment;
if (options.marketPayEndpoint)
this.marketPayEndpoint = options.marketPayEndpoint;
if (options.applicationName)
this.applicationName = options.applicationName;
if (options.apiKey)
this.apiKey = options.apiKey;
// Set the timeout to DEFAULT_TIMEOUT if not provided
this.connectionTimeoutMillis = (_a = options.connectionTimeoutMillis) !== null && _a !== void 0 ? _a : DEFAULT_TIMEOUT;
if (options.certificatePath)
this.certificatePath = options.certificatePath;
if (options.terminalApiCloudEndpoint)
this.terminalApiCloudEndpoint = options.terminalApiCloudEndpoint;
if (options.terminalApiLocalEndpoint)
this.terminalApiLocalEndpoint = options.terminalApiLocalEndpoint;
if (options.liveEndpointUrlPrefix)
this.liveEndpointUrlPrefix = options.liveEndpointUrlPrefix;
if (options.region)
this.region = options.region;
this.enable308Redirect = (_b = options.enable308Redirect) !== null && _b !== void 0 ? _b : true; // enabled by default
}
/**
* Checks if the provided environment is valid.
* @param environment - The environment to validate.
* @returns true if the environment exists in EnvironmentEnum, false otherwise.
*/
static isEnvironmentValid(environment) {
return Object.values(EnvironmentEnum).includes(environment);
}
/**
* Checks if the provided region is a valid supported.
* @param region - The region to validate.
* @returns true if the region exists in RegionEnum, false otherwise.
*/
static isRegionValid(region) {
return Object.values(RegionEnum).includes(region);
}
/**
* Returns the Terminal API endpoint for the given region.
* If the region is not valid, returns the EU endpoint.
* @param region - The region to get the endpoint for.
* @returns The Terminal API endpoint URL.
*/
static getTerminalApiEndpoint(region) {
return exports.TERMINAL_API_ENDPOINTS_MAP[region] || exports.TERMINAL_API_ENDPOINTS_MAP[RegionEnum.EU];
}
}
exports.default = Config;
//# sourceMappingURL=config.js.map