UNPKG

@adyen/api-library

Version:

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

56 lines 2.1 kB
"use strict"; /* * The version of the OpenAPI document: v1 * * * 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.AcsWebhooksHandler = void 0; const __1 = require(".."); /** * Handler for processing AcsWebhooks. * * This class provides functionality to deserialize the payload of AcsWebhooks events. */ class AcsWebhooksHandler { 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.acsWebhooks.AuthenticationNotificationRequest.TypeEnum).includes(type)) { return this.getAuthenticationNotificationRequest(); } if (Object.values(__1.acsWebhooks.RelayedAuthenticationRequest.TypeEnum).includes(type)) { return this.getRelayedAuthenticationRequest(); } throw new Error("Could not parse the json payload: " + this.payload); } /** * Deserialize the webhook payload into a AuthenticationNotificationRequest * * @returns Deserialized AuthenticationNotificationRequest object. */ getAuthenticationNotificationRequest() { return __1.acsWebhooks.ObjectSerializer.deserialize(this.payload, "AuthenticationNotificationRequest"); } /** * Deserialize the webhook payload into a RelayedAuthenticationRequest * * @returns Deserialized RelayedAuthenticationRequest object. */ getRelayedAuthenticationRequest() { return __1.acsWebhooks.ObjectSerializer.deserialize(this.payload, "RelayedAuthenticationRequest"); } } exports.AcsWebhooksHandler = AcsWebhooksHandler; //# sourceMappingURL=acsWebhooksHandler.js.map