UNPKG

@adyen/api-library

Version:

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

97 lines 4.87 kB
"use strict"; /* * The version of the OpenAPI document: v2 * * * 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.DirectDebitMandatesApi = 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/balancePlatform/objectSerializer"); /** * API handler for DirectDebitMandatesApi */ class DirectDebitMandatesApi extends service_1.default { constructor(client) { super(client); this.API_BASEPATH = "https://balanceplatform-api-test.adyen.com/bcl/v2"; this.baseUrl = this.createBaseUrl(this.API_BASEPATH); } /** * @summary Cancel a mandate * @param mandateId {@link string } The unique identifier of the mandate. * @param requestOptions {@link IRequest.Options } * @return {@link void } */ async cancelMandate(mandateId, requestOptions) { const endpoint = `${this.baseUrl}/mandates/{mandateId}/cancel` .replace("{" + "mandateId" + "}", encodeURIComponent(String(mandateId))); const resource = new resource_1.default(this, endpoint); await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "POST" }); } /** * @summary Get a list of mandates * @param requestOptions {@link IRequest.Options } * @param balanceAccountId {@link string } The unique identifier of the balance account linked to the payment instrument. * @param paymentInstrumentId {@link string } The unique identifier of the payment instrument linked to the mandate. * @param cursor {@link string } The pagination cursor returned in a previous GET `/mandates` request. * @return {@link ListMandatesResponse } */ async getListOfMandates(balanceAccountId, paymentInstrumentId, cursor, requestOptions) { var _a; const endpoint = `${this.baseUrl}/mandates`; const resource = new resource_1.default(this, endpoint); const hasDefinedQueryParams = (_a = balanceAccountId !== null && balanceAccountId !== void 0 ? balanceAccountId : paymentInstrumentId) !== null && _a !== void 0 ? _a : cursor; if (hasDefinedQueryParams) { if (!requestOptions) requestOptions = {}; if (!requestOptions.params) requestOptions.params = {}; if (balanceAccountId) requestOptions.params["balanceAccountId"] = balanceAccountId; if (paymentInstrumentId) requestOptions.params["paymentInstrumentId"] = paymentInstrumentId; if (cursor) requestOptions.params["cursor"] = cursor; } const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "ListMandatesResponse"); } /** * @summary Get a specific mandate * @param mandateId {@link string } The unique identifier of the mandate. * @param requestOptions {@link IRequest.Options } * @return {@link Mandate } */ async getMandateById(mandateId, requestOptions) { const endpoint = `${this.baseUrl}/mandates/{mandateId}` .replace("{" + "mandateId" + "}", encodeURIComponent(String(mandateId))); 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, "Mandate"); } /** * @summary Amend a mandate * @param mandateId {@link string } The unique identifier of the mandate. * @param mandateUpdate {@link MandateUpdate } * @param requestOptions {@link IRequest.Options } * @return {@link void } */ async updateMandate(mandateId, mandateUpdate, requestOptions) { const endpoint = `${this.baseUrl}/mandates/{mandateId}` .replace("{" + "mandateId" + "}", encodeURIComponent(String(mandateId))); const resource = new resource_1.default(this, endpoint); const request = objectSerializer_1.ObjectSerializer.serialize(mandateUpdate, "MandateUpdate"); await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "PATCH" }); } } exports.DirectDebitMandatesApi = DirectDebitMandatesApi; //# sourceMappingURL=directDebitMandatesApi.js.map