diff --git a/src/main/java/com/adyen/model/configurationwebhooks/ConfigurationWebhooksHandler.java b/src/main/java/com/adyen/model/configurationwebhooks/ConfigurationWebhooksHandler.java index 6cd42a068..5041867db 100644 --- a/src/main/java/com/adyen/model/configurationwebhooks/ConfigurationWebhooksHandler.java +++ b/src/main/java/com/adyen/model/configurationwebhooks/ConfigurationWebhooksHandler.java @@ -102,6 +102,28 @@ public Optional getCardOrderNotificationRequest() return Optional.empty(); } + /** + * Attempts to deserialize the webhook payload into a MandateNotificationRequest + * + * @return an Optional containing the deserialized object, or empty if deserialization fails + */ + public Optional getMandateNotificationRequest() { + + var optionalMandateNotificationRequest = getOptionalField(MandateNotificationRequest.class); + + if (optionalMandateNotificationRequest.isPresent()) { + // verify event type + for (var value : MandateNotificationRequest.TypeEnum.values()) { + if (value.equals(optionalMandateNotificationRequest.get().getType())) { + // found matching event type + return optionalMandateNotificationRequest; + } + } + } + + return Optional.empty(); + } + /** * Attempts to deserialize the webhook payload into a NetworkTokenNotificationRequest * diff --git a/src/main/java/com/adyen/model/configurationwebhooks/Mandate.java b/src/main/java/com/adyen/model/configurationwebhooks/Mandate.java new file mode 100644 index 000000000..45b7efe31 --- /dev/null +++ b/src/main/java/com/adyen/model/configurationwebhooks/Mandate.java @@ -0,0 +1,497 @@ +/* + * 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.util.*; +import java.util.Arrays; +import java.util.logging.Logger; + +/** Mandate */ +@JsonPropertyOrder({ + Mandate.JSON_PROPERTY_BALANCE_ACCOUNT_ID, + Mandate.JSON_PROPERTY_COUNTERPARTY, + Mandate.JSON_PROPERTY_CREATED_AT, + Mandate.JSON_PROPERTY_ID, + Mandate.JSON_PROPERTY_PAYMENT_INSTRUMENT_ID, + Mandate.JSON_PROPERTY_STATUS, + Mandate.JSON_PROPERTY_TYPE, + Mandate.JSON_PROPERTY_UPDATED_AT +}) +public class Mandate { + public static final String JSON_PROPERTY_BALANCE_ACCOUNT_ID = "balanceAccountId"; + private String balanceAccountId; + + public static final String JSON_PROPERTY_COUNTERPARTY = "counterparty"; + private MandateBankAccount counterparty; + + public static final String JSON_PROPERTY_CREATED_AT = "createdAt"; + private Object createdAt; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_PAYMENT_INSTRUMENT_ID = "paymentInstrumentId"; + private String paymentInstrumentId; + + /** The status of the mandate. Possible values: **pending**, **approved**, **cancelled**. */ + public enum StatusEnum { + APPROVED(String.valueOf("approved")), + + CANCELLED(String.valueOf("cancelled")), + + PENDING(String.valueOf("pending")); + + private static final Logger LOG = Logger.getLogger(StatusEnum.class.getName()); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + // handling unexpected value + LOG.warning( + "StatusEnum: unexpected enum value '" + + value + + "' - Supported values are " + + Arrays.toString(StatusEnum.values())); + return null; + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + private StatusEnum status; + + /** The type of mandate. Possible value: **bacs**. */ + public enum TypeEnum { + BACS(String.valueOf("bacs")); + + 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 static final String JSON_PROPERTY_UPDATED_AT = "updatedAt"; + private Object updatedAt; + + public Mandate() {} + + /** + * The unique identifier of the balance account linked to the payment instrument. + * + * @param balanceAccountId The unique identifier of the balance account linked to the payment + * instrument. + * @return the current {@code Mandate} instance, allowing for method chaining + */ + public Mandate balanceAccountId(String balanceAccountId) { + this.balanceAccountId = balanceAccountId; + return this; + } + + /** + * The unique identifier of the balance account linked to the payment instrument. + * + * @return balanceAccountId The unique identifier of the balance account linked to the payment + * instrument. + */ + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBalanceAccountId() { + return balanceAccountId; + } + + /** + * The unique identifier of the balance account linked to the payment instrument. + * + * @param balanceAccountId The unique identifier of the balance account linked to the payment + * instrument. + */ + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBalanceAccountId(String balanceAccountId) { + this.balanceAccountId = balanceAccountId; + } + + /** + * counterparty + * + * @param counterparty + * @return the current {@code Mandate} instance, allowing for method chaining + */ + public Mandate counterparty(MandateBankAccount counterparty) { + this.counterparty = counterparty; + return this; + } + + /** + * Get counterparty + * + * @return counterparty + */ + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MandateBankAccount getCounterparty() { + return counterparty; + } + + /** + * counterparty + * + * @param counterparty + */ + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCounterparty(MandateBankAccount counterparty) { + this.counterparty = counterparty; + } + + /** + * createdAt + * + * @param createdAt + * @return the current {@code Mandate} instance, allowing for method chaining + */ + public Mandate createdAt(Object createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getCreatedAt() { + return createdAt; + } + + /** + * createdAt + * + * @param createdAt + */ + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreatedAt(Object createdAt) { + this.createdAt = createdAt; + } + + /** + * The unique identifier of the mandate. + * + * @param id The unique identifier of the mandate. + * @return the current {@code Mandate} instance, allowing for method chaining + */ + public Mandate id(String id) { + this.id = id; + return this; + } + + /** + * The unique identifier of the mandate. + * + * @return id The unique identifier of the mandate. + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + /** + * The unique identifier of the mandate. + * + * @param id The unique identifier of the mandate. + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + /** + * The unique identifier of the payment instrument linked to the mandate. + * + * @param paymentInstrumentId The unique identifier of the payment instrument linked to the + * mandate. + * @return the current {@code Mandate} instance, allowing for method chaining + */ + public Mandate paymentInstrumentId(String paymentInstrumentId) { + this.paymentInstrumentId = paymentInstrumentId; + return this; + } + + /** + * The unique identifier of the payment instrument linked to the mandate. + * + * @return paymentInstrumentId The unique identifier of the payment instrument linked to the + * mandate. + */ + @JsonProperty(JSON_PROPERTY_PAYMENT_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPaymentInstrumentId() { + return paymentInstrumentId; + } + + /** + * The unique identifier of the payment instrument linked to the mandate. + * + * @param paymentInstrumentId The unique identifier of the payment instrument linked to the + * mandate. + */ + @JsonProperty(JSON_PROPERTY_PAYMENT_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPaymentInstrumentId(String paymentInstrumentId) { + this.paymentInstrumentId = paymentInstrumentId; + } + + /** + * The status of the mandate. Possible values: **pending**, **approved**, **cancelled**. + * + * @param status The status of the mandate. Possible values: **pending**, **approved**, + * **cancelled**. + * @return the current {@code Mandate} instance, allowing for method chaining + */ + public Mandate status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * The status of the mandate. Possible values: **pending**, **approved**, **cancelled**. + * + * @return status The status of the mandate. Possible values: **pending**, **approved**, + * **cancelled**. + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public StatusEnum getStatus() { + return status; + } + + /** + * The status of the mandate. Possible values: **pending**, **approved**, **cancelled**. + * + * @param status The status of the mandate. Possible values: **pending**, **approved**, + * **cancelled**. + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + * The type of mandate. Possible value: **bacs**. + * + * @param type The type of mandate. Possible value: **bacs**. + * @return the current {@code Mandate} instance, allowing for method chaining + */ + public Mandate type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of mandate. Possible value: **bacs**. + * + * @return type The type of mandate. Possible value: **bacs**. + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TypeEnum getType() { + return type; + } + + /** + * The type of mandate. Possible value: **bacs**. + * + * @param type The type of mandate. Possible value: **bacs**. + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + /** + * updatedAt + * + * @param updatedAt + * @return the current {@code Mandate} instance, allowing for method chaining + */ + public Mandate updatedAt(Object updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Get updatedAt + * + * @return updatedAt + */ + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getUpdatedAt() { + return updatedAt; + } + + /** + * updatedAt + * + * @param updatedAt + */ + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUpdatedAt(Object updatedAt) { + this.updatedAt = updatedAt; + } + + /** Return true if this Mandate object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Mandate mandate = (Mandate) o; + return Objects.equals(this.balanceAccountId, mandate.balanceAccountId) + && Objects.equals(this.counterparty, mandate.counterparty) + && Objects.equals(this.createdAt, mandate.createdAt) + && Objects.equals(this.id, mandate.id) + && Objects.equals(this.paymentInstrumentId, mandate.paymentInstrumentId) + && Objects.equals(this.status, mandate.status) + && Objects.equals(this.type, mandate.type) + && Objects.equals(this.updatedAt, mandate.updatedAt); + } + + @Override + public int hashCode() { + return Objects.hash( + balanceAccountId, + counterparty, + createdAt, + id, + paymentInstrumentId, + status, + type, + updatedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Mandate {\n"); + sb.append(" balanceAccountId: ").append(toIndentedString(balanceAccountId)).append("\n"); + sb.append(" counterparty: ").append(toIndentedString(counterparty)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" paymentInstrumentId: ") + .append(toIndentedString(paymentInstrumentId)) + .append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).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 Mandate given an JSON string + * + * @param jsonString JSON string + * @return An instance of Mandate + * @throws JsonProcessingException if the JSON string is invalid with respect to Mandate + */ + public static Mandate fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Mandate.class); + } + + /** + * Convert an instance of Mandate 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/MandateBankAccount.java b/src/main/java/com/adyen/model/configurationwebhooks/MandateBankAccount.java new file mode 100644 index 000000000..045dca480 --- /dev/null +++ b/src/main/java/com/adyen/model/configurationwebhooks/MandateBankAccount.java @@ -0,0 +1,163 @@ +/* + * 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.*; + +/** MandateBankAccount */ +@JsonPropertyOrder({ + MandateBankAccount.JSON_PROPERTY_ACCOUNT_HOLDER, + MandateBankAccount.JSON_PROPERTY_ACCOUNT_IDENTIFICATION +}) +public class MandateBankAccount { + public static final String JSON_PROPERTY_ACCOUNT_HOLDER = "accountHolder"; + private MandatePartyIdentification accountHolder; + + public static final String JSON_PROPERTY_ACCOUNT_IDENTIFICATION = "accountIdentification"; + private MandateBankAccountAccountIdentification accountIdentification; + + public MandateBankAccount() {} + + /** + * accountHolder + * + * @param accountHolder + * @return the current {@code MandateBankAccount} instance, allowing for method chaining + */ + public MandateBankAccount accountHolder(MandatePartyIdentification accountHolder) { + this.accountHolder = accountHolder; + return this; + } + + /** + * Get accountHolder + * + * @return accountHolder + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MandatePartyIdentification getAccountHolder() { + return accountHolder; + } + + /** + * accountHolder + * + * @param accountHolder + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAccountHolder(MandatePartyIdentification accountHolder) { + this.accountHolder = accountHolder; + } + + /** + * accountIdentification + * + * @param accountIdentification + * @return the current {@code MandateBankAccount} instance, allowing for method chaining + */ + public MandateBankAccount accountIdentification( + MandateBankAccountAccountIdentification accountIdentification) { + this.accountIdentification = accountIdentification; + return this; + } + + /** + * Get accountIdentification + * + * @return accountIdentification + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_IDENTIFICATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MandateBankAccountAccountIdentification getAccountIdentification() { + return accountIdentification; + } + + /** + * accountIdentification + * + * @param accountIdentification + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_IDENTIFICATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAccountIdentification( + MandateBankAccountAccountIdentification accountIdentification) { + this.accountIdentification = accountIdentification; + } + + /** Return true if this MandateBankAccount object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MandateBankAccount mandateBankAccount = (MandateBankAccount) o; + return Objects.equals(this.accountHolder, mandateBankAccount.accountHolder) + && Objects.equals(this.accountIdentification, mandateBankAccount.accountIdentification); + } + + @Override + public int hashCode() { + return Objects.hash(accountHolder, accountIdentification); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MandateBankAccount {\n"); + sb.append(" accountHolder: ").append(toIndentedString(accountHolder)).append("\n"); + sb.append(" accountIdentification: ") + .append(toIndentedString(accountIdentification)) + .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 MandateBankAccount given an JSON string + * + * @param jsonString JSON string + * @return An instance of MandateBankAccount + * @throws JsonProcessingException if the JSON string is invalid with respect to + * MandateBankAccount + */ + public static MandateBankAccount fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, MandateBankAccount.class); + } + + /** + * Convert an instance of MandateBankAccount 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/MandateBankAccountAccountIdentification.java b/src/main/java/com/adyen/model/configurationwebhooks/MandateBankAccountAccountIdentification.java new file mode 100644 index 000000000..4a1ffca1a --- /dev/null +++ b/src/main/java/com/adyen/model/configurationwebhooks/MandateBankAccountAccountIdentification.java @@ -0,0 +1,223 @@ +/* + * 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.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.logging.Level; +import java.util.logging.Logger; + +@JsonDeserialize( + using = + MandateBankAccountAccountIdentification.MandateBankAccountAccountIdentificationDeserializer + .class) +@JsonSerialize( + using = + MandateBankAccountAccountIdentification.MandateBankAccountAccountIdentificationSerializer + .class) +public class MandateBankAccountAccountIdentification extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(MandateBankAccountAccountIdentification.class.getName()); + + public static class MandateBankAccountAccountIdentificationSerializer + extends StdSerializer { + public MandateBankAccountAccountIdentificationSerializer( + Class t) { + super(t); + } + + public MandateBankAccountAccountIdentificationSerializer() { + this(null); + } + + @Override + public void serialize( + MandateBankAccountAccountIdentification value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class MandateBankAccountAccountIdentificationDeserializer + extends StdDeserializer { + public MandateBankAccountAccountIdentificationDeserializer() { + this(MandateBankAccountAccountIdentification.class); + } + + public MandateBankAccountAccountIdentificationDeserializer(Class vc) { + super(vc); + } + + @Override + public MandateBankAccountAccountIdentification deserialize( + JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize UKLocalMandateAccountIdentification + try { + boolean attemptParsing = true; + if (attemptParsing) { + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = false; + if (tree.findValue("type") != null) { + typeMatch = + Arrays.stream(UKLocalMandateAccountIdentification.TypeEnum.values()) + .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText())); + } + + if (typeMatch) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(UKLocalMandateAccountIdentification.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'UKLocalMandateAccountIdentification'"); + } + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'UKLocalMandateAccountIdentification'", + e); + } + + if (match == 1) { + MandateBankAccountAccountIdentification ret = new MandateBankAccountAccountIdentification(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for MandateBankAccountAccountIdentification: %d classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public MandateBankAccountAccountIdentification getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "MandateBankAccountAccountIdentification cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public MandateBankAccountAccountIdentification() { + super("oneOf", Boolean.FALSE); + } + + public MandateBankAccountAccountIdentification(UKLocalMandateAccountIdentification o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put( + "UKLocalMandateAccountIdentification", + new GenericType() {}); + JSON.registerDescendants( + MandateBankAccountAccountIdentification.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return MandateBankAccountAccountIdentification.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: UKLocalMandateAccountIdentification + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(UKLocalMandateAccountIdentification.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be UKLocalMandateAccountIdentification"); + } + + /** + * Get the actual instance, which can be the following: UKLocalMandateAccountIdentification + * + * @return The actual instance (UKLocalMandateAccountIdentification) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `UKLocalMandateAccountIdentification`. If the actual instance is not + * `UKLocalMandateAccountIdentification`, the ClassCastException will be thrown. + * + * @return The actual instance of `UKLocalMandateAccountIdentification` + * @throws ClassCastException if the instance is not `UKLocalMandateAccountIdentification` + */ + public UKLocalMandateAccountIdentification getUKLocalMandateAccountIdentification() + throws ClassCastException { + return (UKLocalMandateAccountIdentification) super.getActualInstance(); + } + + /** + * Create an instance of MandateBankAccountAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of MandateBankAccountAccountIdentification + * @throws IOException if the JSON string is invalid with respect to + * MandateBankAccountAccountIdentification + */ + public static MandateBankAccountAccountIdentification fromJson(String jsonString) + throws IOException { + return JSON.getMapper().readValue(jsonString, MandateBankAccountAccountIdentification.class); + } + + /** + * Convert an instance of MandateBankAccountAccountIdentification 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/MandateNotificationData.java b/src/main/java/com/adyen/model/configurationwebhooks/MandateNotificationData.java new file mode 100644 index 000000000..bd9356d43 --- /dev/null +++ b/src/main/java/com/adyen/model/configurationwebhooks/MandateNotificationData.java @@ -0,0 +1,159 @@ +/* + * 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.*; + +/** MandateNotificationData */ +@JsonPropertyOrder({ + MandateNotificationData.JSON_PROPERTY_BALANCE_PLATFORM, + MandateNotificationData.JSON_PROPERTY_MANDATE +}) +public class MandateNotificationData { + public static final String JSON_PROPERTY_BALANCE_PLATFORM = "balancePlatform"; + private String balancePlatform; + + public static final String JSON_PROPERTY_MANDATE = "mandate"; + private Mandate mandate; + + public MandateNotificationData() {} + + /** + * The unique identifier of the balance platform. + * + * @param balancePlatform The unique identifier of the balance platform. + * @return the current {@code MandateNotificationData} instance, allowing for method chaining + */ + public MandateNotificationData 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; + } + + /** + * mandate + * + * @param mandate + * @return the current {@code MandateNotificationData} instance, allowing for method chaining + */ + public MandateNotificationData mandate(Mandate mandate) { + this.mandate = mandate; + return this; + } + + /** + * Get mandate + * + * @return mandate + */ + @JsonProperty(JSON_PROPERTY_MANDATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Mandate getMandate() { + return mandate; + } + + /** + * mandate + * + * @param mandate + */ + @JsonProperty(JSON_PROPERTY_MANDATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMandate(Mandate mandate) { + this.mandate = mandate; + } + + /** Return true if this MandateNotificationData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MandateNotificationData mandateNotificationData = (MandateNotificationData) o; + return Objects.equals(this.balancePlatform, mandateNotificationData.balancePlatform) + && Objects.equals(this.mandate, mandateNotificationData.mandate); + } + + @Override + public int hashCode() { + return Objects.hash(balancePlatform, mandate); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MandateNotificationData {\n"); + sb.append(" balancePlatform: ").append(toIndentedString(balancePlatform)).append("\n"); + sb.append(" mandate: ").append(toIndentedString(mandate)).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 MandateNotificationData given an JSON string + * + * @param jsonString JSON string + * @return An instance of MandateNotificationData + * @throws JsonProcessingException if the JSON string is invalid with respect to + * MandateNotificationData + */ + public static MandateNotificationData fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, MandateNotificationData.class); + } + + /** + * Convert an instance of MandateNotificationData 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/MandateNotificationRequest.java b/src/main/java/com/adyen/model/configurationwebhooks/MandateNotificationRequest.java new file mode 100644 index 000000000..2dd43a5fb --- /dev/null +++ b/src/main/java/com/adyen/model/configurationwebhooks/MandateNotificationRequest.java @@ -0,0 +1,287 @@ +/* + * 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; + +/** MandateNotificationRequest */ +@JsonPropertyOrder({ + MandateNotificationRequest.JSON_PROPERTY_DATA, + MandateNotificationRequest.JSON_PROPERTY_ENVIRONMENT, + MandateNotificationRequest.JSON_PROPERTY_TIMESTAMP, + MandateNotificationRequest.JSON_PROPERTY_TYPE +}) +public class MandateNotificationRequest { + public static final String JSON_PROPERTY_DATA = "data"; + private MandateNotificationData 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_MANDATE_CREATED(String.valueOf("balancePlatform.mandate.created")), + + BALANCEPLATFORM_MANDATE_UPDATED(String.valueOf("balancePlatform.mandate.updated")); + + 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 MandateNotificationRequest() {} + + /** + * data + * + * @param data + * @return the current {@code MandateNotificationRequest} instance, allowing for method chaining + */ + public MandateNotificationRequest data(MandateNotificationData data) { + this.data = data; + return this; + } + + /** + * Get data + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MandateNotificationData getData() { + return data; + } + + /** + * data + * + * @param data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setData(MandateNotificationData 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 MandateNotificationRequest} instance, allowing for method chaining + */ + public MandateNotificationRequest 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 MandateNotificationRequest} instance, allowing for method chaining + */ + public MandateNotificationRequest 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 MandateNotificationRequest} instance, allowing for method chaining + */ + public MandateNotificationRequest 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 MandateNotificationRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MandateNotificationRequest mandateNotificationRequest = (MandateNotificationRequest) o; + return Objects.equals(this.data, mandateNotificationRequest.data) + && Objects.equals(this.environment, mandateNotificationRequest.environment) + && Objects.equals(this.timestamp, mandateNotificationRequest.timestamp) + && Objects.equals(this.type, mandateNotificationRequest.type); + } + + @Override + public int hashCode() { + return Objects.hash(data, environment, timestamp, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MandateNotificationRequest {\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 MandateNotificationRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of MandateNotificationRequest + * @throws JsonProcessingException if the JSON string is invalid with respect to + * MandateNotificationRequest + */ + public static MandateNotificationRequest fromJson(String jsonString) + throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, MandateNotificationRequest.class); + } + + /** + * Convert an instance of MandateNotificationRequest 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/MandatePartyIdentification.java b/src/main/java/com/adyen/model/configurationwebhooks/MandatePartyIdentification.java new file mode 100644 index 000000000..8441041f7 --- /dev/null +++ b/src/main/java/com/adyen/model/configurationwebhooks/MandatePartyIdentification.java @@ -0,0 +1,125 @@ +/* + * 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.*; + +/** MandatePartyIdentification */ +@JsonPropertyOrder({MandatePartyIdentification.JSON_PROPERTY_FULL_NAME}) +public class MandatePartyIdentification { + public static final String JSON_PROPERTY_FULL_NAME = "fullName"; + private String fullName; + + public MandatePartyIdentification() {} + + /** + * The full name of the entity that owns the bank account. Supported characters: [a-z] [A-Z] [0-9] + * , . ; : - — / \\ + & ! ? @ ( ) \" ' and space. + * + * @param fullName The full name of the entity that owns the bank account. Supported characters: + * [a-z] [A-Z] [0-9] , . ; : - — / \\ + & ! ? @ ( ) \" ' and space. + * @return the current {@code MandatePartyIdentification} instance, allowing for method chaining + */ + public MandatePartyIdentification fullName(String fullName) { + this.fullName = fullName; + return this; + } + + /** + * The full name of the entity that owns the bank account. Supported characters: [a-z] [A-Z] [0-9] + * , . ; : - — / \\ + & ! ? @ ( ) \" ' and space. + * + * @return fullName The full name of the entity that owns the bank account. Supported characters: + * [a-z] [A-Z] [0-9] , . ; : - — / \\ + & ! ? @ ( ) \" ' and space. + */ + @JsonProperty(JSON_PROPERTY_FULL_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFullName() { + return fullName; + } + + /** + * The full name of the entity that owns the bank account. Supported characters: [a-z] [A-Z] [0-9] + * , . ; : - — / \\ + & ! ? @ ( ) \" ' and space. + * + * @param fullName The full name of the entity that owns the bank account. Supported characters: + * [a-z] [A-Z] [0-9] , . ; : - — / \\ + & ! ? @ ( ) \" ' and space. + */ + @JsonProperty(JSON_PROPERTY_FULL_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFullName(String fullName) { + this.fullName = fullName; + } + + /** Return true if this MandatePartyIdentification object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MandatePartyIdentification mandatePartyIdentification = (MandatePartyIdentification) o; + return Objects.equals(this.fullName, mandatePartyIdentification.fullName); + } + + @Override + public int hashCode() { + return Objects.hash(fullName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MandatePartyIdentification {\n"); + sb.append(" fullName: ").append(toIndentedString(fullName)).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 MandatePartyIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of MandatePartyIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to + * MandatePartyIdentification + */ + public static MandatePartyIdentification fromJson(String jsonString) + throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, MandatePartyIdentification.class); + } + + /** + * Convert an instance of MandatePartyIdentification 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/PlatformPaymentConfiguration.java b/src/main/java/com/adyen/model/configurationwebhooks/PlatformPaymentConfiguration.java index 376a23994..3fb41e70d 100644 --- a/src/main/java/com/adyen/model/configurationwebhooks/PlatformPaymentConfiguration.java +++ b/src/main/java/com/adyen/model/configurationwebhooks/PlatformPaymentConfiguration.java @@ -78,11 +78,14 @@ public void setSalesDayClosingTime(String salesDayClosingTime) { /** * Specifies after how many business days the funds in a settlement batch are made available in - * this balance account. Possible values: **1** to **20**, or **null**. Default value: **null**. + * this balance account. Requires Custom Sales Day Payout to be enabled for your balance account. + * Contact your account manager or implementation manager to enable this. Possible values: **1** + * to **20**, or **null**. Default value: **null**. * * @param settlementDelayDays Specifies after how many business days the funds in a settlement - * batch are made available in this balance account. Possible values: **1** to **20**, or - * **null**. Default value: **null**. + * batch are made available in this balance account. Requires Custom Sales Day Payout to be + * enabled for your balance account. Contact your account manager or implementation manager to + * enable this. Possible values: **1** to **20**, or **null**. Default value: **null**. * @return the current {@code PlatformPaymentConfiguration} instance, allowing for method chaining */ public PlatformPaymentConfiguration settlementDelayDays(Integer settlementDelayDays) { @@ -92,11 +95,14 @@ public PlatformPaymentConfiguration settlementDelayDays(Integer settlementDelayD /** * Specifies after how many business days the funds in a settlement batch are made available in - * this balance account. Possible values: **1** to **20**, or **null**. Default value: **null**. + * this balance account. Requires Custom Sales Day Payout to be enabled for your balance account. + * Contact your account manager or implementation manager to enable this. Possible values: **1** + * to **20**, or **null**. Default value: **null**. * * @return settlementDelayDays Specifies after how many business days the funds in a settlement - * batch are made available in this balance account. Possible values: **1** to **20**, or - * **null**. Default value: **null**. + * batch are made available in this balance account. Requires Custom Sales Day Payout to be + * enabled for your balance account. Contact your account manager or implementation manager to + * enable this. Possible values: **1** to **20**, or **null**. Default value: **null**. */ @JsonProperty(JSON_PROPERTY_SETTLEMENT_DELAY_DAYS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -106,11 +112,14 @@ public Integer getSettlementDelayDays() { /** * Specifies after how many business days the funds in a settlement batch are made available in - * this balance account. Possible values: **1** to **20**, or **null**. Default value: **null**. + * this balance account. Requires Custom Sales Day Payout to be enabled for your balance account. + * Contact your account manager or implementation manager to enable this. Possible values: **1** + * to **20**, or **null**. Default value: **null**. * * @param settlementDelayDays Specifies after how many business days the funds in a settlement - * batch are made available in this balance account. Possible values: **1** to **20**, or - * **null**. Default value: **null**. + * batch are made available in this balance account. Requires Custom Sales Day Payout to be + * enabled for your balance account. Contact your account manager or implementation manager to + * enable this. Possible values: **1** to **20**, or **null**. Default value: **null**. */ @JsonProperty(JSON_PROPERTY_SETTLEMENT_DELAY_DAYS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/src/main/java/com/adyen/model/configurationwebhooks/UKLocalMandateAccountIdentification.java b/src/main/java/com/adyen/model/configurationwebhooks/UKLocalMandateAccountIdentification.java new file mode 100644 index 000000000..b1ffc579a --- /dev/null +++ b/src/main/java/com/adyen/model/configurationwebhooks/UKLocalMandateAccountIdentification.java @@ -0,0 +1,252 @@ +/* + * 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.util.*; +import java.util.Arrays; +import java.util.logging.Logger; + +/** UKLocalMandateAccountIdentification */ +@JsonPropertyOrder({ + UKLocalMandateAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + UKLocalMandateAccountIdentification.JSON_PROPERTY_SORT_CODE, + UKLocalMandateAccountIdentification.JSON_PROPERTY_TYPE +}) +public class UKLocalMandateAccountIdentification { + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; + private String accountNumber; + + public static final String JSON_PROPERTY_SORT_CODE = "sortCode"; + private String sortCode; + + /** **ukLocal** */ + public enum TypeEnum { + UKLOCAL(String.valueOf("ukLocal")); + + 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 UKLocalMandateAccountIdentification() {} + + /** + * The 8-digit bank account number, without separators or whitespace. + * + * @param accountNumber The 8-digit bank account number, without separators or whitespace. + * @return the current {@code UKLocalMandateAccountIdentification} instance, allowing for method + * chaining + */ + public UKLocalMandateAccountIdentification accountNumber(String accountNumber) { + this.accountNumber = accountNumber; + return this; + } + + /** + * The 8-digit bank account number, without separators or whitespace. + * + * @return accountNumber The 8-digit bank account number, without separators or whitespace. + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAccountNumber() { + return accountNumber; + } + + /** + * The 8-digit bank account number, without separators or whitespace. + * + * @param accountNumber The 8-digit bank account number, without separators or whitespace. + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + /** + * The 6-digit [sort code](https://en.wikipedia.org/wiki/Sort_code), without separators or + * whitespace. + * + * @param sortCode The 6-digit [sort code](https://en.wikipedia.org/wiki/Sort_code), without + * separators or whitespace. + * @return the current {@code UKLocalMandateAccountIdentification} instance, allowing for method + * chaining + */ + public UKLocalMandateAccountIdentification sortCode(String sortCode) { + this.sortCode = sortCode; + return this; + } + + /** + * The 6-digit [sort code](https://en.wikipedia.org/wiki/Sort_code), without separators or + * whitespace. + * + * @return sortCode The 6-digit [sort code](https://en.wikipedia.org/wiki/Sort_code), without + * separators or whitespace. + */ + @JsonProperty(JSON_PROPERTY_SORT_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSortCode() { + return sortCode; + } + + /** + * The 6-digit [sort code](https://en.wikipedia.org/wiki/Sort_code), without separators or + * whitespace. + * + * @param sortCode The 6-digit [sort code](https://en.wikipedia.org/wiki/Sort_code), without + * separators or whitespace. + */ + @JsonProperty(JSON_PROPERTY_SORT_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSortCode(String sortCode) { + this.sortCode = sortCode; + } + + /** + * **ukLocal** + * + * @param type **ukLocal** + * @return the current {@code UKLocalMandateAccountIdentification} instance, allowing for method + * chaining + */ + public UKLocalMandateAccountIdentification type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * **ukLocal** + * + * @return type **ukLocal** + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TypeEnum getType() { + return type; + } + + /** + * **ukLocal** + * + * @param type **ukLocal** + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + /** Return true if this UKLocalMandateAccountIdentification object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UKLocalMandateAccountIdentification ukLocalMandateAccountIdentification = + (UKLocalMandateAccountIdentification) o; + return Objects.equals(this.accountNumber, ukLocalMandateAccountIdentification.accountNumber) + && Objects.equals(this.sortCode, ukLocalMandateAccountIdentification.sortCode) + && Objects.equals(this.type, ukLocalMandateAccountIdentification.type); + } + + @Override + public int hashCode() { + return Objects.hash(accountNumber, sortCode, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UKLocalMandateAccountIdentification {\n"); + sb.append(" accountNumber: ").append(toIndentedString(accountNumber)).append("\n"); + sb.append(" sortCode: ").append(toIndentedString(sortCode)).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 UKLocalMandateAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of UKLocalMandateAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to + * UKLocalMandateAccountIdentification + */ + public static UKLocalMandateAccountIdentification fromJson(String jsonString) + throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, UKLocalMandateAccountIdentification.class); + } + + /** + * Convert an instance of UKLocalMandateAccountIdentification 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 7fc1771b7..294bedd74 100644 --- a/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java +++ b/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java @@ -513,4 +513,52 @@ public void testScoreNotificationRequest() { assertEquals("ChargebackCardholderDispute", data.getScoreSignalsTriggered().get(0)); assertEquals("ChargebackNonReceipt", data.getScoreSignalsTriggered().get(1)); } + + @Test + public void testMandateCreatedNotificationRequest() { + String json = + getFileContents("mocks/balancePlatform-webhooks/configuration-mandate-created.json"); + + ConfigurationWebhooksHandler handler = new ConfigurationWebhooksHandler(json); + Optional optionalRequest = handler.getMandateNotificationRequest(); + + assertTrue(optionalRequest.isPresent()); + + MandateNotificationRequest request = optionalRequest.get(); + assertEquals( + MandateNotificationRequest.TypeEnum.BALANCEPLATFORM_MANDATE_CREATED, request.getType()); + assertEquals("test", request.getEnvironment()); + assertNotNull(request.getTimestamp()); + + assertNotNull(request.getData()); + assertEquals("YOUR_BALANCE_PLATFORM", request.getData().getBalancePlatform()); + + assertNotNull(request.getData().getMandate()); + assertEquals("MNDT000000000000000000000001", request.getData().getMandate().getId()); + assertEquals( + "BA000000000000000000000001", request.getData().getMandate().getBalanceAccountId()); + assertEquals( + "PI000000000000000000000001", request.getData().getMandate().getPaymentInstrumentId()); + assertEquals(Mandate.StatusEnum.APPROVED, request.getData().getMandate().getStatus()); + assertEquals(Mandate.TypeEnum.BACS, request.getData().getMandate().getType()); + + assertNotNull(request.getData().getMandate().getCounterparty()); + assertNotNull(request.getData().getMandate().getCounterparty().getAccountHolder()); + assertEquals( + "Albert Klassens", + request.getData().getMandate().getCounterparty().getAccountHolder().getFullName()); + + assertNotNull(request.getData().getMandate().getCounterparty().getAccountIdentification()); + UKLocalMandateAccountIdentification ukLocalAccountId = + request + .getData() + .getMandate() + .getCounterparty() + .getAccountIdentification() + .getUKLocalMandateAccountIdentification(); + assertNotNull(ukLocalAccountId); + assertEquals("10809699", ukLocalAccountId.getAccountNumber()); + assertEquals("405081", ukLocalAccountId.getSortCode()); + assertEquals(UKLocalMandateAccountIdentification.TypeEnum.UKLOCAL, ukLocalAccountId.getType()); + } } diff --git a/src/test/resources/mocks/balancePlatform-webhooks/configuration-mandate-created.json b/src/test/resources/mocks/balancePlatform-webhooks/configuration-mandate-created.json new file mode 100644 index 000000000..ab558dfd0 --- /dev/null +++ b/src/test/resources/mocks/balancePlatform-webhooks/configuration-mandate-created.json @@ -0,0 +1,27 @@ +{ + "data": { + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "mandate": { + "balanceAccountId": "BA000000000000000000000001", + "counterparty": { + "accountHolder": { + "fullName": "Albert Klassens" + }, + "accountIdentification": { + "accountNumber": "10809699", + "sortCode": "405081", + "type": "ukLocal" + } + }, + "createdAt": "2025-09-04T13:40:41.581Z", + "id": "MNDT000000000000000000000001", + "paymentInstrumentId": "PI000000000000000000000001", + "status": "approved", + "type": "bacs", + "updatedAt": "2025-09-04T13:40:41.581Z" + } + }, + "environment": "test", + "type": "balancePlatform.mandate.created", + "timestamp": "2025-09-04T13:40:41+02:00" +}