UNPKG

@adyen/api-library

Version:

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

111 lines 5.11 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ManagementWebhooksHandler = void 0; const __1 = require(".."); /** * Handler for processing ManagementWebhooks. * * This class provides functionality to deserialize the payload of ManagementWebhooks events. */ class ManagementWebhooksHandler { constructor(jsonPayload) { this.payload = JSON.parse(jsonPayload); } /** * This method checks the type of the webhook payload and returns the appropriate deserialized object. * * @returns A deserialized object of type GenericWebhook. * @throws Error if the type is not recognized. */ getGenericWebhook() { const type = this.payload["type"]; if (Object.values(__1.managementWebhooks.MerchantCreatedNotificationRequest.TypeEnum).includes(type)) { return this.getMerchantCreatedNotificationRequest(); } if (Object.values(__1.managementWebhooks.MerchantUpdatedNotificationRequest.TypeEnum).includes(type)) { return this.getMerchantUpdatedNotificationRequest(); } if (Object.values(__1.managementWebhooks.PaymentMethodCreatedNotificationRequest.TypeEnum).includes(type)) { return this.getPaymentMethodCreatedNotificationRequest(); } if (Object.values(__1.managementWebhooks.PaymentMethodRequestRemovedNotificationRequest.TypeEnum).includes(type)) { return this.getPaymentMethodRequestRemovedNotificationRequest(); } if (Object.values(__1.managementWebhooks.PaymentMethodScheduledForRemovalNotificationRequest.TypeEnum).includes(type)) { return this.getPaymentMethodScheduledForRemovalNotificationRequest(); } if (Object.values(__1.managementWebhooks.TerminalBoardingNotificationRequest.TypeEnum).includes(type)) { return this.getTerminalBoardingNotificationRequest(); } if (Object.values(__1.managementWebhooks.TerminalSettingsNotificationRequest.TypeEnum).includes(type)) { return this.getTerminalSettingsNotificationRequest(); } throw new Error("Could not parse the json payload: " + this.payload); } /** * Deserialize the webhook payload into a MerchantCreatedNotificationRequest * * @returns Deserialized MerchantCreatedNotificationRequest object. */ getMerchantCreatedNotificationRequest() { return __1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "MerchantCreatedNotificationRequest"); } /** * Deserialize the webhook payload into a MerchantUpdatedNotificationRequest * * @returns Deserialized MerchantUpdatedNotificationRequest object. */ getMerchantUpdatedNotificationRequest() { return __1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "MerchantUpdatedNotificationRequest"); } /** * Deserialize the webhook payload into a PaymentMethodCreatedNotificationRequest * * @returns Deserialized PaymentMethodCreatedNotificationRequest object. */ getPaymentMethodCreatedNotificationRequest() { return __1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentMethodCreatedNotificationRequest"); } /** * Deserialize the webhook payload into a PaymentMethodRequestRemovedNotificationRequest * * @returns Deserialized PaymentMethodRequestRemovedNotificationRequest object. */ getPaymentMethodRequestRemovedNotificationRequest() { return __1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentMethodRequestRemovedNotificationRequest"); } /** * Deserialize the webhook payload into a PaymentMethodScheduledForRemovalNotificationRequest * * @returns Deserialized PaymentMethodScheduledForRemovalNotificationRequest object. */ getPaymentMethodScheduledForRemovalNotificationRequest() { return __1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentMethodScheduledForRemovalNotificationRequest"); } /** * Deserialize the webhook payload into a TerminalBoardingNotificationRequest * * @returns Deserialized TerminalBoardingNotificationRequest object. */ getTerminalBoardingNotificationRequest() { return __1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "TerminalBoardingNotificationRequest"); } /** * Deserialize the webhook payload into a TerminalSettingsNotificationRequest * * @returns Deserialized TerminalSettingsNotificationRequest object. */ getTerminalSettingsNotificationRequest() { return __1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "TerminalSettingsNotificationRequest"); } } exports.ManagementWebhooksHandler = ManagementWebhooksHandler; //# sourceMappingURL=managementWebhooksHandler.js.map