All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adyen.model.acswebhooks.AcsWebhooksHandler Maven / Gradle / Ivy

There is a newer version: 38.1.0
Show newest version
/*
 * Authentication webhooks
 *
 * The version of the OpenAPI document: 1
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

package com.adyen.model.acswebhooks;

import java.util.Optional;
import java.util.logging.Logger;

/**
 * Handler for processing AcsWebhooks.
 * 

* This class provides functionality to deserialize the payload of AcsWebhooks events. */ public class AcsWebhooksHandler { private static final Logger LOG = Logger.getLogger(AcsWebhooksHandler.class.getName()); private final String payload; /** * Constructs a new handler for the given webhook payload * * @param payload the raw JSON payload from the webhook */ public AcsWebhooksHandler(String payload) { this.payload = payload; } /** * Attempts to deserialize the webhook payload into a AuthenticationNotificationRequest * * @return an Optional containing the deserialized object, or empty if deserialization fails */ public Optional getAuthenticationNotificationRequest() { return getOptionalField(AuthenticationNotificationRequest.class); } /** * Attempts to deserialize the webhook payload into a RelayedAuthenticationRequest * * @return an Optional containing the deserialized object, or empty if deserialization fails */ public Optional getRelayedAuthenticationRequest() { return getOptionalField(RelayedAuthenticationRequest.class); } /** * Deserializes the payload into the specified class type. * * @param clazz the class to deserialize into * @param the type of the class * @return an Optional containing the deserialized object, or empty if an error occurs */ private Optional getOptionalField(Class clazz) { try { T val = JSON.getMapper().readValue(payload, clazz); return Optional.ofNullable(val); } catch (Exception e) { // an error has occurred during deserialization (object not found, deserialization error) LOG.warning("Object not found or unexpected error trying to access: " + clazz.getName()); LOG.warning("Deserialization error: " + e.getMessage()); return Optional.empty(); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy