UNPKG

@adyen/api-library

Version:

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

149 lines 8.46 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.WebhooksMerchantLevelApi = 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 WebhooksMerchantLevelApi */ class WebhooksMerchantLevelApi 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 Generate an HMAC key * @param merchantId {@link string } The unique identifier of the merchant account. * @param webhookId {@link string } * @param requestOptions {@link IRequest.Options } * @return {@link GenerateHmacKeyResponse } */ async generateHmacKey(merchantId, webhookId, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantId}/webhooks/{webhookId}/generateHmac` .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))) .replace("{" + "webhookId" + "}", encodeURIComponent(String(webhookId))); 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, "GenerateHmacKeyResponse"); } /** * @summary Get a webhook * @param merchantId {@link string } The unique identifier of the merchant account. * @param webhookId {@link string } Unique identifier of the webhook configuration. * @param requestOptions {@link IRequest.Options } * @return {@link Webhook } */ async getWebhook(merchantId, webhookId, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantId}/webhooks/{webhookId}` .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))) .replace("{" + "webhookId" + "}", encodeURIComponent(String(webhookId))); 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, "Webhook"); } /** * @summary List all webhooks * @param merchantId {@link string } The unique identifier of the merchant account. * @param requestOptions {@link IRequest.Options } * @param pageNumber {@link number } The number of the page to fetch. * @param pageSize {@link number } The number of items to have on a page, maximum 100. The default is 10 items on a page. * @return {@link ListWebhooksResponse } */ async listAllWebhooks(merchantId, pageNumber, pageSize, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantId}/webhooks` .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))); const resource = new resource_1.default(this, endpoint); const hasDefinedQueryParams = pageNumber !== null && pageNumber !== void 0 ? pageNumber : pageSize; if (hasDefinedQueryParams) { if (!requestOptions) requestOptions = {}; if (!requestOptions.params) requestOptions.params = {}; if (pageNumber) requestOptions.params["pageNumber"] = pageNumber; if (pageSize) requestOptions.params["pageSize"] = pageSize; } const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "ListWebhooksResponse"); } /** * @summary Remove a webhook * @param merchantId {@link string } The unique identifier of the merchant account. * @param webhookId {@link string } Unique identifier of the webhook configuration. * @param requestOptions {@link IRequest.Options } * @return {@link void } */ async removeWebhook(merchantId, webhookId, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantId}/webhooks/{webhookId}` .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))) .replace("{" + "webhookId" + "}", encodeURIComponent(String(webhookId))); const resource = new resource_1.default(this, endpoint); await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "DELETE" }); } /** * @summary Set up a webhook * @param merchantId {@link string } The unique identifier of the merchant account. * @param createMerchantWebhookRequest {@link CreateMerchantWebhookRequest } * @param requestOptions {@link IRequest.Options } * @return {@link Webhook } */ async setUpWebhook(merchantId, createMerchantWebhookRequest, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantId}/webhooks` .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))); const resource = new resource_1.default(this, endpoint); const request = objectSerializer_1.ObjectSerializer.serialize(createMerchantWebhookRequest, "CreateMerchantWebhookRequest"); const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "POST" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "Webhook"); } /** * @summary Test a webhook * @param merchantId {@link string } The unique identifier of the merchant account. * @param webhookId {@link string } Unique identifier of the webhook configuration. * @param testWebhookRequest {@link TestWebhookRequest } * @param requestOptions {@link IRequest.Options } * @return {@link TestWebhookResponse } */ async testWebhook(merchantId, webhookId, testWebhookRequest, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantId}/webhooks/{webhookId}/test` .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))) .replace("{" + "webhookId" + "}", encodeURIComponent(String(webhookId))); const resource = new resource_1.default(this, endpoint); const request = objectSerializer_1.ObjectSerializer.serialize(testWebhookRequest, "TestWebhookRequest"); const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "POST" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "TestWebhookResponse"); } /** * @summary Update a webhook * @param merchantId {@link string } The unique identifier of the merchant account. * @param webhookId {@link string } Unique identifier of the webhook configuration. * @param updateMerchantWebhookRequest {@link UpdateMerchantWebhookRequest } * @param requestOptions {@link IRequest.Options } * @return {@link Webhook } */ async updateWebhook(merchantId, webhookId, updateMerchantWebhookRequest, requestOptions) { const endpoint = `${this.baseUrl}/merchants/{merchantId}/webhooks/{webhookId}` .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))) .replace("{" + "webhookId" + "}", encodeURIComponent(String(webhookId))); const resource = new resource_1.default(this, endpoint); const request = objectSerializer_1.ObjectSerializer.serialize(updateMerchantWebhookRequest, "UpdateMerchantWebhookRequest"); const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "PATCH" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "Webhook"); } } exports.WebhooksMerchantLevelApi = WebhooksMerchantLevelApi; //# sourceMappingURL=webhooksMerchantLevelApi.js.map