diff --git a/sdk-generation-log/transferwebhooks.json b/sdk-generation-log/transferwebhooks.json index fe1b79144..60614dfe7 100644 --- a/sdk-generation-log/transferwebhooks.json +++ b/sdk-generation-log/transferwebhooks.json @@ -1,8 +1,8 @@ { "service": "transferwebhooks", "project": "java", - "generatedAt": "2026-06-01T09:45:24Z", - "openapiCommitSha": "c0822241f611e20376f72b279f2b3e67dea27a43", - "automationCommitSha": "6f06b47d0661f0891defe6b85461d2c367fbd284", - "libraryCommitSha": "b2ec3b93864e9e4a5548fa7e77fccd50da77ec2f" + "generatedAt": "2026-07-16T07:19:10Z", + "openapiCommitSha": "8ca5e35a2df8646fbed1793daeba735ebfcb821b", + "automationCommitSha": "a7fa5d57782b5065affe714e9d9caaf5009a1e24", + "libraryCommitSha": "503dcc66e435ded29884875f6a5bda4590cecb95" } diff --git a/src/main/java/com/adyen/model/transferwebhooks/BankAccountV3AccountIdentification.java b/src/main/java/com/adyen/model/transferwebhooks/BankAccountV3AccountIdentification.java index 8b8a56abf..e19901b50 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/BankAccountV3AccountIdentification.java +++ b/src/main/java/com/adyen/model/transferwebhooks/BankAccountV3AccountIdentification.java @@ -639,6 +639,42 @@ public BankAccountV3AccountIdentification(USLocalAccountIdentification o) { schemas.put("USLocalAccountIdentification", new GenericType() {}); JSON.registerDescendants( BankAccountV3AccountIdentification.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap<>(); + mappings.put("auLocal", AULocalAccountIdentification.class); + mappings.put("brLocal", BRLocalAccountIdentification.class); + mappings.put("caLocal", CALocalAccountIdentification.class); + mappings.put("czLocal", CZLocalAccountIdentification.class); + mappings.put("dkLocal", DKLocalAccountIdentification.class); + mappings.put("hkLocal", HKLocalAccountIdentification.class); + mappings.put("huLocal", HULocalAccountIdentification.class); + mappings.put("iban", IbanAccountIdentification.class); + mappings.put("noLocal", NOLocalAccountIdentification.class); + mappings.put("numberAndBic", NumberAndBicAccountIdentification.class); + mappings.put("nzLocal", NZLocalAccountIdentification.class); + mappings.put("plLocal", PLLocalAccountIdentification.class); + mappings.put("seLocal", SELocalAccountIdentification.class); + mappings.put("sgLocal", SGLocalAccountIdentification.class); + mappings.put("ukLocal", UKLocalAccountIdentification.class); + mappings.put("usLocal", USLocalAccountIdentification.class); + mappings.put("AULocalAccountIdentification", AULocalAccountIdentification.class); + mappings.put("BRLocalAccountIdentification", BRLocalAccountIdentification.class); + mappings.put("CALocalAccountIdentification", CALocalAccountIdentification.class); + mappings.put("CZLocalAccountIdentification", CZLocalAccountIdentification.class); + mappings.put("DKLocalAccountIdentification", DKLocalAccountIdentification.class); + mappings.put("HKLocalAccountIdentification", HKLocalAccountIdentification.class); + mappings.put("HULocalAccountIdentification", HULocalAccountIdentification.class); + mappings.put("IbanAccountIdentification", IbanAccountIdentification.class); + mappings.put("NOLocalAccountIdentification", NOLocalAccountIdentification.class); + mappings.put("NZLocalAccountIdentification", NZLocalAccountIdentification.class); + mappings.put("NumberAndBicAccountIdentification", NumberAndBicAccountIdentification.class); + mappings.put("PLLocalAccountIdentification", PLLocalAccountIdentification.class); + mappings.put("SELocalAccountIdentification", SELocalAccountIdentification.class); + mappings.put("SGLocalAccountIdentification", SGLocalAccountIdentification.class); + mappings.put("UKLocalAccountIdentification", UKLocalAccountIdentification.class); + mappings.put("USLocalAccountIdentification", USLocalAccountIdentification.class); + mappings.put("BankAccountV3_accountIdentification", BankAccountV3AccountIdentification.class); + JSON.registerDiscriminator(BankAccountV3AccountIdentification.class, "type", mappings); } @Override diff --git a/src/main/java/com/adyen/model/transferwebhooks/NetworkReason.java b/src/main/java/com/adyen/model/transferwebhooks/NetworkReason.java new file mode 100644 index 000000000..12882907f --- /dev/null +++ b/src/main/java/com/adyen/model/transferwebhooks/NetworkReason.java @@ -0,0 +1,258 @@ +/* + * Transfer webhooks + * + * The version of the OpenAPI document: 4 + * + * + * 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.transferwebhooks; + +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; + +/** NetworkReason */ +@JsonPropertyOrder({ + NetworkReason.JSON_PROPERTY_CODE, + NetworkReason.JSON_PROPERTY_DESCRIPTION, + NetworkReason.JSON_PROPERTY_NAMESPACE +}) +public class NetworkReason { + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public static final String JSON_PROPERTY_DESCRIPTION = "description"; + private String description; + + /** + * The namespace that corresponds to the reason code. Possible values: * **ukFpsRejectionCode** * + * **ukFpsReturnReasonCode** * **usAchReturnReasonCode** * **iso8583ResponseCode** + */ + public enum NamespaceEnum { + ISO8583RESPONSECODE(String.valueOf("iso8583ResponseCode")), + + UKFPSREJECTIONCODE(String.valueOf("ukFpsRejectionCode")), + + UKFPSRETURNREASONCODE(String.valueOf("ukFpsReturnReasonCode")), + + USACHRETURNREASONCODE(String.valueOf("usAchReturnReasonCode")); + + private static final Logger LOG = Logger.getLogger(NamespaceEnum.class.getName()); + + private String value; + + NamespaceEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static NamespaceEnum fromValue(String value) { + for (NamespaceEnum b : NamespaceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + // handling unexpected value + LOG.warning( + "NamespaceEnum: unexpected enum value '" + + value + + "' - Supported values are " + + Arrays.toString(NamespaceEnum.values())); + return null; + } + } + + public static final String JSON_PROPERTY_NAMESPACE = "namespace"; + private NamespaceEnum namespace; + + public NetworkReason() {} + + /** + * The reason code provided by the network. + * + * @param code The reason code provided by the network. + * @return the current {@code NetworkReason} instance, allowing for method chaining + */ + public NetworkReason code(String code) { + this.code = code; + return this; + } + + /** + * The reason code provided by the network. + * + * @return code The reason code provided by the network. + */ + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCode() { + return code; + } + + /** + * The reason code provided by the network. + * + * @param code The reason code provided by the network. + */ + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(String code) { + this.code = code; + } + + /** + * The description of the reason code. + * + * @param description The description of the reason code. + * @return the current {@code NetworkReason} instance, allowing for method chaining + */ + public NetworkReason description(String description) { + this.description = description; + return this; + } + + /** + * The description of the reason code. + * + * @return description The description of the reason code. + */ + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDescription() { + return description; + } + + /** + * The description of the reason code. + * + * @param description The description of the reason code. + */ + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDescription(String description) { + this.description = description; + } + + /** + * The namespace that corresponds to the reason code. Possible values: * **ukFpsRejectionCode** * + * **ukFpsReturnReasonCode** * **usAchReturnReasonCode** * **iso8583ResponseCode** + * + * @param namespace The namespace that corresponds to the reason code. Possible values: * + * **ukFpsRejectionCode** * **ukFpsReturnReasonCode** * **usAchReturnReasonCode** * + * **iso8583ResponseCode** + * @return the current {@code NetworkReason} instance, allowing for method chaining + */ + public NetworkReason namespace(NamespaceEnum namespace) { + this.namespace = namespace; + return this; + } + + /** + * The namespace that corresponds to the reason code. Possible values: * **ukFpsRejectionCode** * + * **ukFpsReturnReasonCode** * **usAchReturnReasonCode** * **iso8583ResponseCode** + * + * @return namespace The namespace that corresponds to the reason code. Possible values: * + * **ukFpsRejectionCode** * **ukFpsReturnReasonCode** * **usAchReturnReasonCode** * + * **iso8583ResponseCode** + */ + @JsonProperty(JSON_PROPERTY_NAMESPACE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NamespaceEnum getNamespace() { + return namespace; + } + + /** + * The namespace that corresponds to the reason code. Possible values: * **ukFpsRejectionCode** * + * **ukFpsReturnReasonCode** * **usAchReturnReasonCode** * **iso8583ResponseCode** + * + * @param namespace The namespace that corresponds to the reason code. Possible values: * + * **ukFpsRejectionCode** * **ukFpsReturnReasonCode** * **usAchReturnReasonCode** * + * **iso8583ResponseCode** + */ + @JsonProperty(JSON_PROPERTY_NAMESPACE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNamespace(NamespaceEnum namespace) { + this.namespace = namespace; + } + + /** Return true if this NetworkReason object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkReason networkReason = (NetworkReason) o; + return Objects.equals(this.code, networkReason.code) + && Objects.equals(this.description, networkReason.description) + && Objects.equals(this.namespace, networkReason.namespace); + } + + @Override + public int hashCode() { + return Objects.hash(code, description, namespace); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NetworkReason {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" namespace: ").append(toIndentedString(namespace)).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 NetworkReason given an JSON string + * + * @param jsonString JSON string + * @return An instance of NetworkReason + * @throws JsonProcessingException if the JSON string is invalid with respect to NetworkReason + */ + public static NetworkReason fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, NetworkReason.class); + } + + /** + * Convert an instance of NetworkReason 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/transferwebhooks/TransferData.java b/src/main/java/com/adyen/model/transferwebhooks/TransferData.java index 534e554cd..e900f1690 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/TransferData.java +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferData.java @@ -44,6 +44,7 @@ TransferData.JSON_PROPERTY_EXECUTION_DATE, TransferData.JSON_PROPERTY_EXTERNAL_REASON, TransferData.JSON_PROPERTY_ID, + TransferData.JSON_PROPERTY_NETWORK_REASON, TransferData.JSON_PROPERTY_PAYMENT_INSTRUMENT, TransferData.JSON_PROPERTY_REASON, TransferData.JSON_PROPERTY_REFERENCE, @@ -51,6 +52,7 @@ TransferData.JSON_PROPERTY_REVIEW, TransferData.JSON_PROPERTY_SEQUENCE_NUMBER, TransferData.JSON_PROPERTY_STATUS, + TransferData.JSON_PROPERTY_TRACING, TransferData.JSON_PROPERTY_TRACKING, TransferData.JSON_PROPERTY_TRANSACTION_RULES_RESULT, TransferData.JSON_PROPERTY_TYPE, @@ -212,6 +214,9 @@ public static DirectionEnum fromValue(String value) { public static final String JSON_PROPERTY_ID = "id"; private String id; + public static final String JSON_PROPERTY_NETWORK_REASON = "networkReason"; + private NetworkReason networkReason; + public static final String JSON_PROPERTY_PAYMENT_INSTRUMENT = "paymentInstrument"; private PaymentInstrument paymentInstrument; @@ -626,6 +631,9 @@ public static StatusEnum fromValue(String value) { public static final String JSON_PROPERTY_STATUS = "status"; private StatusEnum status; + public static final String JSON_PROPERTY_TRACING = "tracing"; + private TransferDataTracing tracing; + public static final String JSON_PROPERTY_TRACKING = "tracking"; private TransferDataTracking tracking; @@ -1462,6 +1470,39 @@ public void setId(String id) { this.id = id; } + /** + * networkReason + * + * @param networkReason + * @return the current {@code TransferData} instance, allowing for method chaining + */ + public TransferData networkReason(NetworkReason networkReason) { + this.networkReason = networkReason; + return this; + } + + /** + * Get networkReason + * + * @return networkReason + */ + @JsonProperty(JSON_PROPERTY_NETWORK_REASON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NetworkReason getNetworkReason() { + return networkReason; + } + + /** + * networkReason + * + * @param networkReason + */ + @JsonProperty(JSON_PROPERTY_NETWORK_REASON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNetworkReason(NetworkReason networkReason) { + this.networkReason = networkReason; + } + /** * paymentInstrument * @@ -1771,6 +1812,39 @@ public void setStatus(StatusEnum status) { this.status = status; } + /** + * tracing + * + * @param tracing + * @return the current {@code TransferData} instance, allowing for method chaining + */ + public TransferData tracing(TransferDataTracing tracing) { + this.tracing = tracing; + return this; + } + + /** + * Get tracing + * + * @return tracing + */ + @JsonProperty(JSON_PROPERTY_TRACING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TransferDataTracing getTracing() { + return tracing; + } + + /** + * tracing + * + * @param tracing + */ + @JsonProperty(JSON_PROPERTY_TRACING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTracing(TransferDataTracing tracing) { + this.tracing = tracing; + } + /** * tracking * @@ -1976,6 +2050,7 @@ public boolean equals(Object o) { && Objects.equals(this.executionDate, transferData.executionDate) && Objects.equals(this.externalReason, transferData.externalReason) && Objects.equals(this.id, transferData.id) + && Objects.equals(this.networkReason, transferData.networkReason) && Objects.equals(this.paymentInstrument, transferData.paymentInstrument) && Objects.equals(this.reason, transferData.reason) && Objects.equals(this.reference, transferData.reference) @@ -1983,6 +2058,7 @@ public boolean equals(Object o) { && Objects.equals(this.review, transferData.review) && Objects.equals(this.sequenceNumber, transferData.sequenceNumber) && Objects.equals(this.status, transferData.status) + && Objects.equals(this.tracing, transferData.tracing) && Objects.equals(this.tracking, transferData.tracking) && Objects.equals(this.transactionRulesResult, transferData.transactionRulesResult) && Objects.equals(this.type, transferData.type) @@ -2011,6 +2087,7 @@ public int hashCode() { executionDate, externalReason, id, + networkReason, paymentInstrument, reason, reference, @@ -2018,6 +2095,7 @@ public int hashCode() { review, sequenceNumber, status, + tracing, tracking, transactionRulesResult, type, @@ -2049,6 +2127,7 @@ public String toString() { sb.append(" executionDate: ").append(toIndentedString(executionDate)).append("\n"); sb.append(" externalReason: ").append(toIndentedString(externalReason)).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" networkReason: ").append(toIndentedString(networkReason)).append("\n"); sb.append(" paymentInstrument: ").append(toIndentedString(paymentInstrument)).append("\n"); sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); sb.append(" reference: ").append(toIndentedString(reference)).append("\n"); @@ -2058,6 +2137,7 @@ public String toString() { sb.append(" review: ").append(toIndentedString(review)).append("\n"); sb.append(" sequenceNumber: ").append(toIndentedString(sequenceNumber)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" tracing: ").append(toIndentedString(tracing)).append("\n"); sb.append(" tracking: ").append(toIndentedString(tracking)).append("\n"); sb.append(" transactionRulesResult: ") .append(toIndentedString(transactionRulesResult)) diff --git a/src/main/java/com/adyen/model/transferwebhooks/TransferDataCategoryData.java b/src/main/java/com/adyen/model/transferwebhooks/TransferDataCategoryData.java index e8dc4fa80..10bd19bc7 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/TransferDataCategoryData.java +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferDataCategoryData.java @@ -230,6 +230,18 @@ public TransferDataCategoryData(PlatformPayment o) { schemas.put("IssuedCard", new GenericType() {}); schemas.put("PlatformPayment", new GenericType() {}); JSON.registerDescendants(TransferDataCategoryData.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap<>(); + mappings.put("bank", BankCategoryData.class); + mappings.put("internal", InternalCategoryData.class); + mappings.put("issuedCard", IssuedCard.class); + mappings.put("platformPayment", PlatformPayment.class); + mappings.put("BankCategoryData", BankCategoryData.class); + mappings.put("InternalCategoryData", InternalCategoryData.class); + mappings.put("IssuedCard", IssuedCard.class); + mappings.put("PlatformPayment", PlatformPayment.class); + mappings.put("TransferData_categoryData", TransferDataCategoryData.class); + JSON.registerDiscriminator(TransferDataCategoryData.class, "type", mappings); } @Override diff --git a/src/main/java/com/adyen/model/transferwebhooks/TransferDataTracing.java b/src/main/java/com/adyen/model/transferwebhooks/TransferDataTracing.java new file mode 100644 index 000000000..b8f7ede96 --- /dev/null +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferDataTracing.java @@ -0,0 +1,255 @@ +/* + * Transfer webhooks + * + * The version of the OpenAPI document: 4 + * + * + * 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.transferwebhooks; + +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 = TransferDataTracing.TransferDataTracingDeserializer.class) +@JsonSerialize(using = TransferDataTracing.TransferDataTracingSerializer.class) +public class TransferDataTracing extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(TransferDataTracing.class.getName()); + + public static class TransferDataTracingSerializer extends StdSerializer { + public TransferDataTracingSerializer(Class t) { + super(t); + } + + public TransferDataTracingSerializer() { + this(null); + } + + @Override + public void serialize( + TransferDataTracing value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class TransferDataTracingDeserializer extends StdDeserializer { + public TransferDataTracingDeserializer() { + this(TransferDataTracing.class); + } + + public TransferDataTracingDeserializer(Class vc) { + super(vc); + } + + @Override + public TransferDataTracing 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 UKFpsTracingData + 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(UKFpsTracingData.TypeEnum.values()) + .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText())); + } + + if (typeMatch) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(UKFpsTracingData.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 'UKFpsTracingData'"); + } + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'UKFpsTracingData'", e); + } + + // deserialize USAchTracingData + 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(USAchTracingData.TypeEnum.values()) + .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText())); + } + + if (typeMatch) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(USAchTracingData.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 'USAchTracingData'"); + } + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'USAchTracingData'", e); + } + + if (match == 1) { + TransferDataTracing ret = new TransferDataTracing(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for TransferDataTracing: %d classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public TransferDataTracing getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "TransferDataTracing cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public TransferDataTracing() { + super("oneOf", Boolean.FALSE); + } + + public TransferDataTracing(UKFpsTracingData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public TransferDataTracing(USAchTracingData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("UKFpsTracingData", new GenericType() {}); + schemas.put("USAchTracingData", new GenericType() {}); + JSON.registerDescendants(TransferDataTracing.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap<>(); + mappings.put("ukFps", UKFpsTracingData.class); + mappings.put("usAch", USAchTracingData.class); + mappings.put("UKFpsTracingData", UKFpsTracingData.class); + mappings.put("USAchTracingData", USAchTracingData.class); + mappings.put("TransferData_tracing", TransferDataTracing.class); + JSON.registerDiscriminator(TransferDataTracing.class, "type", mappings); + } + + @Override + public Map> getSchemas() { + return TransferDataTracing.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: UKFpsTracingData, USAchTracingData + * + *

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(UKFpsTracingData.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(USAchTracingData.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be UKFpsTracingData, USAchTracingData"); + } + + /** + * Get the actual instance, which can be the following: UKFpsTracingData, USAchTracingData + * + * @return The actual instance (UKFpsTracingData, USAchTracingData) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `UKFpsTracingData`. If the actual instance is not + * `UKFpsTracingData`, the ClassCastException will be thrown. + * + * @return The actual instance of `UKFpsTracingData` + * @throws ClassCastException if the instance is not `UKFpsTracingData` + */ + public UKFpsTracingData getUKFpsTracingData() throws ClassCastException { + return (UKFpsTracingData) super.getActualInstance(); + } + + /** + * Get the actual instance of `USAchTracingData`. If the actual instance is not + * `USAchTracingData`, the ClassCastException will be thrown. + * + * @return The actual instance of `USAchTracingData` + * @throws ClassCastException if the instance is not `USAchTracingData` + */ + public USAchTracingData getUSAchTracingData() throws ClassCastException { + return (USAchTracingData) super.getActualInstance(); + } + + /** + * Create an instance of TransferDataTracing given an JSON string + * + * @param jsonString JSON string + * @return An instance of TransferDataTracing + * @throws IOException if the JSON string is invalid with respect to TransferDataTracing + */ + public static TransferDataTracing fromJson(String jsonString) throws IOException { + return JSON.getMapper().readValue(jsonString, TransferDataTracing.class); + } + + /** + * Convert an instance of TransferDataTracing 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/transferwebhooks/TransferDataTracking.java b/src/main/java/com/adyen/model/transferwebhooks/TransferDataTracking.java index 452eb8c73..5d2000f23 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/TransferDataTracking.java +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferDataTracking.java @@ -198,6 +198,16 @@ public TransferDataTracking(InternalReviewTrackingData o) { schemas.put("EstimationTrackingData", new GenericType() {}); schemas.put("InternalReviewTrackingData", new GenericType() {}); JSON.registerDescendants(TransferDataTracking.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap<>(); + mappings.put("confirmation", ConfirmationTrackingData.class); + mappings.put("estimation", EstimationTrackingData.class); + mappings.put("internalReview", InternalReviewTrackingData.class); + mappings.put("ConfirmationTrackingData", ConfirmationTrackingData.class); + mappings.put("EstimationTrackingData", EstimationTrackingData.class); + mappings.put("InternalReviewTrackingData", InternalReviewTrackingData.class); + mappings.put("TransferData_tracking", TransferDataTracking.class); + JSON.registerDiscriminator(TransferDataTracking.class, "type", mappings); } @Override diff --git a/src/main/java/com/adyen/model/transferwebhooks/TransferEvent.java b/src/main/java/com/adyen/model/transferwebhooks/TransferEvent.java index 23da5de7b..a51b4ae98 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/TransferEvent.java +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferEvent.java @@ -39,6 +39,7 @@ TransferEvent.JSON_PROPERTY_ORIGINAL_AMOUNT, TransferEvent.JSON_PROPERTY_REASON, TransferEvent.JSON_PROPERTY_STATUS, + TransferEvent.JSON_PROPERTY_TRACING_DATA, TransferEvent.JSON_PROPERTY_TRACKING_DATA, TransferEvent.JSON_PROPERTY_TRANSACTION_ID, TransferEvent.JSON_PROPERTY_TYPE, @@ -470,6 +471,9 @@ public static StatusEnum fromValue(String value) { public static final String JSON_PROPERTY_STATUS = "status"; private StatusEnum status; + public static final String JSON_PROPERTY_TRACING_DATA = "tracingData"; + private TransferEventTracingData tracingData; + public static final String JSON_PROPERTY_TRACKING_DATA = "trackingData"; private TransferEventTrackingData trackingData; @@ -993,6 +997,39 @@ public void setStatus(StatusEnum status) { this.status = status; } + /** + * tracingData + * + * @param tracingData + * @return the current {@code TransferEvent} instance, allowing for method chaining + */ + public TransferEvent tracingData(TransferEventTracingData tracingData) { + this.tracingData = tracingData; + return this; + } + + /** + * Get tracingData + * + * @return tracingData + */ + @JsonProperty(JSON_PROPERTY_TRACING_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TransferEventTracingData getTracingData() { + return tracingData; + } + + /** + * tracingData + * + * @param tracingData + */ + @JsonProperty(JSON_PROPERTY_TRACING_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTracingData(TransferEventTracingData tracingData) { + this.tracingData = tracingData; + } + /** * trackingData * @@ -1193,6 +1230,7 @@ public boolean equals(Object o) { && Objects.equals(this.originalAmount, transferEvent.originalAmount) && Objects.equals(this.reason, transferEvent.reason) && Objects.equals(this.status, transferEvent.status) + && Objects.equals(this.tracingData, transferEvent.tracingData) && Objects.equals(this.trackingData, transferEvent.trackingData) && Objects.equals(this.transactionId, transferEvent.transactionId) && Objects.equals(this.type, transferEvent.type) @@ -1216,6 +1254,7 @@ public int hashCode() { originalAmount, reason, status, + tracingData, trackingData, transactionId, type, @@ -1242,6 +1281,7 @@ public String toString() { sb.append(" originalAmount: ").append(toIndentedString(originalAmount)).append("\n"); sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" tracingData: ").append(toIndentedString(tracingData)).append("\n"); sb.append(" trackingData: ").append(toIndentedString(trackingData)).append("\n"); sb.append(" transactionId: ").append(toIndentedString(transactionId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); diff --git a/src/main/java/com/adyen/model/transferwebhooks/TransferEventEventsDataInner.java b/src/main/java/com/adyen/model/transferwebhooks/TransferEventEventsDataInner.java index 6cd56c7a4..710664986 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/TransferEventEventsDataInner.java +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferEventEventsDataInner.java @@ -201,6 +201,16 @@ public TransferEventEventsDataInner(MerchantPurchaseData o) { schemas.put("MerchantPurchaseData", new GenericType() {}); JSON.registerDescendants( TransferEventEventsDataInner.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap<>(); + mappings.put("interchangeData", InterchangeData.class); + mappings.put("issuingTransactionData", IssuingTransactionData.class); + mappings.put("merchantPurchaseData", MerchantPurchaseData.class); + mappings.put("InterchangeData", InterchangeData.class); + mappings.put("IssuingTransactionData", IssuingTransactionData.class); + mappings.put("MerchantPurchaseData", MerchantPurchaseData.class); + mappings.put("TransferEvent_eventsData_inner", TransferEventEventsDataInner.class); + JSON.registerDiscriminator(TransferEventEventsDataInner.class, "type", mappings); } @Override diff --git a/src/main/java/com/adyen/model/transferwebhooks/TransferEventTracingData.java b/src/main/java/com/adyen/model/transferwebhooks/TransferEventTracingData.java new file mode 100644 index 000000000..e49673b23 --- /dev/null +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferEventTracingData.java @@ -0,0 +1,257 @@ +/* + * Transfer webhooks + * + * The version of the OpenAPI document: 4 + * + * + * 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.transferwebhooks; + +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 = TransferEventTracingData.TransferEventTracingDataDeserializer.class) +@JsonSerialize(using = TransferEventTracingData.TransferEventTracingDataSerializer.class) +public class TransferEventTracingData extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(TransferEventTracingData.class.getName()); + + public static class TransferEventTracingDataSerializer + extends StdSerializer { + public TransferEventTracingDataSerializer(Class t) { + super(t); + } + + public TransferEventTracingDataSerializer() { + this(null); + } + + @Override + public void serialize( + TransferEventTracingData value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class TransferEventTracingDataDeserializer + extends StdDeserializer { + public TransferEventTracingDataDeserializer() { + this(TransferEventTracingData.class); + } + + public TransferEventTracingDataDeserializer(Class vc) { + super(vc); + } + + @Override + public TransferEventTracingData 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 UKFpsTracingData + 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(UKFpsTracingData.TypeEnum.values()) + .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText())); + } + + if (typeMatch) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(UKFpsTracingData.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 'UKFpsTracingData'"); + } + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'UKFpsTracingData'", e); + } + + // deserialize USAchTracingData + 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(USAchTracingData.TypeEnum.values()) + .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText())); + } + + if (typeMatch) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(USAchTracingData.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 'USAchTracingData'"); + } + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'USAchTracingData'", e); + } + + if (match == 1) { + TransferEventTracingData ret = new TransferEventTracingData(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for TransferEventTracingData: %d classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public TransferEventTracingData getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "TransferEventTracingData cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public TransferEventTracingData() { + super("oneOf", Boolean.FALSE); + } + + public TransferEventTracingData(UKFpsTracingData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public TransferEventTracingData(USAchTracingData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("UKFpsTracingData", new GenericType() {}); + schemas.put("USAchTracingData", new GenericType() {}); + JSON.registerDescendants(TransferEventTracingData.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap<>(); + mappings.put("ukFps", UKFpsTracingData.class); + mappings.put("usAch", USAchTracingData.class); + mappings.put("UKFpsTracingData", UKFpsTracingData.class); + mappings.put("USAchTracingData", USAchTracingData.class); + mappings.put("TransferEvent_tracingData", TransferEventTracingData.class); + JSON.registerDiscriminator(TransferEventTracingData.class, "type", mappings); + } + + @Override + public Map> getSchemas() { + return TransferEventTracingData.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: UKFpsTracingData, USAchTracingData + * + *

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(UKFpsTracingData.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(USAchTracingData.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be UKFpsTracingData, USAchTracingData"); + } + + /** + * Get the actual instance, which can be the following: UKFpsTracingData, USAchTracingData + * + * @return The actual instance (UKFpsTracingData, USAchTracingData) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `UKFpsTracingData`. If the actual instance is not + * `UKFpsTracingData`, the ClassCastException will be thrown. + * + * @return The actual instance of `UKFpsTracingData` + * @throws ClassCastException if the instance is not `UKFpsTracingData` + */ + public UKFpsTracingData getUKFpsTracingData() throws ClassCastException { + return (UKFpsTracingData) super.getActualInstance(); + } + + /** + * Get the actual instance of `USAchTracingData`. If the actual instance is not + * `USAchTracingData`, the ClassCastException will be thrown. + * + * @return The actual instance of `USAchTracingData` + * @throws ClassCastException if the instance is not `USAchTracingData` + */ + public USAchTracingData getUSAchTracingData() throws ClassCastException { + return (USAchTracingData) super.getActualInstance(); + } + + /** + * Create an instance of TransferEventTracingData given an JSON string + * + * @param jsonString JSON string + * @return An instance of TransferEventTracingData + * @throws IOException if the JSON string is invalid with respect to TransferEventTracingData + */ + public static TransferEventTracingData fromJson(String jsonString) throws IOException { + return JSON.getMapper().readValue(jsonString, TransferEventTracingData.class); + } + + /** + * Convert an instance of TransferEventTracingData 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/transferwebhooks/TransferEventTrackingData.java b/src/main/java/com/adyen/model/transferwebhooks/TransferEventTrackingData.java index c775beac7..63734cc01 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/TransferEventTrackingData.java +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferEventTrackingData.java @@ -199,6 +199,16 @@ public TransferEventTrackingData(InternalReviewTrackingData o) { schemas.put("EstimationTrackingData", new GenericType() {}); schemas.put("InternalReviewTrackingData", new GenericType() {}); JSON.registerDescendants(TransferEventTrackingData.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap<>(); + mappings.put("confirmation", ConfirmationTrackingData.class); + mappings.put("estimation", EstimationTrackingData.class); + mappings.put("internalReview", InternalReviewTrackingData.class); + mappings.put("ConfirmationTrackingData", ConfirmationTrackingData.class); + mappings.put("EstimationTrackingData", EstimationTrackingData.class); + mappings.put("InternalReviewTrackingData", InternalReviewTrackingData.class); + mappings.put("TransferEvent_trackingData", TransferEventTrackingData.class); + JSON.registerDiscriminator(TransferEventTrackingData.class, "type", mappings); } @Override diff --git a/src/main/java/com/adyen/model/transferwebhooks/UKFpsTracingData.java b/src/main/java/com/adyen/model/transferwebhooks/UKFpsTracingData.java new file mode 100644 index 000000000..5e0246ba5 --- /dev/null +++ b/src/main/java/com/adyen/model/transferwebhooks/UKFpsTracingData.java @@ -0,0 +1,204 @@ +/* + * Transfer webhooks + * + * The version of the OpenAPI document: 4 + * + * + * 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.transferwebhooks; + +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; + +/** UKFpsTracingData */ +@JsonPropertyOrder({UKFpsTracingData.JSON_PROPERTY_FPID, UKFpsTracingData.JSON_PROPERTY_TYPE}) +public class UKFpsTracingData { + public static final String JSON_PROPERTY_FPID = "fpid"; + private String fpid; + + /** **ukFps** */ + public enum TypeEnum { + UKFPS(String.valueOf("ukFps")); + + 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 UKFpsTracingData() {} + + /** + * The FPS trace number. This is a unique identifier assigned to transfers processed by + * [FPS](https://www.bankofengland.co.uk/payment-systems/services/faster-payments-service). + * + * @param fpid The FPS trace number. This is a unique identifier assigned to transfers processed + * by [FPS](https://www.bankofengland.co.uk/payment-systems/services/faster-payments-service). + * @return the current {@code UKFpsTracingData} instance, allowing for method chaining + */ + public UKFpsTracingData fpid(String fpid) { + this.fpid = fpid; + return this; + } + + /** + * The FPS trace number. This is a unique identifier assigned to transfers processed by + * [FPS](https://www.bankofengland.co.uk/payment-systems/services/faster-payments-service). + * + * @return fpid The FPS trace number. This is a unique identifier assigned to transfers processed + * by [FPS](https://www.bankofengland.co.uk/payment-systems/services/faster-payments-service). + */ + @JsonProperty(JSON_PROPERTY_FPID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFpid() { + return fpid; + } + + /** + * The FPS trace number. This is a unique identifier assigned to transfers processed by + * [FPS](https://www.bankofengland.co.uk/payment-systems/services/faster-payments-service). + * + * @param fpid The FPS trace number. This is a unique identifier assigned to transfers processed + * by [FPS](https://www.bankofengland.co.uk/payment-systems/services/faster-payments-service). + */ + @JsonProperty(JSON_PROPERTY_FPID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFpid(String fpid) { + this.fpid = fpid; + } + + /** + * **ukFps** + * + * @param type **ukFps** + * @return the current {@code UKFpsTracingData} instance, allowing for method chaining + */ + public UKFpsTracingData type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * **ukFps** + * + * @return type **ukFps** + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TypeEnum getType() { + return type; + } + + /** + * **ukFps** + * + * @param type **ukFps** + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + /** Return true if this UKFpsTracingData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UKFpsTracingData ukFpsTracingData = (UKFpsTracingData) o; + return Objects.equals(this.fpid, ukFpsTracingData.fpid) + && Objects.equals(this.type, ukFpsTracingData.type); + } + + @Override + public int hashCode() { + return Objects.hash(fpid, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UKFpsTracingData {\n"); + sb.append(" fpid: ").append(toIndentedString(fpid)).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 UKFpsTracingData given an JSON string + * + * @param jsonString JSON string + * @return An instance of UKFpsTracingData + * @throws JsonProcessingException if the JSON string is invalid with respect to UKFpsTracingData + */ + public static UKFpsTracingData fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, UKFpsTracingData.class); + } + + /** + * Convert an instance of UKFpsTracingData 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/transferwebhooks/USAchTracingData.java b/src/main/java/com/adyen/model/transferwebhooks/USAchTracingData.java new file mode 100644 index 000000000..6818e4dea --- /dev/null +++ b/src/main/java/com/adyen/model/transferwebhooks/USAchTracingData.java @@ -0,0 +1,210 @@ +/* + * Transfer webhooks + * + * The version of the OpenAPI document: 4 + * + * + * 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.transferwebhooks; + +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; + +/** USAchTracingData */ +@JsonPropertyOrder({ + USAchTracingData.JSON_PROPERTY_TRACE_NUMBER, + USAchTracingData.JSON_PROPERTY_TYPE +}) +public class USAchTracingData { + public static final String JSON_PROPERTY_TRACE_NUMBER = "traceNumber"; + private String traceNumber; + + /** **usAch** */ + public enum TypeEnum { + USACH(String.valueOf("usAch")); + + 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 USAchTracingData() {} + + /** + * The ACH trace number. This is a unique 15-digit identifier assigned to transfers processed by + * [ACH](https://fiscal.treasury.gov/payments-from-government/automated-clearing-house-ach). + * + * @param traceNumber The ACH trace number. This is a unique 15-digit identifier assigned to + * transfers processed by + * [ACH](https://fiscal.treasury.gov/payments-from-government/automated-clearing-house-ach). + * @return the current {@code USAchTracingData} instance, allowing for method chaining + */ + public USAchTracingData traceNumber(String traceNumber) { + this.traceNumber = traceNumber; + return this; + } + + /** + * The ACH trace number. This is a unique 15-digit identifier assigned to transfers processed by + * [ACH](https://fiscal.treasury.gov/payments-from-government/automated-clearing-house-ach). + * + * @return traceNumber The ACH trace number. This is a unique 15-digit identifier assigned to + * transfers processed by + * [ACH](https://fiscal.treasury.gov/payments-from-government/automated-clearing-house-ach). + */ + @JsonProperty(JSON_PROPERTY_TRACE_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTraceNumber() { + return traceNumber; + } + + /** + * The ACH trace number. This is a unique 15-digit identifier assigned to transfers processed by + * [ACH](https://fiscal.treasury.gov/payments-from-government/automated-clearing-house-ach). + * + * @param traceNumber The ACH trace number. This is a unique 15-digit identifier assigned to + * transfers processed by + * [ACH](https://fiscal.treasury.gov/payments-from-government/automated-clearing-house-ach). + */ + @JsonProperty(JSON_PROPERTY_TRACE_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTraceNumber(String traceNumber) { + this.traceNumber = traceNumber; + } + + /** + * **usAch** + * + * @param type **usAch** + * @return the current {@code USAchTracingData} instance, allowing for method chaining + */ + public USAchTracingData type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * **usAch** + * + * @return type **usAch** + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TypeEnum getType() { + return type; + } + + /** + * **usAch** + * + * @param type **usAch** + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + /** Return true if this USAchTracingData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + USAchTracingData usAchTracingData = (USAchTracingData) o; + return Objects.equals(this.traceNumber, usAchTracingData.traceNumber) + && Objects.equals(this.type, usAchTracingData.type); + } + + @Override + public int hashCode() { + return Objects.hash(traceNumber, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class USAchTracingData {\n"); + sb.append(" traceNumber: ").append(toIndentedString(traceNumber)).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 USAchTracingData given an JSON string + * + * @param jsonString JSON string + * @return An instance of USAchTracingData + * @throws JsonProcessingException if the JSON string is invalid with respect to USAchTracingData + */ + public static USAchTracingData fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, USAchTracingData.class); + } + + /** + * Convert an instance of USAchTracingData 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 294bedd74..52c35b11d 100644 --- a/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java +++ b/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java @@ -18,8 +18,11 @@ import com.adyen.model.reportwebhooks.ReportWebhooksHandler; import com.adyen.model.transactionwebhooks.TransactionNotificationRequestV4; import com.adyen.model.transactionwebhooks.TransactionWebhooksHandler; +import com.adyen.model.transferwebhooks.BalanceMutation; import com.adyen.model.transferwebhooks.InterchangeData; import com.adyen.model.transferwebhooks.PlatformPayment; +import com.adyen.model.transferwebhooks.TransferData; +import com.adyen.model.transferwebhooks.TransferEvent; import com.adyen.model.transferwebhooks.TransferNotificationRequest; import com.adyen.model.transferwebhooks.TransferWebhooksHandler; import com.adyen.util.HMACValidator; @@ -445,6 +448,61 @@ public void testTransferNotificationRequest() { .getActualInstance()); } + @Test + public void testTransferCreatedNotificationRequest() { + String json = getFileContents("mocks/balancePlatform-webhooks/transfer-created.json"); + + Optional optionalTransferNotificationRequest = + new TransferWebhooksHandler(json).getTransferNotificationRequest(); + assertTrue(optionalTransferNotificationRequest.isPresent()); + + TransferNotificationRequest transferNotificationRequest = + optionalTransferNotificationRequest.get(); + assertEquals( + TransferNotificationRequest.TypeEnum.BALANCEPLATFORM_TRANSFER_CREATED, + transferNotificationRequest.getType()); + assertEquals("test", transferNotificationRequest.getEnvironment()); + assertNotNull(transferNotificationRequest.getTimestamp()); + + TransferData data = transferNotificationRequest.getData(); + assertNotNull(data); + assertEquals("2WT1N05XXY7P9XH9", data.getId()); + assertEquals(TransferData.TypeEnum.INTERNALTRANSFER, data.getType()); + assertEquals("YOUR_BALANCE_PLATFORM", data.getBalancePlatform()); + assertEquals(TransferData.CategoryEnum.INTERNAL, data.getCategory()); + assertEquals("2023-02-28T13:30:05+02:00", data.getCreationDate().toString()); + assertEquals(TransferData.DirectionEnum.INCOMING, data.getDirection()); + assertEquals(TransferData.ReasonEnum.APPROVED, data.getReason()); + assertEquals(TransferData.StatusEnum.RECEIVED, data.getStatus()); + assertEquals(Integer.valueOf(1), data.getSequenceNumber()); + + assertNotNull(data.getAccountHolder()); + assertEquals("AH00000000000000000000002", data.getAccountHolder().getId()); + assertEquals("Your reference of the account holder", data.getAccountHolder().getReference()); + assertNotNull(data.getAmount()); + assertEquals("EUR", data.getAmount().getCurrency()); + assertEquals(Long.valueOf(1000), data.getAmount().getValue()); + assertNotNull(data.getBalanceAccount()); + assertEquals("BA00000000000000000000002", data.getBalanceAccount().getId()); + + assertNotNull(data.getBalances()); + assertEquals(1, data.getBalances().size()); + BalanceMutation balance = data.getBalances().get(0); + assertEquals("EUR", balance.getCurrency()); + assertEquals(Long.valueOf(1000), balance.getReceived()); + + assertNotNull(data.getEvents()); + assertEquals(1, data.getEvents().size()); + TransferEvent event = data.getEvents().get(0); + assertEquals("JDRF00000000000000000000000001", event.getId()); + assertEquals("2023-02-28T13:30:18+02:00", event.getBookingDate().toString()); + assertEquals(TransferEvent.StatusEnum.RECEIVED, event.getStatus()); + assertEquals(TransferEvent.TypeEnum.ACCOUNTING, event.getType()); + assertNotNull(event.getMutations()); + assertEquals(1, event.getMutations().size()); + assertEquals(Long.valueOf(1000), event.getMutations().get(0).getReceived()); + } + @Test public void testGetDisputeNotificationRequestSuccess() { diff --git a/src/test/resources/mocks/balancePlatform-webhooks/transfer-created.json b/src/test/resources/mocks/balancePlatform-webhooks/transfer-created.json new file mode 100644 index 000000000..0943f281d --- /dev/null +++ b/src/test/resources/mocks/balancePlatform-webhooks/transfer-created.json @@ -0,0 +1,52 @@ +{ + "data": { + "id": "2WT1N05XXY7P9XH9", + "type": "internalTransfer", + "accountHolder": { + "description": "Your description of the account holder of the target balance account", + "id": "AH00000000000000000000002", + "reference": "Your reference of the account holder" + }, + "amount": { + "currency": "EUR", + "value": 1000 + }, + "balanceAccount": { + "description": "Your description of the target balance account", + "id": "BA00000000000000000000002" + }, + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "balances": [ + { + "currency": "EUR", + "received": 1000 + } + ], + "category": "internal", + "creationDate": "2023-02-28T13:30:05+02:00", + "description": "Your description of the transfer", + "direction": "incoming", + "events": [ + { + "bookingDate": "2023-02-28T13:30:18+02:00", + "id": "JDRF00000000000000000000000001", + "mutations": [ + { + "currency": "EUR", + "received": 1000 + } + ], + "status": "received", + "type": "accounting" + } + ], + "reason": "approved", + "reference": "Your reference of the transfer", + "referenceForBeneficiary": "Your-reference-for-the-recipient-of-the-transfer-request", + "sequenceNumber": 1, + "status": "received" + }, + "environment": "test", + "timestamp": "2023-02-28T13:27:05+02:00", + "type": "balancePlatform.transfer.created" +}