@adyen/api-library
Version:
The Adyen API Library for NodeJS enables you to work with Adyen APIs.
45 lines • 1.68 kB
JavaScript
;
/*
* The version of the OpenAPI document: v4
*
*
* 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.TransactionWebhooksHandler = void 0;
const __1 = require("..");
/**
* Handler for processing TransactionWebhooks.
*
* This class provides functionality to deserialize the payload of TransactionWebhooks events.
*/
class TransactionWebhooksHandler {
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.transactionWebhooks.TransactionNotificationRequestV4.TypeEnum).includes(type)) {
return this.getTransactionNotificationRequestV4();
}
throw new Error("Could not parse the json payload: " + this.payload);
}
/**
* Deserialize the webhook payload into a TransactionNotificationRequestV4
*
* @returns Deserialized TransactionNotificationRequestV4 object.
*/
getTransactionNotificationRequestV4() {
return __1.transactionWebhooks.ObjectSerializer.deserialize(this.payload, "TransactionNotificationRequestV4");
}
}
exports.TransactionWebhooksHandler = TransactionWebhooksHandler;
//# sourceMappingURL=transactionWebhooksHandler.js.map