UNPKG

@adyen/api-library

Version:

The Adyen API Library for NodeJS enables you to work with Adyen APIs.

120 lines 6.49 kB
"use strict"; /* * ###### * ###### * ############ ####( ###### #####. ###### ############ ############ * ############# #####( ###### #####. ###### ############# ############# * ###### #####( ###### #####. ###### ##### ###### ##### ###### * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### * ###### ###### #####( ###### #####. ###### ##### ##### ###### * ############# ############# ############# ############# ##### ###### * ############ ############ ############# ############ ##### ###### * ###### * ############# * ############ * Adyen NodeJS API Library * Copyright (c) 2026 Adyen B.V. * This file is open source and available under the MIT license. * See the LICENSE file for more info. */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CloudDeviceApi = void 0; const getJsonResponse_1 = __importDefault(require("../../helpers/getJsonResponse")); const service_1 = __importDefault(require("../../service")); const resource_1 = __importDefault(require("../resource")); const models_1 = require("../../typings/clouddevice/models"); /** * API handler for CloudDeviceApi */ class CloudDeviceApi extends service_1.default { constructor(client) { super(client); this.API_BASEPATH = "https://device-api-test.adyen.com/v1"; this.baseUrl = this.createBaseUrl(this.API_BASEPATH); } /** * @summary Send a Terminal API request and receive a synchronous response * @param merchantAccount {@link string } The unique identifier of the merchant account. (required) * @param deviceId {@link string } The unique identifier of the payment device. Must match POIID in the MessageHeader. (required) * @param cloudDeviceApiRequest {@link CloudDeviceApiRequest } * @param requestOptions {@link IRequest.Options } * @return {@link CloudDeviceApiResponse } */ async sync(merchantAccount, deviceId, cloudDeviceApiRequest, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantAccount}/devices/{deviceId}/sync` .replace("{" + "merchantAccount" + "}", encodeURIComponent(String(merchantAccount))) .replace("{" + "deviceId" + "}", encodeURIComponent(String(deviceId))); const resource = new resource_1.default(this, endpoint); const response = await (0, getJsonResponse_1.default)(resource, cloudDeviceApiRequest, { ...requestOptions, method: "POST" }); return response; } /** * @summary Send a Terminal API request and receive an asynchronous response * @param merchantAccount {@link string } The unique identifier of the merchant account. (required) * @param deviceId {@link string } The unique identifier of the payment device. Must match POIID in the MessageHeader. (required) * @param cloudDeviceApiRequest {@link CloudDeviceApiRequest } * @param requestOptions {@link IRequest.Options } * @return {@link CloudDeviceApiAsyncResponse } */ async async(merchantAccount, deviceId, cloudDeviceApiRequest, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantAccount}/devices/{deviceId}/async` .replace("{" + "merchantAccount" + "}", encodeURIComponent(String(merchantAccount))) .replace("{" + "deviceId" + "}", encodeURIComponent(String(deviceId))); const resource = new resource_1.default(this, endpoint); const response = await (0, getJsonResponse_1.default)(resource, cloudDeviceApiRequest, { ...requestOptions, method: "POST" }); const result = new models_1.CloudDeviceApiAsyncResponse(); if (typeof response === "string" && response.toLowerCase().trim() === "ok") { // successful response result.Result = response.trim(); } else { // error returned by the terminal const parsed = response; result.SaleToPOIRequest = parsed.SaleToPOIRequest; } return result; } /** * @summary Get a list of connected devices * @param merchantAccount {@link string } The unique identifier of the merchant account. (required) * @param store {@link string } The store ID of the store belonging to the merchant account specified in the path. (optional) * @param requestOptions {@link IRequest.Options } * @return {@link ConnectedDevicesResponse } */ async getConnectedDevices(merchantAccount, store, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantAccount}/connectedDevices` .replace("{" + "merchantAccount" + "}", encodeURIComponent(String(merchantAccount))); const resource = new resource_1.default(this, endpoint); const hasDefinedQueryParams = store; if (hasDefinedQueryParams) { if (!requestOptions) requestOptions = {}; if (!requestOptions.params) requestOptions.params = {}; if (store) requestOptions.params["store"] = store; } const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" }); return response; } /** * @summary Get the connection status of a device * @param merchantAccount {@link string } The unique identifier of the merchant account. (required) * @param deviceId {@link string } The unique identifier of the device. (required) * @param requestOptions {@link IRequest.Options } * @return {@link DeviceStatusResponse } */ async getDeviceStatus(merchantAccount, deviceId, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantAccount}/devices/{deviceId}/status` .replace("{" + "merchantAccount" + "}", encodeURIComponent(String(merchantAccount))) .replace("{" + "deviceId" + "}", encodeURIComponent(String(deviceId))); const resource = new resource_1.default(this, endpoint); const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" }); return response; } } exports.CloudDeviceApi = CloudDeviceApi; //# sourceMappingURL=cloudDeviceApi.js.map