From 0d9633ba481ef601485e2d77ed3b8dff12d1e884 Mon Sep 17 00:00:00 2001 From: AdyenAutomationBot <38424300+AdyenAutomationBot@users.noreply.github.com> Date: Fri, 16 Oct 2026 13:40:03 +0000 Subject: [PATCH] [foreignexchange] Automated update from Adyen/adyen-openapi@63d4425 --- sdk-generation-log/foreignexchange.json | 8 + .../AbstractOpenApiSchema.java | 142 +++++ .../adyen/model/foreignexchange/Amount.java | 234 ++++++++ .../foreignexchange/CalculateRateRequest.java | 197 +++++++ .../CalculateRateRequestItem.java | 331 +++++++++++ .../CalculateRateResponse.java | 200 +++++++ .../CalculateRateResponseItem.java | 400 +++++++++++++ .../DefaultErrorResponseEntity.java | 547 ++++++++++++++++++ .../model/foreignexchange/ExchangeSide.java | 58 ++ .../model/foreignexchange/InvalidField.java | 273 +++++++++ .../com/adyen/model/foreignexchange/JSON.java | 251 ++++++++ .../adyen/model/foreignexchange/RateType.java | 62 ++ .../service/foreignexchange/RatesApi.java | 83 +++ 13 files changed, 2786 insertions(+) create mode 100644 sdk-generation-log/foreignexchange.json create mode 100644 src/main/java/com/adyen/model/foreignexchange/AbstractOpenApiSchema.java create mode 100644 src/main/java/com/adyen/model/foreignexchange/Amount.java create mode 100644 src/main/java/com/adyen/model/foreignexchange/CalculateRateRequest.java create mode 100644 src/main/java/com/adyen/model/foreignexchange/CalculateRateRequestItem.java create mode 100644 src/main/java/com/adyen/model/foreignexchange/CalculateRateResponse.java create mode 100644 src/main/java/com/adyen/model/foreignexchange/CalculateRateResponseItem.java create mode 100644 src/main/java/com/adyen/model/foreignexchange/DefaultErrorResponseEntity.java create mode 100644 src/main/java/com/adyen/model/foreignexchange/ExchangeSide.java create mode 100644 src/main/java/com/adyen/model/foreignexchange/InvalidField.java create mode 100644 src/main/java/com/adyen/model/foreignexchange/JSON.java create mode 100644 src/main/java/com/adyen/model/foreignexchange/RateType.java create mode 100644 src/main/java/com/adyen/service/foreignexchange/RatesApi.java diff --git a/sdk-generation-log/foreignexchange.json b/sdk-generation-log/foreignexchange.json new file mode 100644 index 000000000..3a3917f45 --- /dev/null +++ b/sdk-generation-log/foreignexchange.json @@ -0,0 +1,8 @@ +{ + "service": "foreignexchange", + "project": "java", + "generatedAt": "2026-10-16T13:40:02Z", + "openapiCommitSha": "63d44256a3466e270201f8d719299c92973abbca", + "automationCommitSha": "b78db5c1f857f1d7d8d45116ce61f6266043fa60", + "libraryCommitSha": "59ca5003d1ed41687e66fc478ca0130f7be35ac9" +} diff --git a/src/main/java/com/adyen/model/foreignexchange/AbstractOpenApiSchema.java b/src/main/java/com/adyen/model/foreignexchange/AbstractOpenApiSchema.java new file mode 100644 index 000000000..aa4b4d297 --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/AbstractOpenApiSchema.java @@ -0,0 +1,142 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.foreignexchange; + +import com.fasterxml.jackson.annotation.JsonValue; +import jakarta.ws.rs.core.GenericType; +import java.util.Map; +import java.util.Objects; + +/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + /** + * @param schemaType the schema type + * @param isNullable whether the instance is nullable + */ + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() { + return instance; + } + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) { + this.instance = instance; + } + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf + * schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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 "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) + && Objects.equals(this.isNullable, a.isNullable) + && Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + return Boolean.TRUE.equals(isNullable); + } +} diff --git a/src/main/java/com/adyen/model/foreignexchange/Amount.java b/src/main/java/com/adyen/model/foreignexchange/Amount.java new file mode 100644 index 000000000..fdc43831f --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/Amount.java @@ -0,0 +1,234 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.foreignexchange; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +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.*; + +/** Amount */ +@JsonPropertyOrder({Amount.JSON_PROPERTY_CURRENCY, Amount.JSON_PROPERTY_VALUE}) +public class Amount { + public static final String JSON_PROPERTY_CURRENCY = "currency"; + private String currency; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetCurrency = false; + + public static final String JSON_PROPERTY_VALUE = "value"; + private Long value; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetValue = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + + public Amount() {} + + /** + * The three-character [ISO currency + * code](https://docs.adyen.com/development-resources/currency-codes#currency-codes). + * + * @param currency The three-character [ISO currency + * code](https://docs.adyen.com/development-resources/currency-codes#currency-codes). + * @return the current {@code Amount} instance, allowing for method chaining + */ + public Amount currency(String currency) { + this.currency = currency; + isSetCurrency = true; // mark as set + return this; + } + + /** + * The three-character [ISO currency + * code](https://docs.adyen.com/development-resources/currency-codes#currency-codes). + * + * @return currency The three-character [ISO currency + * code](https://docs.adyen.com/development-resources/currency-codes#currency-codes). + */ + @JsonProperty(JSON_PROPERTY_CURRENCY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCurrency() { + return currency; + } + + /** + * The three-character [ISO currency + * code](https://docs.adyen.com/development-resources/currency-codes#currency-codes). + * + * @param currency The three-character [ISO currency + * code](https://docs.adyen.com/development-resources/currency-codes#currency-codes). + */ + @JsonProperty(JSON_PROPERTY_CURRENCY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCurrency(String currency) { + this.currency = currency; + isSetCurrency = true; // mark as set + } + + /** + * The amount of the transaction, in [minor + * units](https://docs.adyen.com/development-resources/currency-codes#minor-units). + * + * @param value The amount of the transaction, in [minor + * units](https://docs.adyen.com/development-resources/currency-codes#minor-units). + * @return the current {@code Amount} instance, allowing for method chaining + */ + public Amount value(Long value) { + this.value = value; + isSetValue = true; // mark as set + return this; + } + + /** + * The amount of the transaction, in [minor + * units](https://docs.adyen.com/development-resources/currency-codes#minor-units). + * + * @return value The amount of the transaction, in [minor + * units](https://docs.adyen.com/development-resources/currency-codes#minor-units). + */ + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getValue() { + return value; + } + + /** + * The amount of the transaction, in [minor + * units](https://docs.adyen.com/development-resources/currency-codes#minor-units). + * + * @param value The amount of the transaction, in [minor + * units](https://docs.adyen.com/development-resources/currency-codes#minor-units). + */ + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setValue(Long value) { + this.value = value; + isSetValue = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public Amount includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + } + + /** Return true if this Amount object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Amount amount = (Amount) o; + return Objects.equals(this.currency, amount.currency) + && Objects.equals(this.isSetCurrency, amount.isSetCurrency) + && Objects.equals(this.value, amount.value) + && Objects.equals(this.isSetValue, amount.isSetValue); + } + + @Override + public int hashCode() { + return Objects.hash(currency, isSetCurrency, value, isSetValue); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Amount {\n"); + sb.append(" currency: ").append(toIndentedString(currency)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).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 "); + } + + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetCurrency) { + addIfNull(nulls, JSON_PROPERTY_CURRENCY, this.currency); + } + if (isSetValue) { + addIfNull(nulls, JSON_PROPERTY_VALUE, this.value); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + + /** + * Create an instance of Amount given an JSON string + * + * @param jsonString JSON string + * @return An instance of Amount + * @throws JsonProcessingException if the JSON string is invalid with respect to Amount + */ + public static Amount fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Amount.class); + } + + /** + * Convert an instance of Amount 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/foreignexchange/CalculateRateRequest.java b/src/main/java/com/adyen/model/foreignexchange/CalculateRateRequest.java new file mode 100644 index 000000000..3f80229f2 --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/CalculateRateRequest.java @@ -0,0 +1,197 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.foreignexchange; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +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.*; +import java.util.ArrayList; +import java.util.List; + +/** The request to calculate an amount in a different currency. */ +@JsonPropertyOrder({CalculateRateRequest.JSON_PROPERTY_EXCHANGE_CALCULATIONS}) +public class CalculateRateRequest { + public static final String JSON_PROPERTY_EXCHANGE_CALCULATIONS = "exchangeCalculations"; + private List exchangeCalculations; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetExchangeCalculations = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + + public CalculateRateRequest() {} + + /** + * An array of objects, where each object defines a currency and value for which you want to + * perform an exchange calculation. + * + * @param exchangeCalculations An array of objects, where each object defines a currency and value + * for which you want to perform an exchange calculation. + * @return the current {@code CalculateRateRequest} instance, allowing for method chaining + */ + public CalculateRateRequest exchangeCalculations( + List exchangeCalculations) { + this.exchangeCalculations = exchangeCalculations; + isSetExchangeCalculations = true; // mark as set + return this; + } + + public CalculateRateRequest addExchangeCalculationsItem( + CalculateRateRequestItem exchangeCalculationsItem) { + if (this.exchangeCalculations == null) { + this.exchangeCalculations = new ArrayList<>(); + } + this.exchangeCalculations.add(exchangeCalculationsItem); + return this; + } + + /** + * An array of objects, where each object defines a currency and value for which you want to + * perform an exchange calculation. + * + * @return exchangeCalculations An array of objects, where each object defines a currency and + * value for which you want to perform an exchange calculation. + */ + @JsonProperty(JSON_PROPERTY_EXCHANGE_CALCULATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getExchangeCalculations() { + return exchangeCalculations; + } + + /** + * An array of objects, where each object defines a currency and value for which you want to + * perform an exchange calculation. + * + * @param exchangeCalculations An array of objects, where each object defines a currency and value + * for which you want to perform an exchange calculation. + */ + @JsonProperty(JSON_PROPERTY_EXCHANGE_CALCULATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExchangeCalculations(List exchangeCalculations) { + this.exchangeCalculations = exchangeCalculations; + isSetExchangeCalculations = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public CalculateRateRequest includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + } + + /** Return true if this CalculateRateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CalculateRateRequest calculateRateRequest = (CalculateRateRequest) o; + return Objects.equals(this.exchangeCalculations, calculateRateRequest.exchangeCalculations) + && Objects.equals( + this.isSetExchangeCalculations, calculateRateRequest.isSetExchangeCalculations); + } + + @Override + public int hashCode() { + return Objects.hash(exchangeCalculations, isSetExchangeCalculations); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CalculateRateRequest {\n"); + sb.append(" exchangeCalculations: ") + .append(toIndentedString(exchangeCalculations)) + .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 "); + } + + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetExchangeCalculations) { + addIfNull(nulls, JSON_PROPERTY_EXCHANGE_CALCULATIONS, this.exchangeCalculations); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + + /** + * Create an instance of CalculateRateRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CalculateRateRequest + * @throws JsonProcessingException if the JSON string is invalid with respect to + * CalculateRateRequest + */ + public static CalculateRateRequest fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CalculateRateRequest.class); + } + + /** + * Convert an instance of CalculateRateRequest 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/foreignexchange/CalculateRateRequestItem.java b/src/main/java/com/adyen/model/foreignexchange/CalculateRateRequestItem.java new file mode 100644 index 000000000..f9e97ef7f --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/CalculateRateRequestItem.java @@ -0,0 +1,331 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.foreignexchange; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +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.*; + +/** The request parameters required to calculate an amount in a different currency. */ +@JsonPropertyOrder({ + CalculateRateRequestItem.JSON_PROPERTY_EXCHANGE_SIDE, + CalculateRateRequestItem.JSON_PROPERTY_SOURCE_AMOUNT, + CalculateRateRequestItem.JSON_PROPERTY_TARGET_CURRENCY, + CalculateRateRequestItem.JSON_PROPERTY_TYPE +}) +public class CalculateRateRequestItem { + public static final String JSON_PROPERTY_EXCHANGE_SIDE = "exchangeSide"; + private ExchangeSide exchangeSide; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetExchangeSide = false; + + public static final String JSON_PROPERTY_SOURCE_AMOUNT = "sourceAmount"; + private Amount sourceAmount; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetSourceAmount = false; + + public static final String JSON_PROPERTY_TARGET_CURRENCY = "targetCurrency"; + private String targetCurrency; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetTargetCurrency = false; + + public static final String JSON_PROPERTY_TYPE = "type"; + private RateType type; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetType = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + + public CalculateRateRequestItem() {} + + /** + * exchangeSide + * + * @param exchangeSide + * @return the current {@code CalculateRateRequestItem} instance, allowing for method chaining + */ + public CalculateRateRequestItem exchangeSide(ExchangeSide exchangeSide) { + this.exchangeSide = exchangeSide; + isSetExchangeSide = true; // mark as set + return this; + } + + /** + * Get exchangeSide + * + * @return exchangeSide + */ + @JsonProperty(JSON_PROPERTY_EXCHANGE_SIDE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ExchangeSide getExchangeSide() { + return exchangeSide; + } + + /** + * exchangeSide + * + * @param exchangeSide + */ + @JsonProperty(JSON_PROPERTY_EXCHANGE_SIDE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExchangeSide(ExchangeSide exchangeSide) { + this.exchangeSide = exchangeSide; + isSetExchangeSide = true; // mark as set + } + + /** + * sourceAmount + * + * @param sourceAmount + * @return the current {@code CalculateRateRequestItem} instance, allowing for method chaining + */ + public CalculateRateRequestItem sourceAmount(Amount sourceAmount) { + this.sourceAmount = sourceAmount; + isSetSourceAmount = true; // mark as set + return this; + } + + /** + * Get sourceAmount + * + * @return sourceAmount + */ + @JsonProperty(JSON_PROPERTY_SOURCE_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Amount getSourceAmount() { + return sourceAmount; + } + + /** + * sourceAmount + * + * @param sourceAmount + */ + @JsonProperty(JSON_PROPERTY_SOURCE_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceAmount(Amount sourceAmount) { + this.sourceAmount = sourceAmount; + isSetSourceAmount = true; // mark as set + } + + /** + * The currency to which you want to convert the source amount. + * + * @param targetCurrency The currency to which you want to convert the source amount. + * @return the current {@code CalculateRateRequestItem} instance, allowing for method chaining + */ + public CalculateRateRequestItem targetCurrency(String targetCurrency) { + this.targetCurrency = targetCurrency; + isSetTargetCurrency = true; // mark as set + return this; + } + + /** + * The currency to which you want to convert the source amount. + * + * @return targetCurrency The currency to which you want to convert the source amount. + */ + @JsonProperty(JSON_PROPERTY_TARGET_CURRENCY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTargetCurrency() { + return targetCurrency; + } + + /** + * The currency to which you want to convert the source amount. + * + * @param targetCurrency The currency to which you want to convert the source amount. + */ + @JsonProperty(JSON_PROPERTY_TARGET_CURRENCY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTargetCurrency(String targetCurrency) { + this.targetCurrency = targetCurrency; + isSetTargetCurrency = true; // mark as set + } + + /** + * type + * + * @param type + * @return the current {@code CalculateRateRequestItem} instance, allowing for method chaining + */ + public CalculateRateRequestItem type(RateType type) { + this.type = type; + isSetType = true; // mark as set + return this; + } + + /** + * Get type + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RateType getType() { + return type; + } + + /** + * type + * + * @param type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(RateType type) { + this.type = type; + isSetType = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public CalculateRateRequestItem includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + } + + /** Return true if this CalculateRateRequestItem object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CalculateRateRequestItem calculateRateRequestItem = (CalculateRateRequestItem) o; + return Objects.equals(this.exchangeSide, calculateRateRequestItem.exchangeSide) + && Objects.equals(this.isSetExchangeSide, calculateRateRequestItem.isSetExchangeSide) + && Objects.equals(this.sourceAmount, calculateRateRequestItem.sourceAmount) + && Objects.equals(this.isSetSourceAmount, calculateRateRequestItem.isSetSourceAmount) + && Objects.equals(this.targetCurrency, calculateRateRequestItem.targetCurrency) + && Objects.equals(this.isSetTargetCurrency, calculateRateRequestItem.isSetTargetCurrency) + && Objects.equals(this.type, calculateRateRequestItem.type) + && Objects.equals(this.isSetType, calculateRateRequestItem.isSetType); + } + + @Override + public int hashCode() { + return Objects.hash( + exchangeSide, + isSetExchangeSide, + sourceAmount, + isSetSourceAmount, + targetCurrency, + isSetTargetCurrency, + type, + isSetType); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CalculateRateRequestItem {\n"); + sb.append(" exchangeSide: ").append(toIndentedString(exchangeSide)).append("\n"); + sb.append(" sourceAmount: ").append(toIndentedString(sourceAmount)).append("\n"); + sb.append(" targetCurrency: ").append(toIndentedString(targetCurrency)).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 "); + } + + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetExchangeSide) { + addIfNull(nulls, JSON_PROPERTY_EXCHANGE_SIDE, this.exchangeSide); + } + if (isSetSourceAmount) { + addIfNull(nulls, JSON_PROPERTY_SOURCE_AMOUNT, this.sourceAmount); + } + if (isSetTargetCurrency) { + addIfNull(nulls, JSON_PROPERTY_TARGET_CURRENCY, this.targetCurrency); + } + if (isSetType) { + addIfNull(nulls, JSON_PROPERTY_TYPE, this.type); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + + /** + * Create an instance of CalculateRateRequestItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of CalculateRateRequestItem + * @throws JsonProcessingException if the JSON string is invalid with respect to + * CalculateRateRequestItem + */ + public static CalculateRateRequestItem fromJson(String jsonString) + throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CalculateRateRequestItem.class); + } + + /** + * Convert an instance of CalculateRateRequestItem 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/foreignexchange/CalculateRateResponse.java b/src/main/java/com/adyen/model/foreignexchange/CalculateRateResponse.java new file mode 100644 index 000000000..84b2e0259 --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/CalculateRateResponse.java @@ -0,0 +1,200 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.foreignexchange; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +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.*; +import java.util.ArrayList; +import java.util.List; + +/** The response returned when you calculate an amount in a different currency. */ +@JsonPropertyOrder({CalculateRateResponse.JSON_PROPERTY_EXCHANGE_CALCULATIONS}) +public class CalculateRateResponse { + public static final String JSON_PROPERTY_EXCHANGE_CALCULATIONS = "exchangeCalculations"; + private List exchangeCalculations; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetExchangeCalculations = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + + public CalculateRateResponse() {} + + /** + * An array of objects, where each object returns a currency and value for which you performed an + * exchange calculation. You can use the calculated amounts in your payment requests. + * + * @param exchangeCalculations An array of objects, where each object returns a currency and value + * for which you performed an exchange calculation. You can use the calculated amounts in your + * payment requests. + * @return the current {@code CalculateRateResponse} instance, allowing for method chaining + */ + public CalculateRateResponse exchangeCalculations( + List exchangeCalculations) { + this.exchangeCalculations = exchangeCalculations; + isSetExchangeCalculations = true; // mark as set + return this; + } + + public CalculateRateResponse addExchangeCalculationsItem( + CalculateRateResponseItem exchangeCalculationsItem) { + if (this.exchangeCalculations == null) { + this.exchangeCalculations = new ArrayList<>(); + } + this.exchangeCalculations.add(exchangeCalculationsItem); + return this; + } + + /** + * An array of objects, where each object returns a currency and value for which you performed an + * exchange calculation. You can use the calculated amounts in your payment requests. + * + * @return exchangeCalculations An array of objects, where each object returns a currency and + * value for which you performed an exchange calculation. You can use the calculated amounts + * in your payment requests. + */ + @JsonProperty(JSON_PROPERTY_EXCHANGE_CALCULATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getExchangeCalculations() { + return exchangeCalculations; + } + + /** + * An array of objects, where each object returns a currency and value for which you performed an + * exchange calculation. You can use the calculated amounts in your payment requests. + * + * @param exchangeCalculations An array of objects, where each object returns a currency and value + * for which you performed an exchange calculation. You can use the calculated amounts in your + * payment requests. + */ + @JsonProperty(JSON_PROPERTY_EXCHANGE_CALCULATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExchangeCalculations(List exchangeCalculations) { + this.exchangeCalculations = exchangeCalculations; + isSetExchangeCalculations = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public CalculateRateResponse includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + } + + /** Return true if this CalculateRateResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CalculateRateResponse calculateRateResponse = (CalculateRateResponse) o; + return Objects.equals(this.exchangeCalculations, calculateRateResponse.exchangeCalculations) + && Objects.equals( + this.isSetExchangeCalculations, calculateRateResponse.isSetExchangeCalculations); + } + + @Override + public int hashCode() { + return Objects.hash(exchangeCalculations, isSetExchangeCalculations); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CalculateRateResponse {\n"); + sb.append(" exchangeCalculations: ") + .append(toIndentedString(exchangeCalculations)) + .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 "); + } + + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetExchangeCalculations) { + addIfNull(nulls, JSON_PROPERTY_EXCHANGE_CALCULATIONS, this.exchangeCalculations); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + + /** + * Create an instance of CalculateRateResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CalculateRateResponse + * @throws JsonProcessingException if the JSON string is invalid with respect to + * CalculateRateResponse + */ + public static CalculateRateResponse fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CalculateRateResponse.class); + } + + /** + * Convert an instance of CalculateRateResponse 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/foreignexchange/CalculateRateResponseItem.java b/src/main/java/com/adyen/model/foreignexchange/CalculateRateResponseItem.java new file mode 100644 index 000000000..0068d7ea2 --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/CalculateRateResponseItem.java @@ -0,0 +1,400 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.foreignexchange; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +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.math.BigDecimal; +import java.util.*; + +/** The response parameters returned when you calculate an amount in a different currency. */ +@JsonPropertyOrder({ + CalculateRateResponseItem.JSON_PROPERTY_APPLIED_EXCHANGE_RATE, + CalculateRateResponseItem.JSON_PROPERTY_EXCHANGE_SIDE, + CalculateRateResponseItem.JSON_PROPERTY_SOURCE_AMOUNT, + CalculateRateResponseItem.JSON_PROPERTY_TARGET_AMOUNT, + CalculateRateResponseItem.JSON_PROPERTY_TYPE +}) +public class CalculateRateResponseItem { + public static final String JSON_PROPERTY_APPLIED_EXCHANGE_RATE = "appliedExchangeRate"; + private BigDecimal appliedExchangeRate; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetAppliedExchangeRate = false; + + public static final String JSON_PROPERTY_EXCHANGE_SIDE = "exchangeSide"; + private String exchangeSide; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetExchangeSide = false; + + public static final String JSON_PROPERTY_SOURCE_AMOUNT = "sourceAmount"; + private Amount sourceAmount; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetSourceAmount = false; + + public static final String JSON_PROPERTY_TARGET_AMOUNT = "targetAmount"; + private Amount targetAmount; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetTargetAmount = false; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetType = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + + public CalculateRateResponseItem() {} + + /** + * The exchange rate to convert the source currency to the target currency. This includes + * Adyen's markup. + * + * @param appliedExchangeRate The exchange rate to convert the source currency to the target + * currency. This includes Adyen's markup. + * @return the current {@code CalculateRateResponseItem} instance, allowing for method chaining + */ + public CalculateRateResponseItem appliedExchangeRate(BigDecimal appliedExchangeRate) { + this.appliedExchangeRate = appliedExchangeRate; + isSetAppliedExchangeRate = true; // mark as set + return this; + } + + /** + * The exchange rate to convert the source currency to the target currency. This includes + * Adyen's markup. + * + * @return appliedExchangeRate The exchange rate to convert the source currency to the target + * currency. This includes Adyen's markup. + */ + @JsonProperty(JSON_PROPERTY_APPLIED_EXCHANGE_RATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public BigDecimal getAppliedExchangeRate() { + return appliedExchangeRate; + } + + /** + * The exchange rate to convert the source currency to the target currency. This includes + * Adyen's markup. + * + * @param appliedExchangeRate The exchange rate to convert the source currency to the target + * currency. This includes Adyen's markup. + */ + @JsonProperty(JSON_PROPERTY_APPLIED_EXCHANGE_RATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAppliedExchangeRate(BigDecimal appliedExchangeRate) { + this.appliedExchangeRate = appliedExchangeRate; + isSetAppliedExchangeRate = true; // mark as set + } + + /** + * The operation performed on the source amount. Possible values: * **buy** * **sell** + * + * @param exchangeSide The operation performed on the source amount. Possible values: * **buy** * + * **sell** + * @return the current {@code CalculateRateResponseItem} instance, allowing for method chaining + */ + public CalculateRateResponseItem exchangeSide(String exchangeSide) { + this.exchangeSide = exchangeSide; + isSetExchangeSide = true; // mark as set + return this; + } + + /** + * The operation performed on the source amount. Possible values: * **buy** * **sell** + * + * @return exchangeSide The operation performed on the source amount. Possible values: * **buy** * + * **sell** + */ + @JsonProperty(JSON_PROPERTY_EXCHANGE_SIDE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getExchangeSide() { + return exchangeSide; + } + + /** + * The operation performed on the source amount. Possible values: * **buy** * **sell** + * + * @param exchangeSide The operation performed on the source amount. Possible values: * **buy** * + * **sell** + */ + @JsonProperty(JSON_PROPERTY_EXCHANGE_SIDE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExchangeSide(String exchangeSide) { + this.exchangeSide = exchangeSide; + isSetExchangeSide = true; // mark as set + } + + /** + * sourceAmount + * + * @param sourceAmount + * @return the current {@code CalculateRateResponseItem} instance, allowing for method chaining + */ + public CalculateRateResponseItem sourceAmount(Amount sourceAmount) { + this.sourceAmount = sourceAmount; + isSetSourceAmount = true; // mark as set + return this; + } + + /** + * Get sourceAmount + * + * @return sourceAmount + */ + @JsonProperty(JSON_PROPERTY_SOURCE_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Amount getSourceAmount() { + return sourceAmount; + } + + /** + * sourceAmount + * + * @param sourceAmount + */ + @JsonProperty(JSON_PROPERTY_SOURCE_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSourceAmount(Amount sourceAmount) { + this.sourceAmount = sourceAmount; + isSetSourceAmount = true; // mark as set + } + + /** + * targetAmount + * + * @param targetAmount + * @return the current {@code CalculateRateResponseItem} instance, allowing for method chaining + */ + public CalculateRateResponseItem targetAmount(Amount targetAmount) { + this.targetAmount = targetAmount; + isSetTargetAmount = true; // mark as set + return this; + } + + /** + * Get targetAmount + * + * @return targetAmount + */ + @JsonProperty(JSON_PROPERTY_TARGET_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Amount getTargetAmount() { + return targetAmount; + } + + /** + * targetAmount + * + * @param targetAmount + */ + @JsonProperty(JSON_PROPERTY_TARGET_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTargetAmount(Amount targetAmount) { + this.targetAmount = targetAmount; + isSetTargetAmount = true; // mark as set + } + + /** + * The type of transaction. Possible values: * **splitPayment**: for payments * **splitRefund**: + * for refunds + * + * @param type The type of transaction. Possible values: * **splitPayment**: for payments * + * **splitRefund**: for refunds + * @return the current {@code CalculateRateResponseItem} instance, allowing for method chaining + */ + public CalculateRateResponseItem type(String type) { + this.type = type; + isSetType = true; // mark as set + return this; + } + + /** + * The type of transaction. Possible values: * **splitPayment**: for payments * **splitRefund**: + * for refunds + * + * @return type The type of transaction. Possible values: * **splitPayment**: for payments * + * **splitRefund**: for refunds + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + /** + * The type of transaction. Possible values: * **splitPayment**: for payments * **splitRefund**: + * for refunds + * + * @param type The type of transaction. Possible values: * **splitPayment**: for payments * + * **splitRefund**: for refunds + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + isSetType = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public CalculateRateResponseItem includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + } + + /** Return true if this CalculateRateResponseItem object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CalculateRateResponseItem calculateRateResponseItem = (CalculateRateResponseItem) o; + return Objects.equals(this.appliedExchangeRate, calculateRateResponseItem.appliedExchangeRate) + && Objects.equals( + this.isSetAppliedExchangeRate, calculateRateResponseItem.isSetAppliedExchangeRate) + && Objects.equals(this.exchangeSide, calculateRateResponseItem.exchangeSide) + && Objects.equals(this.isSetExchangeSide, calculateRateResponseItem.isSetExchangeSide) + && Objects.equals(this.sourceAmount, calculateRateResponseItem.sourceAmount) + && Objects.equals(this.isSetSourceAmount, calculateRateResponseItem.isSetSourceAmount) + && Objects.equals(this.targetAmount, calculateRateResponseItem.targetAmount) + && Objects.equals(this.isSetTargetAmount, calculateRateResponseItem.isSetTargetAmount) + && Objects.equals(this.type, calculateRateResponseItem.type) + && Objects.equals(this.isSetType, calculateRateResponseItem.isSetType); + } + + @Override + public int hashCode() { + return Objects.hash( + appliedExchangeRate, + isSetAppliedExchangeRate, + exchangeSide, + isSetExchangeSide, + sourceAmount, + isSetSourceAmount, + targetAmount, + isSetTargetAmount, + type, + isSetType); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CalculateRateResponseItem {\n"); + sb.append(" appliedExchangeRate: ") + .append(toIndentedString(appliedExchangeRate)) + .append("\n"); + sb.append(" exchangeSide: ").append(toIndentedString(exchangeSide)).append("\n"); + sb.append(" sourceAmount: ").append(toIndentedString(sourceAmount)).append("\n"); + sb.append(" targetAmount: ").append(toIndentedString(targetAmount)).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 "); + } + + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetAppliedExchangeRate) { + addIfNull(nulls, JSON_PROPERTY_APPLIED_EXCHANGE_RATE, this.appliedExchangeRate); + } + if (isSetExchangeSide) { + addIfNull(nulls, JSON_PROPERTY_EXCHANGE_SIDE, this.exchangeSide); + } + if (isSetSourceAmount) { + addIfNull(nulls, JSON_PROPERTY_SOURCE_AMOUNT, this.sourceAmount); + } + if (isSetTargetAmount) { + addIfNull(nulls, JSON_PROPERTY_TARGET_AMOUNT, this.targetAmount); + } + if (isSetType) { + addIfNull(nulls, JSON_PROPERTY_TYPE, this.type); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + + /** + * Create an instance of CalculateRateResponseItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of CalculateRateResponseItem + * @throws JsonProcessingException if the JSON string is invalid with respect to + * CalculateRateResponseItem + */ + public static CalculateRateResponseItem fromJson(String jsonString) + throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CalculateRateResponseItem.class); + } + + /** + * Convert an instance of CalculateRateResponseItem 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/foreignexchange/DefaultErrorResponseEntity.java b/src/main/java/com/adyen/model/foreignexchange/DefaultErrorResponseEntity.java new file mode 100644 index 000000000..2ad0e8980 --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/DefaultErrorResponseEntity.java @@ -0,0 +1,547 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.foreignexchange; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +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.*; +import java.util.ArrayList; +import java.util.List; + +/** Standardized error response following RFC-7807 format */ +@JsonPropertyOrder({ + DefaultErrorResponseEntity.JSON_PROPERTY_DETAIL, + DefaultErrorResponseEntity.JSON_PROPERTY_ERROR_CODE, + DefaultErrorResponseEntity.JSON_PROPERTY_INSTANCE, + DefaultErrorResponseEntity.JSON_PROPERTY_INVALID_FIELDS, + DefaultErrorResponseEntity.JSON_PROPERTY_REQUEST_ID, + DefaultErrorResponseEntity.JSON_PROPERTY_STATUS, + DefaultErrorResponseEntity.JSON_PROPERTY_TITLE, + DefaultErrorResponseEntity.JSON_PROPERTY_TYPE +}) +public class DefaultErrorResponseEntity { + public static final String JSON_PROPERTY_DETAIL = "detail"; + private String detail; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetDetail = false; + + public static final String JSON_PROPERTY_ERROR_CODE = "errorCode"; + private String errorCode; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetErrorCode = false; + + public static final String JSON_PROPERTY_INSTANCE = "instance"; + private String instance; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetInstance = false; + + public static final String JSON_PROPERTY_INVALID_FIELDS = "invalidFields"; + private List invalidFields; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetInvalidFields = false; + + public static final String JSON_PROPERTY_REQUEST_ID = "requestId"; + private String requestId; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetRequestId = false; + + public static final String JSON_PROPERTY_STATUS = "status"; + private Integer status; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetStatus = false; + + public static final String JSON_PROPERTY_TITLE = "title"; + private String title; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetTitle = false; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetType = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + + public DefaultErrorResponseEntity() {} + + /** + * A human-readable explanation specific to this occurrence of the problem. + * + * @param detail A human-readable explanation specific to this occurrence of the problem. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity detail(String detail) { + this.detail = detail; + isSetDetail = true; // mark as set + return this; + } + + /** + * A human-readable explanation specific to this occurrence of the problem. + * + * @return detail A human-readable explanation specific to this occurrence of the problem. + */ + @JsonProperty(JSON_PROPERTY_DETAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDetail() { + return detail; + } + + /** + * A human-readable explanation specific to this occurrence of the problem. + * + * @param detail A human-readable explanation specific to this occurrence of the problem. + */ + @JsonProperty(JSON_PROPERTY_DETAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDetail(String detail) { + this.detail = detail; + isSetDetail = true; // mark as set + } + + /** + * Unique business error code. + * + * @param errorCode Unique business error code. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity errorCode(String errorCode) { + this.errorCode = errorCode; + isSetErrorCode = true; // mark as set + return this; + } + + /** + * Unique business error code. + * + * @return errorCode Unique business error code. + */ + @JsonProperty(JSON_PROPERTY_ERROR_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getErrorCode() { + return errorCode; + } + + /** + * Unique business error code. + * + * @param errorCode Unique business error code. + */ + @JsonProperty(JSON_PROPERTY_ERROR_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + isSetErrorCode = true; // mark as set + } + + /** + * A URI that identifies the specific occurrence of the problem if applicable. + * + * @param instance A URI that identifies the specific occurrence of the problem if applicable. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity instance(String instance) { + this.instance = instance; + isSetInstance = true; // mark as set + return this; + } + + /** + * A URI that identifies the specific occurrence of the problem if applicable. + * + * @return instance A URI that identifies the specific occurrence of the problem if applicable. + */ + @JsonProperty(JSON_PROPERTY_INSTANCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getInstance() { + return instance; + } + + /** + * A URI that identifies the specific occurrence of the problem if applicable. + * + * @param instance A URI that identifies the specific occurrence of the problem if applicable. + */ + @JsonProperty(JSON_PROPERTY_INSTANCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setInstance(String instance) { + this.instance = instance; + isSetInstance = true; // mark as set + } + + /** + * Array of fields with validation errors when applicable. + * + * @param invalidFields Array of fields with validation errors when applicable. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity invalidFields(List invalidFields) { + this.invalidFields = invalidFields; + isSetInvalidFields = true; // mark as set + return this; + } + + public DefaultErrorResponseEntity addInvalidFieldsItem(InvalidField invalidFieldsItem) { + if (this.invalidFields == null) { + this.invalidFields = new ArrayList<>(); + } + this.invalidFields.add(invalidFieldsItem); + return this; + } + + /** + * Array of fields with validation errors when applicable. + * + * @return invalidFields Array of fields with validation errors when applicable. + */ + @JsonProperty(JSON_PROPERTY_INVALID_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getInvalidFields() { + return invalidFields; + } + + /** + * Array of fields with validation errors when applicable. + * + * @param invalidFields Array of fields with validation errors when applicable. + */ + @JsonProperty(JSON_PROPERTY_INVALID_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setInvalidFields(List invalidFields) { + this.invalidFields = invalidFields; + isSetInvalidFields = true; // mark as set + } + + /** + * The unique reference for the request. + * + * @param requestId The unique reference for the request. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity requestId(String requestId) { + this.requestId = requestId; + isSetRequestId = true; // mark as set + return this; + } + + /** + * The unique reference for the request. + * + * @return requestId The unique reference for the request. + */ + @JsonProperty(JSON_PROPERTY_REQUEST_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRequestId() { + return requestId; + } + + /** + * The unique reference for the request. + * + * @param requestId The unique reference for the request. + */ + @JsonProperty(JSON_PROPERTY_REQUEST_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRequestId(String requestId) { + this.requestId = requestId; + isSetRequestId = true; // mark as set + } + + /** + * The HTTP status code. + * + * @param status The HTTP status code. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity status(Integer status) { + this.status = status; + isSetStatus = true; // mark as set + return this; + } + + /** + * The HTTP status code. + * + * @return status The HTTP status code. + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getStatus() { + return status; + } + + /** + * The HTTP status code. + * + * @param status The HTTP status code. + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(Integer status) { + this.status = status; + isSetStatus = true; // mark as set + } + + /** + * A short, human-readable summary of the problem type. + * + * @param title A short, human-readable summary of the problem type. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity title(String title) { + this.title = title; + isSetTitle = true; // mark as set + return this; + } + + /** + * A short, human-readable summary of the problem type. + * + * @return title A short, human-readable summary of the problem type. + */ + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTitle() { + return title; + } + + /** + * A short, human-readable summary of the problem type. + * + * @param title A short, human-readable summary of the problem type. + */ + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTitle(String title) { + this.title = title; + isSetTitle = true; // mark as set + } + + /** + * A URI that identifies the validation error type. It points to human-readable documentation for + * the problem type. + * + * @param type A URI that identifies the validation error type. It points to human-readable + * documentation for the problem type. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity type(String type) { + this.type = type; + isSetType = true; // mark as set + return this; + } + + /** + * A URI that identifies the validation error type. It points to human-readable documentation for + * the problem type. + * + * @return type A URI that identifies the validation error type. It points to human-readable + * documentation for the problem type. + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + /** + * A URI that identifies the validation error type. It points to human-readable documentation for + * the problem type. + * + * @param type A URI that identifies the validation error type. It points to human-readable + * documentation for the problem type. + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + isSetType = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public DefaultErrorResponseEntity includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + } + + /** Return true if this DefaultErrorResponseEntity object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DefaultErrorResponseEntity defaultErrorResponseEntity = (DefaultErrorResponseEntity) o; + return Objects.equals(this.detail, defaultErrorResponseEntity.detail) + && Objects.equals(this.isSetDetail, defaultErrorResponseEntity.isSetDetail) + && Objects.equals(this.errorCode, defaultErrorResponseEntity.errorCode) + && Objects.equals(this.isSetErrorCode, defaultErrorResponseEntity.isSetErrorCode) + && Objects.equals(this.instance, defaultErrorResponseEntity.instance) + && Objects.equals(this.isSetInstance, defaultErrorResponseEntity.isSetInstance) + && Objects.equals(this.invalidFields, defaultErrorResponseEntity.invalidFields) + && Objects.equals(this.isSetInvalidFields, defaultErrorResponseEntity.isSetInvalidFields) + && Objects.equals(this.requestId, defaultErrorResponseEntity.requestId) + && Objects.equals(this.isSetRequestId, defaultErrorResponseEntity.isSetRequestId) + && Objects.equals(this.status, defaultErrorResponseEntity.status) + && Objects.equals(this.isSetStatus, defaultErrorResponseEntity.isSetStatus) + && Objects.equals(this.title, defaultErrorResponseEntity.title) + && Objects.equals(this.isSetTitle, defaultErrorResponseEntity.isSetTitle) + && Objects.equals(this.type, defaultErrorResponseEntity.type) + && Objects.equals(this.isSetType, defaultErrorResponseEntity.isSetType); + } + + @Override + public int hashCode() { + return Objects.hash( + detail, + isSetDetail, + errorCode, + isSetErrorCode, + instance, + isSetInstance, + invalidFields, + isSetInvalidFields, + requestId, + isSetRequestId, + status, + isSetStatus, + title, + isSetTitle, + type, + isSetType); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DefaultErrorResponseEntity {\n"); + sb.append(" detail: ").append(toIndentedString(detail)).append("\n"); + sb.append(" errorCode: ").append(toIndentedString(errorCode)).append("\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" invalidFields: ").append(toIndentedString(invalidFields)).append("\n"); + sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).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 "); + } + + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetDetail) { + addIfNull(nulls, JSON_PROPERTY_DETAIL, this.detail); + } + if (isSetErrorCode) { + addIfNull(nulls, JSON_PROPERTY_ERROR_CODE, this.errorCode); + } + if (isSetInstance) { + addIfNull(nulls, JSON_PROPERTY_INSTANCE, this.instance); + } + if (isSetInvalidFields) { + addIfNull(nulls, JSON_PROPERTY_INVALID_FIELDS, this.invalidFields); + } + if (isSetRequestId) { + addIfNull(nulls, JSON_PROPERTY_REQUEST_ID, this.requestId); + } + if (isSetStatus) { + addIfNull(nulls, JSON_PROPERTY_STATUS, this.status); + } + if (isSetTitle) { + addIfNull(nulls, JSON_PROPERTY_TITLE, this.title); + } + if (isSetType) { + addIfNull(nulls, JSON_PROPERTY_TYPE, this.type); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + + /** + * Create an instance of DefaultErrorResponseEntity given an JSON string + * + * @param jsonString JSON string + * @return An instance of DefaultErrorResponseEntity + * @throws JsonProcessingException if the JSON string is invalid with respect to + * DefaultErrorResponseEntity + */ + public static DefaultErrorResponseEntity fromJson(String jsonString) + throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, DefaultErrorResponseEntity.class); + } + + /** + * Convert an instance of DefaultErrorResponseEntity 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/foreignexchange/ExchangeSide.java b/src/main/java/com/adyen/model/foreignexchange/ExchangeSide.java new file mode 100644 index 000000000..7dae9895d --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/ExchangeSide.java @@ -0,0 +1,58 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.foreignexchange; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.*; +import java.util.logging.Logger; + +/** Gets or Sets ExchangeSide */ +public enum ExchangeSide { + BUY("buy"), + + SELL("sell"); + + private static final Logger LOG = Logger.getLogger(ExchangeSide.class.getName()); + + private String value; + + ExchangeSide(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ExchangeSide fromValue(String value) { + for (ExchangeSide b : ExchangeSide.values()) { + if (b.value.equals(value)) { + return b; + } + } + // handling unexpected value + LOG.warning( + "ExchangeSide: unexpected enum value '" + + value + + "' - Supported values are " + + Arrays.toString(ExchangeSide.values())); + return null; + } +} diff --git a/src/main/java/com/adyen/model/foreignexchange/InvalidField.java b/src/main/java/com/adyen/model/foreignexchange/InvalidField.java new file mode 100644 index 000000000..49a98de57 --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/InvalidField.java @@ -0,0 +1,273 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.foreignexchange; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +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.*; + +/** InvalidField */ +@JsonPropertyOrder({ + InvalidField.JSON_PROPERTY_NAME, + InvalidField.JSON_PROPERTY_VALUE, + InvalidField.JSON_PROPERTY_MESSAGE +}) +public class InvalidField { + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetName = false; + + public static final String JSON_PROPERTY_VALUE = "value"; + private String value; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetValue = false; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetMessage = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + + public InvalidField() {} + + /** + * The field that has an invalid value. + * + * @param name The field that has an invalid value. + * @return the current {@code InvalidField} instance, allowing for method chaining + */ + public InvalidField name(String name) { + this.name = name; + isSetName = true; // mark as set + return this; + } + + /** + * The field that has an invalid value. + * + * @return name The field that has an invalid value. + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + /** + * The field that has an invalid value. + * + * @param name The field that has an invalid value. + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + isSetName = true; // mark as set + } + + /** + * The invalid value. + * + * @param value The invalid value. + * @return the current {@code InvalidField} instance, allowing for method chaining + */ + public InvalidField value(String value) { + this.value = value; + isSetValue = true; // mark as set + return this; + } + + /** + * The invalid value. + * + * @return value The invalid value. + */ + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getValue() { + return value; + } + + /** + * The invalid value. + * + * @param value The invalid value. + */ + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setValue(String value) { + this.value = value; + isSetValue = true; // mark as set + } + + /** + * Description of the validation error. + * + * @param message Description of the validation error. + * @return the current {@code InvalidField} instance, allowing for method chaining + */ + public InvalidField message(String message) { + this.message = message; + isSetMessage = true; // mark as set + return this; + } + + /** + * Description of the validation error. + * + * @return message Description of the validation error. + */ + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + /** + * Description of the validation error. + * + * @param message Description of the validation error. + */ + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + isSetMessage = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public InvalidField includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + } + + /** Return true if this InvalidField object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InvalidField invalidField = (InvalidField) o; + return Objects.equals(this.name, invalidField.name) + && Objects.equals(this.isSetName, invalidField.isSetName) + && Objects.equals(this.value, invalidField.value) + && Objects.equals(this.isSetValue, invalidField.isSetValue) + && Objects.equals(this.message, invalidField.message) + && Objects.equals(this.isSetMessage, invalidField.isSetMessage); + } + + @Override + public int hashCode() { + return Objects.hash(name, isSetName, value, isSetValue, message, isSetMessage); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InvalidField {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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 "); + } + + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetName) { + addIfNull(nulls, JSON_PROPERTY_NAME, this.name); + } + if (isSetValue) { + addIfNull(nulls, JSON_PROPERTY_VALUE, this.value); + } + if (isSetMessage) { + addIfNull(nulls, JSON_PROPERTY_MESSAGE, this.message); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + + /** + * Create an instance of InvalidField given an JSON string + * + * @param jsonString JSON string + * @return An instance of InvalidField + * @throws JsonProcessingException if the JSON string is invalid with respect to InvalidField + */ + public static InvalidField fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, InvalidField.class); + } + + /** + * Convert an instance of InvalidField 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/foreignexchange/JSON.java b/src/main/java/com/adyen/model/foreignexchange/JSON.java new file mode 100644 index 000000000..34b220ab7 --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/JSON.java @@ -0,0 +1,251 @@ +package com.adyen.model.foreignexchange; + +import com.adyen.serializer.ByteArrayDeserializer; +import com.adyen.serializer.ByteArraySerializer; +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.ext.ContextResolver; +import java.text.DateFormat; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class JSON implements ContextResolver { + private static ObjectMapper mapper; + + private JSON() { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, true); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.registerModule(new JavaTimeModule()); + // Custom ByteSerializer + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(byte[].class, new ByteArraySerializer()); + simpleModule.addDeserializer(byte[].class, new ByteArrayDeserializer()); + mapper.registerModule(simpleModule); + } + + /** + * Set the date format for JSON (de)serialization with Date properties. + * + * @param dateFormat Date format + */ + public void setDateFormat(DateFormat dateFormat) { + mapper.setDateFormat(dateFormat); + } + + @Override + public ObjectMapper getContext(Class type) { + return mapper; + } + + /** + * Get the object mapper + * + * @return object mapper + */ + public static ObjectMapper getMapper() { + return mapper; + } + + /** + * Returns the target model class that should be used to deserialize the input data. The + * discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param modelClass The class that contains the discriminator mappings. + */ + public static Class getClassForElement(JsonNode node, Class modelClass) { + ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); + if (cdm != null) { + return cdm.getClassForElement(node, new HashSet<>()); + } + return null; + } + + /** Helper class to register the discriminator mappings. */ + private static class ClassDiscriminatorMapping { + // The model class name. + Class modelClass; + // The name of the discriminator property. + String discriminatorName; + // The discriminator mappings for a model class. + Map> discriminatorMappings; + + // Constructs a new class discriminator. + ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { + modelClass = cls; + discriminatorName = propertyName; + discriminatorMappings = new HashMap<>(); + if (mappings != null) { + discriminatorMappings.putAll(mappings); + } + } + + // Return the name of the discriminator property for this model class. + String getDiscriminatorPropertyName() { + return discriminatorName; + } + + // Return the discriminator value or null if the discriminator is not + // present in the payload. + String getDiscriminatorValue(JsonNode node) { + // Determine the value of the discriminator property in the input data. + if (discriminatorName != null) { + // Get the value of the discriminator property, if present in the input payload. + node = node.get(discriminatorName); + if (node != null && node.isValueNode()) { + String discrValue = node.asText(); + if (discrValue != null) { + return discrValue; + } + } + } + return null; + } + + /** + * Returns the target model class that should be used to deserialize the input data. This + * function can be invoked for anyOf/oneOf composed models with discriminator mappings. The + * discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. + */ + Class getClassForElement(JsonNode node, Set> visitedClasses) { + if (visitedClasses.contains(modelClass)) { + // Class has already been visited. + return null; + } + // Determine the value of the discriminator property in the input data. + String discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + return null; + } + Class cls = discriminatorMappings.get(discrValue); + // It may not be sufficient to return this cls directly because that target class + // may itself be a composed schema, possibly with its own discriminator. + visitedClasses.add(modelClass); + for (Class childClass : discriminatorMappings.values()) { + ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); + if (childCdm == null) { + continue; + } + if (!discriminatorName.equals(childCdm.discriminatorName)) { + discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + continue; + } + } + if (childCdm != null) { + // Recursively traverse the discriminator mappings. + Class childDiscr = childCdm.getClassForElement(node, visitedClasses); + if (childDiscr != null) { + return childDiscr; + } + } + } + return cls; + } + } + + /** + * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. + * + *

The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, so + * it's not possible to use the instanceof keyword. + * + * @param modelClass A OpenAPI model class. + * @param inst The instance object. + */ + public static boolean isInstanceOf( + Class modelClass, Object inst, Set> visitedClasses) { + if (modelClass.isInstance(inst)) { + // This handles the 'allOf' use case with single parent inheritance. + return true; + } + if (visitedClasses.contains(modelClass)) { + // This is to prevent infinite recursion when the composed schemas have + // a circular dependency. + return false; + } + visitedClasses.add(modelClass); + + // Traverse the oneOf/anyOf composed schemas. + Map descendants = modelDescendants.get(modelClass); + if (descendants != null) { + for (GenericType childType : descendants.values()) { + if (isInstanceOf(childType.getRawType(), inst, visitedClasses)) { + return true; + } + } + } + return false; + } + + /** A map of discriminators for all model classes. */ + private static final Map, ClassDiscriminatorMapping> modelDiscriminators = + new HashMap, ClassDiscriminatorMapping>(); + + /** A map of oneOf/anyOf descendants for each model class. */ + private static final Map, Map> modelDescendants = new HashMap<>(); + + /** + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator( + Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = + new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + modelDiscriminators.put(modelClass, m); + } + + /** + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ + public static void registerDescendants( + Class modelClass, Map descendants) { + modelDescendants.put(modelClass, descendants); + } + + private static JSON json; + + static { + json = new JSON(); + } + + /** + * Get the default JSON instance. + * + * @return the default JSON instance + */ + public static JSON getDefault() { + return json; + } + + /** + * Set the default JSON instance. + * + * @param json JSON instance to be used + */ + public static void setDefault(JSON json) { + JSON.json = json; + } +} diff --git a/src/main/java/com/adyen/model/foreignexchange/RateType.java b/src/main/java/com/adyen/model/foreignexchange/RateType.java new file mode 100644 index 000000000..bd73f413c --- /dev/null +++ b/src/main/java/com/adyen/model/foreignexchange/RateType.java @@ -0,0 +1,62 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.foreignexchange; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.*; +import java.util.logging.Logger; + +/** Gets or Sets RateType */ +public enum RateType { + SPLITPAYMENT("splitPayment"), + + BALANCECONVERSION("balanceConversion"), + + TRANSFER("transfer"), + + SPLITREFUND("splitRefund"); + + private static final Logger LOG = Logger.getLogger(RateType.class.getName()); + + private String value; + + RateType(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static RateType fromValue(String value) { + for (RateType b : RateType.values()) { + if (b.value.equals(value)) { + return b; + } + } + // handling unexpected value + LOG.warning( + "RateType: unexpected enum value '" + + value + + "' - Supported values are " + + Arrays.toString(RateType.values())); + return null; + } +} diff --git a/src/main/java/com/adyen/service/foreignexchange/RatesApi.java b/src/main/java/com/adyen/service/foreignexchange/RatesApi.java new file mode 100644 index 000000000..9163f513d --- /dev/null +++ b/src/main/java/com/adyen/service/foreignexchange/RatesApi.java @@ -0,0 +1,83 @@ +/* + * Foreign Exchange API + * + * The version of the OpenAPI document: 1 + * + * + * 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.service.foreignexchange; + +import com.adyen.Client; +import com.adyen.Service; +import com.adyen.constants.ApiConstants; +import com.adyen.model.RequestOptions; +import com.adyen.model.foreignexchange.CalculateRateRequest; +import com.adyen.model.foreignexchange.CalculateRateResponse; +import com.adyen.service.exception.ApiException; +import com.adyen.service.resource.Resource; +import java.io.IOException; + +public class RatesApi extends Service { + + public static final String API_VERSION = "1"; + + protected String baseURL; + + /** + * Rates constructor in {@link com.adyen.service.foreignexchange package}. + * + * @param client {@link Client } (required) + */ + public RatesApi(Client client) { + super(client); + this.baseURL = createBaseURL("https://balanceplatform-api-test.adyen.com/fx/api/v1"); + } + + /** + * Rates constructor in {@link com.adyen.service.foreignexchange package}. Please use this + * constructor only if you would like to pass along your own url for routing or testing purposes. + * The latest API version is defined in this class as a constant. + * + * @param client {@link Client } (required) + * @param baseURL {@link String } (required) + */ + public RatesApi(Client client, String baseURL) { + super(client); + this.baseURL = baseURL; + } + + /** + * Calculate amount in a different currency + * + * @param calculateRateRequest {@link CalculateRateRequest } (required) + * @return {@link CalculateRateResponse } + * @throws ApiException if fails to make API call + */ + public CalculateRateResponse calculate(CalculateRateRequest calculateRateRequest) + throws ApiException, IOException { + return calculate(calculateRateRequest, null); + } + + /** + * Calculate amount in a different currency + * + * @param calculateRateRequest {@link CalculateRateRequest } (required) + * @param requestOptions {@link RequestOptions } Object to store additional HTTP headers such as + * idempotency-keys (optional) + * @return {@link CalculateRateResponse } + * @throws ApiException if fails to make API call + */ + public CalculateRateResponse calculate( + CalculateRateRequest calculateRateRequest, RequestOptions requestOptions) + throws ApiException, IOException { + String requestBody = calculateRateRequest.toJson(); + Resource resource = new Resource(this, this.baseURL + "/rates/calculate", null); + String jsonResult = + resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, null); + return CalculateRateResponse.fromJson(jsonResult); + } +}