@adyen/api-library
Version:
The Adyen API Library for NodeJS enables you to work with Adyen APIs.
84 lines • 3.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/*
* Adyen NodeJS API Library
* Copyright (c) 2023 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
const typings_1 = require("../typings");
/**
* DEPRECATED
*
* Centralised handler for de-serialising all (Management) webhook payloads.
*
* @deprecated Use instead ManagementWebhooksHandler
*/
class ManagementWebhookHandler {
/**
* Constructor
* @deprecated Use specific webhook handlers instead.
*
* @param jsonPayload
*/
constructor(jsonPayload) {
this.payload = JSON.parse(jsonPayload);
}
/**
* Return generic webhook type
* @deprecated Use specific webhook handlers instead.
*
* @param jsonPayload
*/
getGenericWebhook() {
const type = this.payload["type"];
if (Object.values(typings_1.managementWebhooks.MerchantCreatedNotificationRequest.TypeEnum).includes(type)) {
return this.getMerchantCreatedNotificationRequest();
}
if (Object.values(typings_1.managementWebhooks.MerchantUpdatedNotificationRequest.TypeEnum).includes(type)) {
return this.getMerchantUpdatedNotificationRequest();
}
if (Object.values(typings_1.managementWebhooks.PaymentMethodCreatedNotificationRequest.TypeEnum).includes(type)) {
return this.getPaymentMethodCreatedNotificationRequest();
}
if (Object.values(typings_1.managementWebhooks.PaymentMethodRequestRemovedNotificationRequest.TypeEnum).includes(type)) {
return this.getPaymentMethodRequestRemovedNotificationRequest();
}
if (Object.values(typings_1.managementWebhooks.PaymentMethodScheduledForRemovalNotificationRequest.TypeEnum).includes(type)) {
return this.getPaymentMethodScheduledForRemovalNotificationRequest();
}
throw new Error("Could not parse the json payload: " + this.payload);
}
/**
* @deprecated Use ManagementWebhooksHandler instead.
*/
getMerchantCreatedNotificationRequest() {
return typings_1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "MerchantCreatedNotificationRequest");
}
/**
* @deprecated Use ManagementWebhooksHandler instead.
*/
getMerchantUpdatedNotificationRequest() {
return typings_1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "MerchantUpdatedNotificationRequest");
}
/**
* @deprecated Use ManagementWebhooksHandler instead.
*/
getPaymentMethodCreatedNotificationRequest() {
return typings_1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentMethodCreatedNotificationRequest");
}
/**
* @deprecated Use ManagementWebhooksHandler instead.
*/
getPaymentMethodRequestRemovedNotificationRequest() {
return typings_1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentMethodRequestRemovedNotificationRequest");
}
/**
* @deprecated Use ManagementWebhooksHandler instead.
*/
getPaymentMethodScheduledForRemovalNotificationRequest() {
return typings_1.managementWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentMethodScheduledForRemovalNotificationRequest");
}
}
exports.default = ManagementWebhookHandler;
//# sourceMappingURL=managementWebhookHandler.js.map