diff --git a/src/main/java/com/adyen/model/configurationwebhooks/BankScoreSignalTriggeredData.java b/src/main/java/com/adyen/model/configurationwebhooks/BankScoreSignalTriggeredData.java new file mode 100644 index 000000000..51cabd168 --- /dev/null +++ b/src/main/java/com/adyen/model/configurationwebhooks/BankScoreSignalTriggeredData.java @@ -0,0 +1,485 @@ +/* + * Configuration webhooks + * + * The version of the OpenAPI document: 2 + * + * + * 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.configurationwebhooks; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.time.OffsetDateTime; +import java.util.*; +import java.util.ArrayList; +import java.util.List; + +/** BankScoreSignalTriggeredData */ +@JsonPropertyOrder({ + BankScoreSignalTriggeredData.JSON_PROPERTY_ACCOUNT_HOLDER, + BankScoreSignalTriggeredData.JSON_PROPERTY_ACCOUNT_HOLDER_STATUS, + BankScoreSignalTriggeredData.JSON_PROPERTY_AUTOMATED_ACTIONS, + BankScoreSignalTriggeredData.JSON_PROPERTY_BALANCE_PLATFORM, + BankScoreSignalTriggeredData.JSON_PROPERTY_CREATION_DATE, + BankScoreSignalTriggeredData.JSON_PROPERTY_ID, + BankScoreSignalTriggeredData.JSON_PROPERTY_RISK_SCORE, + BankScoreSignalTriggeredData.JSON_PROPERTY_SCORE_SIGNALS_TRIGGERED, + BankScoreSignalTriggeredData.JSON_PROPERTY_SIGNAL_SOURCE_TYPES +}) +public class BankScoreSignalTriggeredData { + public static final String JSON_PROPERTY_ACCOUNT_HOLDER = "accountHolder"; + private ResourceReference accountHolder; + + public static final String JSON_PROPERTY_ACCOUNT_HOLDER_STATUS = "accountHolderStatus"; + private String accountHolderStatus; + + public static final String JSON_PROPERTY_AUTOMATED_ACTIONS = "automatedActions"; + private List automatedActions; + + public static final String JSON_PROPERTY_BALANCE_PLATFORM = "balancePlatform"; + private String balancePlatform; + + public static final String JSON_PROPERTY_CREATION_DATE = "creationDate"; + private OffsetDateTime creationDate; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_RISK_SCORE = "riskScore"; + private Integer riskScore; + + public static final String JSON_PROPERTY_SCORE_SIGNALS_TRIGGERED = "scoreSignalsTriggered"; + private List scoreSignalsTriggered; + + public static final String JSON_PROPERTY_SIGNAL_SOURCE_TYPES = "signalSourceTypes"; + private List signalSourceTypes; + + public BankScoreSignalTriggeredData() {} + + /** + * accountHolder + * + * @param accountHolder + * @return the current {@code BankScoreSignalTriggeredData} instance, allowing for method chaining + */ + public BankScoreSignalTriggeredData accountHolder(ResourceReference accountHolder) { + this.accountHolder = accountHolder; + return this; + } + + /** + * Get accountHolder + * + * @return accountHolder + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ResourceReference getAccountHolder() { + return accountHolder; + } + + /** + * accountHolder + * + * @param accountHolder + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAccountHolder(ResourceReference accountHolder) { + this.accountHolder = accountHolder; + } + + /** + * The status of the account holder. + * + * @param accountHolderStatus The status of the account holder. + * @return the current {@code BankScoreSignalTriggeredData} instance, allowing for method chaining + */ + public BankScoreSignalTriggeredData accountHolderStatus(String accountHolderStatus) { + this.accountHolderStatus = accountHolderStatus; + return this; + } + + /** + * The status of the account holder. + * + * @return accountHolderStatus The status of the account holder. + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAccountHolderStatus() { + return accountHolderStatus; + } + + /** + * The status of the account holder. + * + * @param accountHolderStatus The status of the account holder. + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAccountHolderStatus(String accountHolderStatus) { + this.accountHolderStatus = accountHolderStatus; + } + + /** + * The automated action(s) taken as a result of the score signals that were triggered. + * + * @param automatedActions The automated action(s) taken as a result of the score signals that + * were triggered. + * @return the current {@code BankScoreSignalTriggeredData} instance, allowing for method chaining + */ + public BankScoreSignalTriggeredData automatedActions(List automatedActions) { + this.automatedActions = automatedActions; + return this; + } + + public BankScoreSignalTriggeredData addAutomatedActionsItem(String automatedActionsItem) { + if (this.automatedActions == null) { + this.automatedActions = new ArrayList<>(); + } + this.automatedActions.add(automatedActionsItem); + return this; + } + + /** + * The automated action(s) taken as a result of the score signals that were triggered. + * + * @return automatedActions The automated action(s) taken as a result of the score signals that + * were triggered. + */ + @JsonProperty(JSON_PROPERTY_AUTOMATED_ACTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getAutomatedActions() { + return automatedActions; + } + + /** + * The automated action(s) taken as a result of the score signals that were triggered. + * + * @param automatedActions The automated action(s) taken as a result of the score signals that + * were triggered. + */ + @JsonProperty(JSON_PROPERTY_AUTOMATED_ACTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAutomatedActions(List automatedActions) { + this.automatedActions = automatedActions; + } + + /** + * The unique identifier of the balance platform. + * + * @param balancePlatform The unique identifier of the balance platform. + * @return the current {@code BankScoreSignalTriggeredData} instance, allowing for method chaining + */ + public BankScoreSignalTriggeredData balancePlatform(String balancePlatform) { + this.balancePlatform = balancePlatform; + return this; + } + + /** + * The unique identifier of the balance platform. + * + * @return balancePlatform The unique identifier of the balance platform. + */ + @JsonProperty(JSON_PROPERTY_BALANCE_PLATFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBalancePlatform() { + return balancePlatform; + } + + /** + * The unique identifier of the balance platform. + * + * @param balancePlatform The unique identifier of the balance platform. + */ + @JsonProperty(JSON_PROPERTY_BALANCE_PLATFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBalancePlatform(String balancePlatform) { + this.balancePlatform = balancePlatform; + } + + /** + * The date and time when the event was triggered, in ISO 8601 extended format. For example, + * **2025-03-19T10:15:30+01:00**. + * + * @param creationDate The date and time when the event was triggered, in ISO 8601 extended + * format. For example, **2025-03-19T10:15:30+01:00**. + * @return the current {@code BankScoreSignalTriggeredData} instance, allowing for method chaining + */ + public BankScoreSignalTriggeredData creationDate(OffsetDateTime creationDate) { + this.creationDate = creationDate; + return this; + } + + /** + * The date and time when the event was triggered, in ISO 8601 extended format. For example, + * **2025-03-19T10:15:30+01:00**. + * + * @return creationDate The date and time when the event was triggered, in ISO 8601 extended + * format. For example, **2025-03-19T10:15:30+01:00**. + */ + @JsonProperty(JSON_PROPERTY_CREATION_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreationDate() { + return creationDate; + } + + /** + * The date and time when the event was triggered, in ISO 8601 extended format. For example, + * **2025-03-19T10:15:30+01:00**. + * + * @param creationDate The date and time when the event was triggered, in ISO 8601 extended + * format. For example, **2025-03-19T10:15:30+01:00**. + */ + @JsonProperty(JSON_PROPERTY_CREATION_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreationDate(OffsetDateTime creationDate) { + this.creationDate = creationDate; + } + + /** + * The ID of the resource. + * + * @param id The ID of the resource. + * @return the current {@code BankScoreSignalTriggeredData} instance, allowing for method chaining + */ + public BankScoreSignalTriggeredData id(String id) { + this.id = id; + return this; + } + + /** + * The ID of the resource. + * + * @return id The ID of the resource. + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + /** + * The ID of the resource. + * + * @param id The ID of the resource. + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + /** + * The score of the identity resulting from the signal(s) that were triggered. + * + * @param riskScore The score of the identity resulting from the signal(s) that were triggered. + * @return the current {@code BankScoreSignalTriggeredData} instance, allowing for method chaining + */ + public BankScoreSignalTriggeredData riskScore(Integer riskScore) { + this.riskScore = riskScore; + return this; + } + + /** + * The score of the identity resulting from the signal(s) that were triggered. + * + * @return riskScore The score of the identity resulting from the signal(s) that were triggered. + */ + @JsonProperty(JSON_PROPERTY_RISK_SCORE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getRiskScore() { + return riskScore; + } + + /** + * The score of the identity resulting from the signal(s) that were triggered. + * + * @param riskScore The score of the identity resulting from the signal(s) that were triggered. + */ + @JsonProperty(JSON_PROPERTY_RISK_SCORE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRiskScore(Integer riskScore) { + this.riskScore = riskScore; + } + + /** + * The name(s) of the score signals that were triggered. + * + * @param scoreSignalsTriggered The name(s) of the score signals that were triggered. + * @return the current {@code BankScoreSignalTriggeredData} instance, allowing for method chaining + */ + public BankScoreSignalTriggeredData scoreSignalsTriggered(List scoreSignalsTriggered) { + this.scoreSignalsTriggered = scoreSignalsTriggered; + return this; + } + + public BankScoreSignalTriggeredData addScoreSignalsTriggeredItem( + String scoreSignalsTriggeredItem) { + if (this.scoreSignalsTriggered == null) { + this.scoreSignalsTriggered = new ArrayList<>(); + } + this.scoreSignalsTriggered.add(scoreSignalsTriggeredItem); + return this; + } + + /** + * The name(s) of the score signals that were triggered. + * + * @return scoreSignalsTriggered The name(s) of the score signals that were triggered. + */ + @JsonProperty(JSON_PROPERTY_SCORE_SIGNALS_TRIGGERED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getScoreSignalsTriggered() { + return scoreSignalsTriggered; + } + + /** + * The name(s) of the score signals that were triggered. + * + * @param scoreSignalsTriggered The name(s) of the score signals that were triggered. + */ + @JsonProperty(JSON_PROPERTY_SCORE_SIGNALS_TRIGGERED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setScoreSignalsTriggered(List scoreSignalsTriggered) { + this.scoreSignalsTriggered = scoreSignalsTriggered; + } + + /** + * The type(s) of the score signals that were triggered. + * + * @param signalSourceTypes The type(s) of the score signals that were triggered. + * @return the current {@code BankScoreSignalTriggeredData} instance, allowing for method chaining + */ + public BankScoreSignalTriggeredData signalSourceTypes(List signalSourceTypes) { + this.signalSourceTypes = signalSourceTypes; + return this; + } + + public BankScoreSignalTriggeredData addSignalSourceTypesItem(String signalSourceTypesItem) { + if (this.signalSourceTypes == null) { + this.signalSourceTypes = new ArrayList<>(); + } + this.signalSourceTypes.add(signalSourceTypesItem); + return this; + } + + /** + * The type(s) of the score signals that were triggered. + * + * @return signalSourceTypes The type(s) of the score signals that were triggered. + */ + @JsonProperty(JSON_PROPERTY_SIGNAL_SOURCE_TYPES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getSignalSourceTypes() { + return signalSourceTypes; + } + + /** + * The type(s) of the score signals that were triggered. + * + * @param signalSourceTypes The type(s) of the score signals that were triggered. + */ + @JsonProperty(JSON_PROPERTY_SIGNAL_SOURCE_TYPES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSignalSourceTypes(List signalSourceTypes) { + this.signalSourceTypes = signalSourceTypes; + } + + /** Return true if this BankScoreSignalTriggeredData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BankScoreSignalTriggeredData bankScoreSignalTriggeredData = (BankScoreSignalTriggeredData) o; + return Objects.equals(this.accountHolder, bankScoreSignalTriggeredData.accountHolder) + && Objects.equals( + this.accountHolderStatus, bankScoreSignalTriggeredData.accountHolderStatus) + && Objects.equals(this.automatedActions, bankScoreSignalTriggeredData.automatedActions) + && Objects.equals(this.balancePlatform, bankScoreSignalTriggeredData.balancePlatform) + && Objects.equals(this.creationDate, bankScoreSignalTriggeredData.creationDate) + && Objects.equals(this.id, bankScoreSignalTriggeredData.id) + && Objects.equals(this.riskScore, bankScoreSignalTriggeredData.riskScore) + && Objects.equals( + this.scoreSignalsTriggered, bankScoreSignalTriggeredData.scoreSignalsTriggered) + && Objects.equals(this.signalSourceTypes, bankScoreSignalTriggeredData.signalSourceTypes); + } + + @Override + public int hashCode() { + return Objects.hash( + accountHolder, + accountHolderStatus, + automatedActions, + balancePlatform, + creationDate, + id, + riskScore, + scoreSignalsTriggered, + signalSourceTypes); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BankScoreSignalTriggeredData {\n"); + sb.append(" accountHolder: ").append(toIndentedString(accountHolder)).append("\n"); + sb.append(" accountHolderStatus: ") + .append(toIndentedString(accountHolderStatus)) + .append("\n"); + sb.append(" automatedActions: ").append(toIndentedString(automatedActions)).append("\n"); + sb.append(" balancePlatform: ").append(toIndentedString(balancePlatform)).append("\n"); + sb.append(" creationDate: ").append(toIndentedString(creationDate)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" riskScore: ").append(toIndentedString(riskScore)).append("\n"); + sb.append(" scoreSignalsTriggered: ") + .append(toIndentedString(scoreSignalsTriggered)) + .append("\n"); + sb.append(" signalSourceTypes: ").append(toIndentedString(signalSourceTypes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create an instance of BankScoreSignalTriggeredData given an JSON string + * + * @param jsonString JSON string + * @return An instance of BankScoreSignalTriggeredData + * @throws JsonProcessingException if the JSON string is invalid with respect to + * BankScoreSignalTriggeredData + */ + public static BankScoreSignalTriggeredData fromJson(String jsonString) + throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, BankScoreSignalTriggeredData.class); + } + + /** + * Convert an instance of BankScoreSignalTriggeredData to an JSON string + * + * @return JSON string + */ + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); + } +} diff --git a/src/main/java/com/adyen/model/configurationwebhooks/ConfigurationWebhooksHandler.java b/src/main/java/com/adyen/model/configurationwebhooks/ConfigurationWebhooksHandler.java index bba6c6064..6cd42a068 100644 --- a/src/main/java/com/adyen/model/configurationwebhooks/ConfigurationWebhooksHandler.java +++ b/src/main/java/com/adyen/model/configurationwebhooks/ConfigurationWebhooksHandler.java @@ -147,6 +147,28 @@ public Optional getPaymentNotificationRequest() { return Optional.empty(); } + /** + * Attempts to deserialize the webhook payload into a ScoreNotificationRequest + * + * @return an Optional containing the deserialized object, or empty if deserialization fails + */ + public Optional getScoreNotificationRequest() { + + var optionalScoreNotificationRequest = getOptionalField(ScoreNotificationRequest.class); + + if (optionalScoreNotificationRequest.isPresent()) { + // verify event type + for (var value : ScoreNotificationRequest.TypeEnum.values()) { + if (value.equals(optionalScoreNotificationRequest.get().getType())) { + // found matching event type + return optionalScoreNotificationRequest; + } + } + } + + return Optional.empty(); + } + /** * Attempts to deserialize the webhook payload into a SweepConfigurationNotificationRequest * diff --git a/src/main/java/com/adyen/model/configurationwebhooks/ResourceReference.java b/src/main/java/com/adyen/model/configurationwebhooks/ResourceReference.java new file mode 100644 index 000000000..a015a573b --- /dev/null +++ b/src/main/java/com/adyen/model/configurationwebhooks/ResourceReference.java @@ -0,0 +1,197 @@ +/* + * Configuration webhooks + * + * The version of the OpenAPI document: 2 + * + * + * 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.configurationwebhooks; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.*; + +/** ResourceReference */ +@JsonPropertyOrder({ + ResourceReference.JSON_PROPERTY_DESCRIPTION, + ResourceReference.JSON_PROPERTY_ID, + ResourceReference.JSON_PROPERTY_REFERENCE +}) +public class ResourceReference { + public static final String JSON_PROPERTY_DESCRIPTION = "description"; + private String description; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_REFERENCE = "reference"; + private String reference; + + public ResourceReference() {} + + /** + * The description of the resource. + * + * @param description The description of the resource. + * @return the current {@code ResourceReference} instance, allowing for method chaining + */ + public ResourceReference description(String description) { + this.description = description; + return this; + } + + /** + * The description of the resource. + * + * @return description The description of the resource. + */ + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDescription() { + return description; + } + + /** + * The description of the resource. + * + * @param description The description of the resource. + */ + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDescription(String description) { + this.description = description; + } + + /** + * The unique identifier of the resource. + * + * @param id The unique identifier of the resource. + * @return the current {@code ResourceReference} instance, allowing for method chaining + */ + public ResourceReference id(String id) { + this.id = id; + return this; + } + + /** + * The unique identifier of the resource. + * + * @return id The unique identifier of the resource. + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + /** + * The unique identifier of the resource. + * + * @param id The unique identifier of the resource. + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + /** + * The reference for the resource. + * + * @param reference The reference for the resource. + * @return the current {@code ResourceReference} instance, allowing for method chaining + */ + public ResourceReference reference(String reference) { + this.reference = reference; + return this; + } + + /** + * The reference for the resource. + * + * @return reference The reference for the resource. + */ + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getReference() { + return reference; + } + + /** + * The reference for the resource. + * + * @param reference The reference for the resource. + */ + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setReference(String reference) { + this.reference = reference; + } + + /** Return true if this ResourceReference object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResourceReference resourceReference = (ResourceReference) o; + return Objects.equals(this.description, resourceReference.description) + && Objects.equals(this.id, resourceReference.id) + && Objects.equals(this.reference, resourceReference.reference); + } + + @Override + public int hashCode() { + return Objects.hash(description, id, reference); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ResourceReference {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" reference: ").append(toIndentedString(reference)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create an instance of ResourceReference given an JSON string + * + * @param jsonString JSON string + * @return An instance of ResourceReference + * @throws JsonProcessingException if the JSON string is invalid with respect to ResourceReference + */ + public static ResourceReference fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, ResourceReference.class); + } + + /** + * Convert an instance of ResourceReference to an JSON string + * + * @return JSON string + */ + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); + } +} diff --git a/src/main/java/com/adyen/model/configurationwebhooks/ScoreNotificationRequest.java b/src/main/java/com/adyen/model/configurationwebhooks/ScoreNotificationRequest.java new file mode 100644 index 000000000..e25fb7b3e --- /dev/null +++ b/src/main/java/com/adyen/model/configurationwebhooks/ScoreNotificationRequest.java @@ -0,0 +1,285 @@ +/* + * Configuration webhooks + * + * The version of the OpenAPI document: 2 + * + * + * 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.configurationwebhooks; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.time.OffsetDateTime; +import java.util.*; +import java.util.Arrays; +import java.util.logging.Logger; + +/** ScoreNotificationRequest */ +@JsonPropertyOrder({ + ScoreNotificationRequest.JSON_PROPERTY_DATA, + ScoreNotificationRequest.JSON_PROPERTY_ENVIRONMENT, + ScoreNotificationRequest.JSON_PROPERTY_TIMESTAMP, + ScoreNotificationRequest.JSON_PROPERTY_TYPE +}) +public class ScoreNotificationRequest { + public static final String JSON_PROPERTY_DATA = "data"; + private BankScoreSignalTriggeredData data; + + public static final String JSON_PROPERTY_ENVIRONMENT = "environment"; + private String environment; + + public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; + private OffsetDateTime timestamp; + + /** Type of webhook. */ + public enum TypeEnum { + BALANCEPLATFORM_SCORE_TRIGGERED(String.valueOf("balancePlatform.score.triggered")); + + private static final Logger LOG = Logger.getLogger(TypeEnum.class.getName()); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + // handling unexpected value + LOG.warning( + "TypeEnum: unexpected enum value '" + + value + + "' - Supported values are " + + Arrays.toString(TypeEnum.values())); + return null; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private TypeEnum type; + + public ScoreNotificationRequest() {} + + /** + * data + * + * @param data + * @return the current {@code ScoreNotificationRequest} instance, allowing for method chaining + */ + public ScoreNotificationRequest data(BankScoreSignalTriggeredData data) { + this.data = data; + return this; + } + + /** + * Get data + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public BankScoreSignalTriggeredData getData() { + return data; + } + + /** + * data + * + * @param data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setData(BankScoreSignalTriggeredData data) { + this.data = data; + } + + /** + * The environment from which the webhook originated. Possible values: **test**, **live**. + * + * @param environment The environment from which the webhook originated. Possible values: + * **test**, **live**. + * @return the current {@code ScoreNotificationRequest} instance, allowing for method chaining + */ + public ScoreNotificationRequest environment(String environment) { + this.environment = environment; + return this; + } + + /** + * The environment from which the webhook originated. Possible values: **test**, **live**. + * + * @return environment The environment from which the webhook originated. Possible values: + * **test**, **live**. + */ + @JsonProperty(JSON_PROPERTY_ENVIRONMENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEnvironment() { + return environment; + } + + /** + * The environment from which the webhook originated. Possible values: **test**, **live**. + * + * @param environment The environment from which the webhook originated. Possible values: + * **test**, **live**. + */ + @JsonProperty(JSON_PROPERTY_ENVIRONMENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEnvironment(String environment) { + this.environment = environment; + } + + /** + * When the event was queued. + * + * @param timestamp When the event was queued. + * @return the current {@code ScoreNotificationRequest} instance, allowing for method chaining + */ + public ScoreNotificationRequest timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * When the event was queued. + * + * @return timestamp When the event was queued. + */ + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getTimestamp() { + return timestamp; + } + + /** + * When the event was queued. + * + * @param timestamp When the event was queued. + */ + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + /** + * Type of webhook. + * + * @param type Type of webhook. + * @return the current {@code ScoreNotificationRequest} instance, allowing for method chaining + */ + public ScoreNotificationRequest type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Type of webhook. + * + * @return type Type of webhook. + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TypeEnum getType() { + return type; + } + + /** + * Type of webhook. + * + * @param type Type of webhook. + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + /** Return true if this ScoreNotificationRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScoreNotificationRequest scoreNotificationRequest = (ScoreNotificationRequest) o; + return Objects.equals(this.data, scoreNotificationRequest.data) + && Objects.equals(this.environment, scoreNotificationRequest.environment) + && Objects.equals(this.timestamp, scoreNotificationRequest.timestamp) + && Objects.equals(this.type, scoreNotificationRequest.type); + } + + @Override + public int hashCode() { + return Objects.hash(data, environment, timestamp, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ScoreNotificationRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" environment: ").append(toIndentedString(environment)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create an instance of ScoreNotificationRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of ScoreNotificationRequest + * @throws JsonProcessingException if the JSON string is invalid with respect to + * ScoreNotificationRequest + */ + public static ScoreNotificationRequest fromJson(String jsonString) + throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, ScoreNotificationRequest.class); + } + + /** + * Convert an instance of ScoreNotificationRequest to an JSON string + * + * @return JSON string + */ + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); + } +} diff --git a/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java b/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java index b4ac142f4..75bb8f435 100644 --- a/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java +++ b/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java @@ -436,4 +436,34 @@ public void testGetDisputeNotificationRequestWithEmptyJson() { Optional result = handler.getDisputeNotificationRequest(); assertFalse(result.isPresent()); } + + @Test + public void testScoreNotificationRequest() { + + String json = + getFileContents("mocks/balancePlatform-webhooks/balancePlatform-score-triggered.json"); + + ConfigurationWebhooksHandler handler = new ConfigurationWebhooksHandler(json); + Optional optionalRequest = handler.getScoreNotificationRequest(); + + assertTrue("The ScoreNotificationRequest should be present", optionalRequest.isPresent()); + + ScoreNotificationRequest request = optionalRequest.get(); + assertEquals( + ScoreNotificationRequest.TypeEnum.BALANCEPLATFORM_SCORE_TRIGGERED, request.getType()); + assertEquals("test", request.getEnvironment()); + + BankScoreSignalTriggeredData data = request.getData(); + assertNotNull(data); + assertEquals("2235e7be-fcb0-4b88-a79b-895b68cfb855", data.getId()); + assertEquals(Integer.valueOf(100), data.getRiskScore()); + + assertNotNull(data.getAccountHolder()); + assertEquals("AH00000000000001", data.getAccountHolder().getId()); + + assertNotNull(data.getScoreSignalsTriggered()); + assertEquals(2, data.getScoreSignalsTriggered().size()); + assertEquals("ChargebackCardholderDispute", data.getScoreSignalsTriggered().get(0)); + assertEquals("ChargebackNonReceipt", data.getScoreSignalsTriggered().get(1)); + } } diff --git a/src/test/resources/mocks/balancePlatform-webhooks/balancePlatform-score-triggered.json b/src/test/resources/mocks/balancePlatform-webhooks/balancePlatform-score-triggered.json new file mode 100644 index 000000000..720c6cfa2 --- /dev/null +++ b/src/test/resources/mocks/balancePlatform-webhooks/balancePlatform-score-triggered.json @@ -0,0 +1,19 @@ +{ + "data": { + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "creationDate": "2025-07-20T17:12:07+02:00", + "id": "2235e7be-fcb0-4b88-a79b-895b68cfb855", + "accountHolder": { + "description": "AH 01", + "id": "AH00000000000001", + "reference": "ref1" + }, + "riskScore": 100, + "scoreSignalsTriggered": [ + "ChargebackCardholderDispute", + "ChargebackNonReceipt" + ] + }, + "environment": "test", + "type": "balancePlatform.score.triggered" +} \ No newline at end of file