diff --git a/src/main/java/com/adyen/model/transferwebhooks/InterchangeData.java b/src/main/java/com/adyen/model/transferwebhooks/InterchangeData.java new file mode 100644 index 000000000..3446e6ea0 --- /dev/null +++ b/src/main/java/com/adyen/model/transferwebhooks/InterchangeData.java @@ -0,0 +1,263 @@ +/* + * 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; + +/** InterchangeData */ +@JsonPropertyOrder({ + InterchangeData.JSON_PROPERTY_INTERCHANGE_AMOUNT, + InterchangeData.JSON_PROPERTY_INTERCHANGE_RATE_INDICATOR, + InterchangeData.JSON_PROPERTY_TYPE +}) +public class InterchangeData { + public static final String JSON_PROPERTY_INTERCHANGE_AMOUNT = "interchangeAmount"; + private Amount interchangeAmount; + + public static final String JSON_PROPERTY_INTERCHANGE_RATE_INDICATOR = "interchangeRateIndicator"; + private String interchangeRateIndicator; + + /** + * The type of events data. Possible values: - **interchangeData**: information about the + * interchange fee applied to a transaction. + */ + public enum TypeEnum { + INTERCHANGEDATA(String.valueOf("interchangeData")); + + 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 InterchangeData() {} + + /** + * interchangeAmount + * + * @param interchangeAmount + * @return the current {@code InterchangeData} instance, allowing for method chaining + */ + public InterchangeData interchangeAmount(Amount interchangeAmount) { + this.interchangeAmount = interchangeAmount; + return this; + } + + /** + * Get interchangeAmount + * + * @return interchangeAmount + */ + @JsonProperty(JSON_PROPERTY_INTERCHANGE_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Amount getInterchangeAmount() { + return interchangeAmount; + } + + /** + * interchangeAmount + * + * @param interchangeAmount + */ + @JsonProperty(JSON_PROPERTY_INTERCHANGE_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setInterchangeAmount(Amount interchangeAmount) { + this.interchangeAmount = interchangeAmount; + } + + /** + * A 3-character alphanumeric code assigned by Visa that identifies the specific interchange + * reimbursement program a transaction qualified for. The code is assigned based on the card type, + * entry mode, and security data provided. + * + * @param interchangeRateIndicator A 3-character alphanumeric code assigned by Visa that + * identifies the specific interchange reimbursement program a transaction qualified for. The + * code is assigned based on the card type, entry mode, and security data provided. + * @return the current {@code InterchangeData} instance, allowing for method chaining + */ + public InterchangeData interchangeRateIndicator(String interchangeRateIndicator) { + this.interchangeRateIndicator = interchangeRateIndicator; + return this; + } + + /** + * A 3-character alphanumeric code assigned by Visa that identifies the specific interchange + * reimbursement program a transaction qualified for. The code is assigned based on the card type, + * entry mode, and security data provided. + * + * @return interchangeRateIndicator A 3-character alphanumeric code assigned by Visa that + * identifies the specific interchange reimbursement program a transaction qualified for. The + * code is assigned based on the card type, entry mode, and security data provided. + */ + @JsonProperty(JSON_PROPERTY_INTERCHANGE_RATE_INDICATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getInterchangeRateIndicator() { + return interchangeRateIndicator; + } + + /** + * A 3-character alphanumeric code assigned by Visa that identifies the specific interchange + * reimbursement program a transaction qualified for. The code is assigned based on the card type, + * entry mode, and security data provided. + * + * @param interchangeRateIndicator A 3-character alphanumeric code assigned by Visa that + * identifies the specific interchange reimbursement program a transaction qualified for. The + * code is assigned based on the card type, entry mode, and security data provided. + */ + @JsonProperty(JSON_PROPERTY_INTERCHANGE_RATE_INDICATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setInterchangeRateIndicator(String interchangeRateIndicator) { + this.interchangeRateIndicator = interchangeRateIndicator; + } + + /** + * The type of events data. Possible values: - **interchangeData**: information about the + * interchange fee applied to a transaction. + * + * @param type The type of events data. Possible values: - **interchangeData**: information about + * the interchange fee applied to a transaction. + * @return the current {@code InterchangeData} instance, allowing for method chaining + */ + public InterchangeData type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of events data. Possible values: - **interchangeData**: information about the + * interchange fee applied to a transaction. + * + * @return type The type of events data. Possible values: - **interchangeData**: information about + * the interchange fee applied to a transaction. + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TypeEnum getType() { + return type; + } + + /** + * The type of events data. Possible values: - **interchangeData**: information about the + * interchange fee applied to a transaction. + * + * @param type The type of events data. Possible values: - **interchangeData**: information about + * the interchange fee applied to a transaction. + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + /** Return true if this InterchangeData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InterchangeData interchangeData = (InterchangeData) o; + return Objects.equals(this.interchangeAmount, interchangeData.interchangeAmount) + && Objects.equals(this.interchangeRateIndicator, interchangeData.interchangeRateIndicator) + && Objects.equals(this.type, interchangeData.type); + } + + @Override + public int hashCode() { + return Objects.hash(interchangeAmount, interchangeRateIndicator, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InterchangeData {\n"); + sb.append(" interchangeAmount: ").append(toIndentedString(interchangeAmount)).append("\n"); + sb.append(" interchangeRateIndicator: ") + .append(toIndentedString(interchangeRateIndicator)) + .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 InterchangeData given an JSON string + * + * @param jsonString JSON string + * @return An instance of InterchangeData + * @throws JsonProcessingException if the JSON string is invalid with respect to InterchangeData + */ + public static InterchangeData fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, InterchangeData.class); + } + + /** + * Convert an instance of InterchangeData 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/Modification.java b/src/main/java/com/adyen/model/transferwebhooks/Modification.java index f7a96dd05..398b46bdb 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/Modification.java +++ b/src/main/java/com/adyen/model/transferwebhooks/Modification.java @@ -111,6 +111,8 @@ public enum StatusEnum { FEEPENDING(String.valueOf("feePending")), + INTERCHANGEADJUSTED(String.valueOf("interchangeAdjusted")), + INTERNALTRANSFER(String.valueOf("internalTransfer")), INTERNALTRANSFERPENDING(String.valueOf("internalTransferPending")), diff --git a/src/main/java/com/adyen/model/transferwebhooks/TransferData.java b/src/main/java/com/adyen/model/transferwebhooks/TransferData.java index 12fa08cd2..8734606a0 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/TransferData.java +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferData.java @@ -517,6 +517,8 @@ public enum StatusEnum { FEEPENDING(String.valueOf("feePending")), + INTERCHANGEADJUSTED(String.valueOf("interchangeAdjusted")), + INTERNALTRANSFER(String.valueOf("internalTransfer")), INTERNALTRANSFERPENDING(String.valueOf("internalTransferPending")), diff --git a/src/main/java/com/adyen/model/transferwebhooks/TransferEvent.java b/src/main/java/com/adyen/model/transferwebhooks/TransferEvent.java index 291448c69..2420ee509 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/TransferEvent.java +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferEvent.java @@ -362,6 +362,8 @@ public enum StatusEnum { FEEPENDING(String.valueOf("feePending")), + INTERCHANGEADJUSTED(String.valueOf("interchangeAdjusted")), + INTERNALTRANSFER(String.valueOf("internalTransfer")), INTERNALTRANSFERPENDING(String.valueOf("internalTransferPending")), @@ -474,6 +476,8 @@ public static StatusEnum fromValue(String value) { public enum TypeEnum { ACCOUNTING(String.valueOf("accounting")), + TRACING(String.valueOf("tracing")), + TRACKING(String.valueOf("tracking")); private static final Logger LOG = Logger.getLogger(TypeEnum.class.getName()); diff --git a/src/main/java/com/adyen/model/transferwebhooks/TransferEventEventsDataInner.java b/src/main/java/com/adyen/model/transferwebhooks/TransferEventEventsDataInner.java index 9f8c0aa2b..6cd56c7a4 100644 --- a/src/main/java/com/adyen/model/transferwebhooks/TransferEventEventsDataInner.java +++ b/src/main/java/com/adyen/model/transferwebhooks/TransferEventEventsDataInner.java @@ -75,6 +75,32 @@ public TransferEventEventsDataInner deserialize(JsonParser jp, DeserializationCo boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); int match = 0; JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize InterchangeData + 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(InterchangeData.TypeEnum.values()) + .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText())); + } + + if (typeMatch) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(InterchangeData.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 'InterchangeData'"); + } + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'InterchangeData'", e); + } + // deserialize IssuingTransactionData try { boolean attemptParsing = true; @@ -154,6 +180,11 @@ public TransferEventEventsDataInner() { super("oneOf", Boolean.FALSE); } + public TransferEventEventsDataInner(InterchangeData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + public TransferEventEventsDataInner(IssuingTransactionData o) { super("oneOf", Boolean.FALSE); setActualInstance(o); @@ -165,6 +196,7 @@ public TransferEventEventsDataInner(MerchantPurchaseData o) { } static { + schemas.put("InterchangeData", new GenericType() {}); schemas.put("IssuingTransactionData", new GenericType() {}); schemas.put("MerchantPurchaseData", new GenericType() {}); JSON.registerDescendants( @@ -178,13 +210,18 @@ public Map> getSchemas() { /** * Set the instance that matches the oneOf child schema, check the instance parameter is valid - * against the oneOf child schemas: IssuingTransactionData, MerchantPurchaseData + * against the oneOf child schemas: InterchangeData, IssuingTransactionData, MerchantPurchaseData * *

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(InterchangeData.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(IssuingTransactionData.class, instance, new HashSet<>())) { super.setActualInstance(instance); return; @@ -196,20 +233,31 @@ public void setActualInstance(Object instance) { } throw new RuntimeException( - "Invalid instance type. Must be IssuingTransactionData, MerchantPurchaseData"); + "Invalid instance type. Must be InterchangeData, IssuingTransactionData, MerchantPurchaseData"); } /** - * Get the actual instance, which can be the following: IssuingTransactionData, + * Get the actual instance, which can be the following: InterchangeData, IssuingTransactionData, * MerchantPurchaseData * - * @return The actual instance (IssuingTransactionData, MerchantPurchaseData) + * @return The actual instance (InterchangeData, IssuingTransactionData, MerchantPurchaseData) */ @Override public Object getActualInstance() { return super.getActualInstance(); } + /** + * Get the actual instance of `InterchangeData`. If the actual instance is not `InterchangeData`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `InterchangeData` + * @throws ClassCastException if the instance is not `InterchangeData` + */ + public InterchangeData getInterchangeData() throws ClassCastException { + return (InterchangeData) super.getActualInstance(); + } + /** * Get the actual instance of `IssuingTransactionData`. If the actual instance is not * `IssuingTransactionData`, the ClassCastException will be thrown.