Package com.adyen.util.tapi
Class PredefinedContentHelper
- java.lang.Object
-
- com.adyen.util.tapi.PredefinedContentHelper
-
public final class PredefinedContentHelper extends Object
A helper class to parse and manage the key-value pairs within a PredefinedContent referenceID string. The referenceID is expected to be in a URL query string format (e.g.,key1=value1&key2=value2).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPredefinedContentHelper.DisplayNotificationEventDefines the supported events for display notifications within a PredefinedContent reference ID.
-
Constructor Summary
Constructors Constructor Description PredefinedContentHelper(String referenceId)Constructs a helper instance by parsing the provided reference ID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<String>get(String key)Gets the value for a given key from the reference ID.Optional<PredefinedContentHelper.DisplayNotificationEvent>getEvent()Extracts and validates the 'event' value from the reference ID.Optional<String>getTimeStamp()Gets the timestamp from the reference ID.Optional<String>getTransactionId()Gets the transaction ID from the reference ID.Map<String,String>toMap()Returns an unmodifiable view of all parsed parameters.
-
-
-
Constructor Detail
-
PredefinedContentHelper
public PredefinedContentHelper(String referenceId)
Constructs a helper instance by parsing the provided reference ID.- Parameters:
referenceId- The string fromPredefinedContent#getReferenceID(), expected to be in URL query string format.
-
-
Method Detail
-
getEvent
public Optional<PredefinedContentHelper.DisplayNotificationEvent> getEvent()
Extracts and validates the 'event' value from the reference ID.- Returns:
- An
Optionalcontaining thePredefinedContentHelper.DisplayNotificationEventif it is present and valid, otherwise an empty Optional.PredefinedContentHelper helper = new PredefinedContentHelper("...&event=PIN_ENTERED"); helper.getEvent().ifPresent(event -> System.out.println(event)); // Prints PIN_ENTERED
-
getTransactionId
public Optional<String> getTransactionId()
Gets the transaction ID from the reference ID.- Returns:
- An
Optionalcontaining the TransactionID, or an empty Optional if not present.
-
getTimeStamp
public Optional<String> getTimeStamp()
Gets the timestamp from the reference ID.- Returns:
- An
Optionalcontaining the TimeStamp, or an empty Optional if not present.
-
get
public Optional<String> get(String key)
Gets the value for a given key from the reference ID.- Parameters:
key- The name of the parameter to retrieve.- Returns:
- An
Optionalcontaining the parameter's value, or an empty Optional if not present.
-
-