UNPKG

@adyen/api-library

Version:

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

149 lines 8.68 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.WebhooksCompanyLevelApi = 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 WebhooksCompanyLevelApi */ class WebhooksCompanyLevelApi 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 companyId {@link string } The unique identifier of the company account. * @param webhookId {@link string } Unique identifier of the webhook configuration. * @param requestOptions {@link IRequest.Options } * @return {@link GenerateHmacKeyResponse } */ async generateHmacKey(companyId, webhookId, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/webhooks/{webhookId}/generateHmac` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))) .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 companyId {@link string } Unique identifier of the [company account](https://docs.adyen.com/account/account-structure#company-account). * @param webhookId {@link string } Unique identifier of the webhook configuration. * @param requestOptions {@link IRequest.Options } * @return {@link Webhook } */ async getWebhook(companyId, webhookId, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/webhooks/{webhookId}` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))) .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 companyId {@link string } Unique identifier of the [company account](https://docs.adyen.com/account/account-structure#company-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(companyId, pageNumber, pageSize, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/webhooks` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))); 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 companyId {@link string } The unique identifier of the company account. * @param webhookId {@link string } Unique identifier of the webhook configuration. * @param requestOptions {@link IRequest.Options } * @return {@link void } */ async removeWebhook(companyId, webhookId, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/webhooks/{webhookId}` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))) .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 companyId {@link string } Unique identifier of the [company account](https://docs.adyen.com/account/account-structure#company-account). * @param createCompanyWebhookRequest {@link CreateCompanyWebhookRequest } * @param requestOptions {@link IRequest.Options } * @return {@link Webhook } */ async setUpWebhook(companyId, createCompanyWebhookRequest, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/webhooks` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))); const resource = new resource_1.default(this, endpoint); const request = objectSerializer_1.ObjectSerializer.serialize(createCompanyWebhookRequest, "CreateCompanyWebhookRequest"); const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "POST" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "Webhook"); } /** * @summary Test a webhook * @param companyId {@link string } The unique identifier of the company account. * @param webhookId {@link string } Unique identifier of the webhook configuration. * @param testCompanyWebhookRequest {@link TestCompanyWebhookRequest } * @param requestOptions {@link IRequest.Options } * @return {@link TestWebhookResponse } */ async testWebhook(companyId, webhookId, testCompanyWebhookRequest, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/webhooks/{webhookId}/test` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))) .replace("{" + "webhookId" + "}", encodeURIComponent(String(webhookId))); const resource = new resource_1.default(this, endpoint); const request = objectSerializer_1.ObjectSerializer.serialize(testCompanyWebhookRequest, "TestCompanyWebhookRequest"); const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "POST" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "TestWebhookResponse"); } /** * @summary Update a webhook * @param companyId {@link string } The unique identifier of the company account. * @param webhookId {@link string } Unique identifier of the webhook configuration. * @param updateCompanyWebhookRequest {@link UpdateCompanyWebhookRequest } * @param requestOptions {@link IRequest.Options } * @return {@link Webhook } */ async updateWebhook(companyId, webhookId, updateCompanyWebhookRequest, requestOptions) { const endpoint = `${this.baseUrl}/companies/{companyId}/webhooks/{webhookId}` .replace("{" + "companyId" + "}", encodeURIComponent(String(companyId))) .replace("{" + "webhookId" + "}", encodeURIComponent(String(webhookId))); const resource = new resource_1.default(this, endpoint); const request = objectSerializer_1.ObjectSerializer.serialize(updateCompanyWebhookRequest, "UpdateCompanyWebhookRequest"); const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "PATCH" }); return objectSerializer_1.ObjectSerializer.deserialize(response, "Webhook"); } } exports.WebhooksCompanyLevelApi = WebhooksCompanyLevelApi; //# sourceMappingURL=webhooksCompanyLevelApi.js.map