UNPKG

@adyen/api-library

Version:

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

239 lines 13.6 kB
"use strict"; /* * The version of the OpenAPI document: v3 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit this class manually. */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TerminalOrdersCompanyLevelApi = void 0; const getJsonResponse_1 = __importDefault(require("../../helpers/getJsonResponse")); const service_1 = __importDefault(require("../../service")); const resource_1 = __importDefault(require("../resource")); const objectSerializer_1 = require("../../typings/management/objectSerializer"); /** * API handler for TerminalOrdersCompanyLevelApi */ class TerminalOrdersCompanyLevelApi extends service_1.default { constructor(client) { super(client); this.API_BASEPATH = "https://management-test.adyen.com/v3"; this.baseUrl = this.createBaseUrl(this.API_BASEPATH); } /** * @summary Cancel an order * @param companyId {@link string } The unique identifier of the company account. * @param orderId {@link string } The unique identifier of the order. * @param requestOptions {@link IRequest.Options } * @return {@link TerminalOrder } */ async cancelOrder(companyId, orderId, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/terminalOrders/{orderId}/cancel` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))) .replace("{" + "orderId" + "}", encodeURIComponent(String(orderId))); const resource = new resource_1.default(this, endpoint); const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "POST" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "TerminalOrder"); } /** * @summary Create an order * @param companyId {@link string } The unique identifier of the company account. * @param terminalOrderRequest {@link TerminalOrderRequest } * @param requestOptions {@link IRequest.Options } * @return {@link TerminalOrder } */ async createOrder(companyId, terminalOrderRequest, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/terminalOrders` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))); const resource = new resource_1.default(this, endpoint); const request = objectSerializer_1.ObjectSerializer.serialize(terminalOrderRequest, "TerminalOrderRequest"); const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "POST" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "TerminalOrder"); } /** * @summary Create a shipping location * @param companyId {@link string } The unique identifier of the company account. * @param shippingLocation {@link ShippingLocation } * @param requestOptions {@link IRequest.Options } * @return {@link ShippingLocation } */ async createShippingLocation(companyId, shippingLocation, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/shippingLocations` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))); const resource = new resource_1.default(this, endpoint); const request = objectSerializer_1.ObjectSerializer.serialize(shippingLocation, "ShippingLocation"); const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "POST" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "ShippingLocation"); } /** * @summary Get an order * @param companyId {@link string } The unique identifier of the company account. * @param orderId {@link string } The unique identifier of the order. * @param requestOptions {@link IRequest.Options } * @return {@link TerminalOrder } */ async getOrder(companyId, orderId, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/terminalOrders/{orderId}` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))) .replace("{" + "orderId" + "}", encodeURIComponent(String(orderId))); const resource = new resource_1.default(this, endpoint); const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "TerminalOrder"); } /** * @summary Get a list of billing entities * @param companyId {@link string } The unique identifier of the company account. * @param requestOptions {@link IRequest.Options } * @param name {@link string } The name of the billing entity. * @return {@link BillingEntitiesResponse } */ async listBillingEntities(companyId, name, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/billingEntities` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))); const resource = new resource_1.default(this, endpoint); const hasDefinedQueryParams = name; if (hasDefinedQueryParams) { if (!requestOptions) requestOptions = {}; if (!requestOptions.params) requestOptions.params = {}; if (name) requestOptions.params["name"] = name; } const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "BillingEntitiesResponse"); } /** * @summary Get a list of orders * @param companyId {@link string } The unique identifier of the company account. * @param requestOptions {@link IRequest.Options } * @param customerOrderReference {@link string } Your purchase order number. * @param status {@link string } The order status. Possible values (not case-sensitive): Placed, Confirmed, Cancelled, Shipped, Delivered. * @param offset {@link number } The number of orders to skip. * @param limit {@link number } The number of orders to return. * @return {@link TerminalOrdersResponse } */ async listOrders(companyId, customerOrderReference, status, offset, limit, requestOptions) { var _a, _b; const endpoint = `${this.baseUrl}/companies/{companyId}/terminalOrders` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))); const resource = new resource_1.default(this, endpoint); const hasDefinedQueryParams = (_b = (_a = customerOrderReference !== null && customerOrderReference !== void 0 ? customerOrderReference : status) !== null && _a !== void 0 ? _a : offset) !== null && _b !== void 0 ? _b : limit; if (hasDefinedQueryParams) { if (!requestOptions) requestOptions = {}; if (!requestOptions.params) requestOptions.params = {}; if (customerOrderReference) requestOptions.params["customerOrderReference"] = customerOrderReference; if (status) requestOptions.params["status"] = status; if (offset) requestOptions.params["offset"] = offset; if (limit) requestOptions.params["limit"] = limit; } const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "TerminalOrdersResponse"); } /** * @summary Get a list of shipping locations * @param companyId {@link string } The unique identifier of the company account. * @param requestOptions {@link IRequest.Options } * @param name {@link string } The name of the shipping location. * @param offset {@link number } The number of locations to skip. * @param limit {@link number } The number of locations to return. * @return {@link ShippingLocationsResponse } */ async listShippingLocations(companyId, name, offset, limit, requestOptions) { var _a; const endpoint = `${this.baseUrl}/companies/{companyId}/shippingLocations` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))); const resource = new resource_1.default(this, endpoint); const hasDefinedQueryParams = (_a = name !== null && name !== void 0 ? name : offset) !== null && _a !== void 0 ? _a : limit; if (hasDefinedQueryParams) { if (!requestOptions) requestOptions = {}; if (!requestOptions.params) requestOptions.params = {}; if (name) requestOptions.params["name"] = name; if (offset) requestOptions.params["offset"] = offset; if (limit) requestOptions.params["limit"] = limit; } const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "ShippingLocationsResponse"); } /** * @summary Get a list of terminal models * @param companyId {@link string } The unique identifier of the company account. * @param requestOptions {@link IRequest.Options } * @return {@link TerminalModelsResponse } */ async listTerminalModels(companyId, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/terminalModels` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))); const resource = new resource_1.default(this, endpoint); const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "TerminalModelsResponse"); } /** * @summary Get a list of terminal products * @param companyId {@link string } The unique identifier of the company account. * @param requestOptions {@link IRequest.Options } * @param country {@link string } (Required) The country to return products for, in [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. For example, **US** * @param terminalModelId {@link string } The terminal model to return products for. Use the ID returned in the [GET `/terminalModels`](https://docs.adyen.com/api-explorer/#/ManagementService/latest/get/companies/{companyId}/terminalModels) response. For example, **Verifone.M400** * @param offset {@link number } The number of products to skip. * @param limit {@link number } The number of products to return. * @return {@link TerminalProductsResponse } */ async listTerminalProducts(companyId, country, terminalModelId, offset, limit, requestOptions) { var _a, _b; const endpoint = `${this.baseUrl}/companies/{companyId}/terminalProducts` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))); const resource = new resource_1.default(this, endpoint); const hasDefinedQueryParams = (_b = (_a = country !== null && country !== void 0 ? country : terminalModelId) !== null && _a !== void 0 ? _a : offset) !== null && _b !== void 0 ? _b : limit; if (hasDefinedQueryParams) { if (!requestOptions) requestOptions = {}; if (!requestOptions.params) requestOptions.params = {}; if (country) requestOptions.params["country"] = country; if (terminalModelId) requestOptions.params["terminalModelId"] = terminalModelId; if (offset) requestOptions.params["offset"] = offset; if (limit) requestOptions.params["limit"] = limit; } const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "TerminalProductsResponse"); } /** * @summary Update an order * @param companyId {@link string } The unique identifier of the company account. * @param orderId {@link string } The unique identifier of the order. * @param terminalOrderRequest {@link TerminalOrderRequest } * @param requestOptions {@link IRequest.Options } * @return {@link TerminalOrder } */ async updateOrder(companyId, orderId, terminalOrderRequest, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/terminalOrders/{orderId}` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))) .replace("{" + "orderId" + "}", encodeURIComponent(String(orderId))); const resource = new resource_1.default(this, endpoint); const request = objectSerializer_1.ObjectSerializer.serialize(terminalOrderRequest, "TerminalOrderRequest"); const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "PATCH" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "TerminalOrder"); } } exports.TerminalOrdersCompanyLevelApi = TerminalOrdersCompanyLevelApi; //# sourceMappingURL=terminalOrdersCompanyLevelApi.js.map