From 1ba3bbaaa4a4f35d0602bd21b8c56280b828fb85 Mon Sep 17 00:00:00 2001 From: Wouter Boereboom <62436079+wboereboom@users.noreply.github.com> Date: Thu, 6 Jul 2023 15:18:00 +0200 Subject: [PATCH] rename Transfers service to TransfersApi and move capital endpoints into TransfersApi (#1072) --- .gitignore | 1 + Makefile | 6 +- .../AULocalAccountIdentification.java | 209 +--- .../transfers/AbstractOpenApiSchema.java | 7 +- .../AdditionalBankIdentification.java | 185 +--- .../com/adyen/model/transfers/Address2.java | 231 ++--- .../com/adyen/model/transfers/Amount.java | 171 +--- .../BRLocalAccountIdentification.java | 224 +---- .../adyen/model/transfers/BankAccountV3.java | 175 +--- .../BankAccountV3AccountIdentification.java | 943 +++++++++--------- .../CALocalAccountIdentification.java | 257 ++--- .../CZLocalAccountIdentification.java | 209 +--- .../adyen/model/transfers/CapitalBalance.java | 221 ++++ .../adyen/model/transfers/CapitalGrant.java | 418 ++++++++ .../model/transfers/CapitalGrantInfo.java | 191 ++++ .../adyen/model/transfers/CapitalGrants.java | 136 +++ .../adyen/model/transfers/Counterparty2.java | 191 ++++ .../model/transfers/CounterpartyInfoV3.java | 180 +--- .../adyen/model/transfers/CounterpartyV3.java | 194 +--- .../DKLocalAccountIdentification.java | 209 +--- .../java/com/adyen/model/transfers/Fee.java | 129 +++ .../HULocalAccountIdentification.java | 194 +--- .../transfers/IbanAccountIdentification.java | 194 +--- .../adyen/model/transfers/InvalidField.java | 190 +--- .../java/com/adyen/model/transfers/JSON.java | 664 +++++------- .../com/adyen/model/transfers/JSONObject.java | 174 +--- .../com/adyen/model/transfers/JSONPath.java | 152 +-- .../java/com/adyen/model/transfers/Link.java | 152 +-- .../java/com/adyen/model/transfers/Links.java | 166 +-- .../adyen/model/transfers/MerchantData.java | 194 +--- .../NOLocalAccountIdentification.java | 194 +--- .../adyen/model/transfers/NameLocation.java | 222 ++--- .../NumberAndBicAccountIdentification.java | 223 +---- .../PLLocalAccountIdentification.java | 194 +--- .../model/transfers/PartyIdentification2.java | 264 ++--- .../model/transfers/PaymentInstrument.java | 194 +--- .../com/adyen/model/transfers/Repayment.java | 192 ++++ .../adyen/model/transfers/RepaymentTerm.java | 159 +++ .../model/transfers/ResourceReference.java | 180 +--- .../model/transfers/RestServiceError.java | 280 ++---- .../SELocalAccountIdentification.java | 209 +--- .../SGLocalAccountIdentification.java | 208 +--- .../model/transfers/ThresholdRepayment.java | 129 +++ .../adyen/model/transfers/Transaction.java | 457 +++------ .../transfers/TransactionSearchResponse.java | 174 +--- .../com/adyen/model/transfers/Transfer.java | 512 ++++------ .../adyen/model/transfers/TransferInfo.java | 344 ++----- .../UKLocalAccountIdentification.java | 209 +--- .../USLocalAccountIdentification.java | 242 +---- .../UltimatePartyIdentification.java | 263 ++--- .../java/com/adyen/service/Transfers.java | 45 - .../service/{ => transfers}/CapitalApi.java | 15 +- .../service/transfers/TransactionsApi.java | 2 +- .../adyen/service/transfers/TransfersApi.java | 2 +- src/test/java/com/adyen/CapitalTest.java | 50 - src/test/java/com/adyen/TransfersTest.java | 51 +- 56 files changed, 4547 insertions(+), 7034 deletions(-) create mode 100644 src/main/java/com/adyen/model/transfers/CapitalBalance.java create mode 100644 src/main/java/com/adyen/model/transfers/CapitalGrant.java create mode 100644 src/main/java/com/adyen/model/transfers/CapitalGrantInfo.java create mode 100644 src/main/java/com/adyen/model/transfers/CapitalGrants.java create mode 100644 src/main/java/com/adyen/model/transfers/Counterparty2.java create mode 100644 src/main/java/com/adyen/model/transfers/Fee.java create mode 100644 src/main/java/com/adyen/model/transfers/Repayment.java create mode 100644 src/main/java/com/adyen/model/transfers/RepaymentTerm.java create mode 100644 src/main/java/com/adyen/model/transfers/ThresholdRepayment.java delete mode 100644 src/main/java/com/adyen/service/Transfers.java rename src/main/java/com/adyen/service/{ => transfers}/CapitalApi.java (72%) delete mode 100644 src/test/java/com/adyen/CapitalTest.java diff --git a/.gitignore b/.gitignore index 9710bb122..74dd352ae 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.iml /target/** .DS_Store +.vscode diff --git a/Makefile b/Makefile index 28e495aee..b49191aa1 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ openapi-generator-cli:=java -jar $(openapi-generator-jar) generator:=java library:=jersey3 -modelGen:=balancecontrol balanceplatform binlookup capital checkout dataprotection legalentitymanagement management payment payout posterminalmanagement recurring transfers storedvalue configurationwebhooks reportwebhooks transferwebhooks +modelGen:=balancecontrol balanceplatform binlookup checkout dataprotection legalentitymanagement management payment payout posterminalmanagement recurring transfers storedvalue configurationwebhooks reportwebhooks transferwebhooks models:=src/main/java/com/adyen/model output:=target/out @@ -19,8 +19,6 @@ binlookup: smallServiceName=BinLookupApi checkout: spec=CheckoutService-v70 dataprotection: spec=DataProtectionService-v1 dataprotection: smallServiceName=DataProtectionApi -capital: spec=GrantService-v3 -capital: smallServiceName=CapitalApi storedvalue: spec=StoredValueService-v46 storedvalue: smallServiceName=StoredValueApi posterminalmanagement: spec=TfmAPIService-v1 @@ -68,7 +66,7 @@ $(modelGen): target/spec $(openapi-generator-jar) # Full service + models automation bigServices:=balanceplatform checkout payout management legalentitymanagement transfers -singleFileServices:=balancecontrol binlookup dataprotection storedvalue posterminalmanagement recurring payment capital +singleFileServices:=balancecontrol binlookup dataprotection storedvalue posterminalmanagement recurring payment services: $(bigServices) $(singleFileServices) diff --git a/src/main/java/com/adyen/model/transfers/AULocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/AULocalAccountIdentification.java index 7e31d2e4a..97f7d7487 100644 --- a/src/main/java/com/adyen/model/transfers/AULocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/AULocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,54 +14,38 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * AULocalAccountIdentification */ +@JsonPropertyOrder({ + AULocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + AULocalAccountIdentification.JSON_PROPERTY_BSB_CODE, + AULocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class AULocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; - public static final String SERIALIZED_NAME_BSB_CODE = "bsbCode"; - @SerializedName(SERIALIZED_NAME_BSB_CODE) + public static final String JSON_PROPERTY_BSB_CODE = "bsbCode"; private String bsbCode; /** * **auLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { AULOCAL("auLocal"); @@ -71,6 +55,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -80,6 +65,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -88,30 +74,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.AULOCAL; public AULocalAccountIdentification() { } public AULocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -121,19 +92,22 @@ public AULocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The bank account number, without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public AULocalAccountIdentification bsbCode(String bsbCode) { - this.bsbCode = bsbCode; return this; } @@ -143,19 +117,22 @@ public AULocalAccountIdentification bsbCode(String bsbCode) { * @return bsbCode **/ @ApiModelProperty(required = true, value = "The 6-digit [Bank State Branch (BSB) code](https://en.wikipedia.org/wiki/Bank_state_branch), without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_BSB_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBsbCode() { return bsbCode; } + @JsonProperty(JSON_PROPERTY_BSB_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBsbCode(String bsbCode) { this.bsbCode = bsbCode; } public AULocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -165,18 +142,24 @@ public AULocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**auLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this AULocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -218,121 +201,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("bsbCode"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("bsbCode"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(AULocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to AULocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (AULocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in AULocalAccountIdentification is not found in the empty JSON string", AULocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AULocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `AULocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : AULocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // validate the optional field bsbCode - if (jsonObj.get("bsbCode") != null && !jsonObj.get("bsbCode").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `bsbCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bsbCode").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!AULocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'AULocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(AULocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, AULocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public AULocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of AULocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of AULocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to AULocalAccountIdentification - */ - public static AULocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, AULocalAccountIdentification.class); +/** + * Create an instance of AULocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of AULocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to AULocalAccountIdentification + */ + public static AULocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, AULocalAccountIdentification.class); } - - /** +/** * Convert an instance of AULocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/AbstractOpenApiSchema.java b/src/main/java/com/adyen/model/transfers/AbstractOpenApiSchema.java index 6c7266e5b..fc37ace6e 100644 --- a/src/main/java/com/adyen/model/transfers/AbstractOpenApiSchema.java +++ b/src/main/java/com/adyen/model/transfers/AbstractOpenApiSchema.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -17,9 +17,12 @@ import java.util.Map; import jakarta.ws.rs.core.GenericType; +import com.fasterxml.jackson.annotation.JsonValue; + /** * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ + public abstract class AbstractOpenApiSchema { // store the actual instance of the schema/object @@ -48,7 +51,7 @@ public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { * * @return an instance of the actual schema/object */ - //@JsonValue + @JsonValue public Object getActualInstance() {return instance;} /** diff --git a/src/main/java/com/adyen/model/transfers/AdditionalBankIdentification.java b/src/main/java/com/adyen/model/transfers/AdditionalBankIdentification.java index 1242f4197..a7801c9a4 100644 --- a/src/main/java/com/adyen/model/transfers/AdditionalBankIdentification.java +++ b/src/main/java/com/adyen/model/transfers/AdditionalBankIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,50 +14,34 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * AdditionalBankIdentification */ +@JsonPropertyOrder({ + AdditionalBankIdentification.JSON_PROPERTY_CODE, + AdditionalBankIdentification.JSON_PROPERTY_TYPE +}) public class AdditionalBankIdentification { - public static final String SERIALIZED_NAME_CODE = "code"; - @SerializedName(SERIALIZED_NAME_CODE) + public static final String JSON_PROPERTY_CODE = "code"; private String code; /** * The type of additional bank identification, depending on the country. Possible values: * **gbSortCode**: The 6-digit [UK sort code](https://en.wikipedia.org/wiki/Sort_code), without separators or spaces * **usRoutingNumber**: The 9-digit [routing number](https://en.wikipedia.org/wiki/ABA_routing_transit_number), without separators or spaces. */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { GBSORTCODE("gbSortCode"), @@ -69,6 +53,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -78,6 +63,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -86,30 +72,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type; public AdditionalBankIdentification() { } public AdditionalBankIdentification code(String code) { - this.code = code; return this; } @@ -119,19 +90,22 @@ public AdditionalBankIdentification code(String code) { * @return code **/ @ApiModelProperty(value = "The value of the additional bank identification.") + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getCode() { return code; } + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCode(String code) { this.code = code; } public AdditionalBankIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -141,18 +115,24 @@ public AdditionalBankIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(value = "The type of additional bank identification, depending on the country. Possible values: * **gbSortCode**: The 6-digit [UK sort code](https://en.wikipedia.org/wiki/Sort_code), without separators or spaces * **usRoutingNumber**: The 9-digit [routing number](https://en.wikipedia.org/wiki/ABA_routing_transit_number), without separators or spaces.") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this AdditionalBankIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -192,106 +172,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("code"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(AdditionalBankIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to AdditionalBankIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (AdditionalBankIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalBankIdentification is not found in the empty JSON string", AdditionalBankIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalBankIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `AdditionalBankIdentification` properties.", entry.getKey())); - } - } - // validate the optional field code - if (jsonObj.get("code") != null && !jsonObj.get("code").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!AdditionalBankIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'AdditionalBankIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(AdditionalBankIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, AdditionalBankIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public AdditionalBankIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of AdditionalBankIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of AdditionalBankIdentification - * @throws IOException if the JSON string is invalid with respect to AdditionalBankIdentification - */ - public static AdditionalBankIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, AdditionalBankIdentification.class); +/** + * Create an instance of AdditionalBankIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdditionalBankIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to AdditionalBankIdentification + */ + public static AdditionalBankIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, AdditionalBankIdentification.class); } - - /** +/** * Convert an instance of AdditionalBankIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/Address2.java b/src/main/java/com/adyen/model/transfers/Address2.java index 0c802b7fc..9476aeaa4 100644 --- a/src/main/java/com/adyen/model/transfers/Address2.java +++ b/src/main/java/com/adyen/model/transfers/Address2.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,71 +14,55 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * Address2 */ +@JsonPropertyOrder({ + Address2.JSON_PROPERTY_CITY, + Address2.JSON_PROPERTY_COUNTRY, + Address2.JSON_PROPERTY_LINE1, + Address2.JSON_PROPERTY_LINE2, + Address2.JSON_PROPERTY_POSTAL_CODE, + Address2.JSON_PROPERTY_STATE_OR_PROVINCE +}) +@JsonTypeName("Address-2") public class Address2 { - public static final String SERIALIZED_NAME_CITY = "city"; - @SerializedName(SERIALIZED_NAME_CITY) + public static final String JSON_PROPERTY_CITY = "city"; private String city; - public static final String SERIALIZED_NAME_COUNTRY = "country"; - @SerializedName(SERIALIZED_NAME_COUNTRY) + public static final String JSON_PROPERTY_COUNTRY = "country"; private String country; - public static final String SERIALIZED_NAME_LINE1 = "line1"; - @SerializedName(SERIALIZED_NAME_LINE1) + public static final String JSON_PROPERTY_LINE1 = "line1"; private String line1; - public static final String SERIALIZED_NAME_LINE2 = "line2"; - @SerializedName(SERIALIZED_NAME_LINE2) + public static final String JSON_PROPERTY_LINE2 = "line2"; private String line2; - public static final String SERIALIZED_NAME_POSTAL_CODE = "postalCode"; - @SerializedName(SERIALIZED_NAME_POSTAL_CODE) + public static final String JSON_PROPERTY_POSTAL_CODE = "postalCode"; private String postalCode; - public static final String SERIALIZED_NAME_STATE_OR_PROVINCE = "stateOrProvince"; - @SerializedName(SERIALIZED_NAME_STATE_OR_PROVINCE) + public static final String JSON_PROPERTY_STATE_OR_PROVINCE = "stateOrProvince"; private String stateOrProvince; public Address2() { } public Address2 city(String city) { - this.city = city; return this; } @@ -88,19 +72,22 @@ public Address2 city(String city) { * @return city **/ @ApiModelProperty(value = "The name of the city.") + @JsonProperty(JSON_PROPERTY_CITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getCity() { return city; } + @JsonProperty(JSON_PROPERTY_CITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCity(String city) { this.city = city; } public Address2 country(String country) { - this.country = country; return this; } @@ -110,19 +97,22 @@ public Address2 country(String country) { * @return country **/ @ApiModelProperty(required = true, value = "The two-character ISO 3166-1 alpha-2 country code. For example, **US**, **NL**, or **GB**.") + @JsonProperty(JSON_PROPERTY_COUNTRY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getCountry() { return country; } + @JsonProperty(JSON_PROPERTY_COUNTRY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCountry(String country) { this.country = country; } public Address2 line1(String line1) { - this.line1 = line1; return this; } @@ -132,19 +122,22 @@ public Address2 line1(String line1) { * @return line1 **/ @ApiModelProperty(value = "First line of the street address.") + @JsonProperty(JSON_PROPERTY_LINE1) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getLine1() { return line1; } + @JsonProperty(JSON_PROPERTY_LINE1) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setLine1(String line1) { this.line1 = line1; } public Address2 line2(String line2) { - this.line2 = line2; return this; } @@ -154,19 +147,22 @@ public Address2 line2(String line2) { * @return line2 **/ @ApiModelProperty(value = "Second line of the street address.") + @JsonProperty(JSON_PROPERTY_LINE2) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getLine2() { return line2; } + @JsonProperty(JSON_PROPERTY_LINE2) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setLine2(String line2) { this.line2 = line2; } public Address2 postalCode(String postalCode) { - this.postalCode = postalCode; return this; } @@ -176,19 +172,22 @@ public Address2 postalCode(String postalCode) { * @return postalCode **/ @ApiModelProperty(value = "The postal code. Maximum length: * 5 digits for an address in the US. * 10 characters for an address in all other countries.") + @JsonProperty(JSON_PROPERTY_POSTAL_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getPostalCode() { return postalCode; } + @JsonProperty(JSON_PROPERTY_POSTAL_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPostalCode(String postalCode) { this.postalCode = postalCode; } public Address2 stateOrProvince(String stateOrProvince) { - this.stateOrProvince = stateOrProvince; return this; } @@ -198,18 +197,24 @@ public Address2 stateOrProvince(String stateOrProvince) { * @return stateOrProvince **/ @ApiModelProperty(value = "The two-letter ISO 3166-2 state or province code. For example, **CA** in the US or **ON** in Canada. > Required for the US and Canada.") + @JsonProperty(JSON_PROPERTY_STATE_OR_PROVINCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getStateOrProvince() { return stateOrProvince; } + @JsonProperty(JSON_PROPERTY_STATE_OR_PROVINCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setStateOrProvince(String stateOrProvince) { this.stateOrProvince = stateOrProvince; } - + /** + * Return true if this Address-2 object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -257,131 +262,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("city"); - openapiFields.add("country"); - openapiFields.add("line1"); - openapiFields.add("line2"); - openapiFields.add("postalCode"); - openapiFields.add("stateOrProvince"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("country"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(Address2.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to Address2 - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (Address2.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in Address2 is not found in the empty JSON string", Address2.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!Address2.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `Address2` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Address2.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field city - if (jsonObj.get("city") != null && !jsonObj.get("city").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `city` to be a primitive type in the JSON string but got `%s`", jsonObj.get("city").toString())); - } - // validate the optional field country - if (jsonObj.get("country") != null && !jsonObj.get("country").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `country` to be a primitive type in the JSON string but got `%s`", jsonObj.get("country").toString())); - } - // validate the optional field line1 - if (jsonObj.get("line1") != null && !jsonObj.get("line1").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `line1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("line1").toString())); - } - // validate the optional field line2 - if (jsonObj.get("line2") != null && !jsonObj.get("line2").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `line2` to be a primitive type in the JSON string but got `%s`", jsonObj.get("line2").toString())); - } - // validate the optional field postalCode - if (jsonObj.get("postalCode") != null && !jsonObj.get("postalCode").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `postalCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("postalCode").toString())); - } - // validate the optional field stateOrProvince - if (jsonObj.get("stateOrProvince") != null && !jsonObj.get("stateOrProvince").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `stateOrProvince` to be a primitive type in the JSON string but got `%s`", jsonObj.get("stateOrProvince").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Address2.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Address2' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Address2.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Address2 value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Address2 read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of Address2 given an JSON string - * - * @param jsonString JSON string - * @return An instance of Address2 - * @throws IOException if the JSON string is invalid with respect to Address2 - */ - public static Address2 fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Address2.class); +/** + * Create an instance of Address2 given an JSON string + * + * @param jsonString JSON string + * @return An instance of Address2 + * @throws JsonProcessingException if the JSON string is invalid with respect to Address2 + */ + public static Address2 fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Address2.class); } - - /** +/** * Convert an instance of Address2 to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/Amount.java b/src/main/java/com/adyen/model/transfers/Amount.java index 2194ca085..d6dab5c6e 100644 --- a/src/main/java/com/adyen/model/transfers/Amount.java +++ b/src/main/java/com/adyen/model/transfers/Amount.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,55 +14,38 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * Amount */ +@JsonPropertyOrder({ + Amount.JSON_PROPERTY_CURRENCY, + Amount.JSON_PROPERTY_VALUE +}) public class Amount { - public static final String SERIALIZED_NAME_CURRENCY = "currency"; - @SerializedName(SERIALIZED_NAME_CURRENCY) + public static final String JSON_PROPERTY_CURRENCY = "currency"; private String currency; - public static final String SERIALIZED_NAME_VALUE = "value"; - @SerializedName(SERIALIZED_NAME_VALUE) + public static final String JSON_PROPERTY_VALUE = "value"; private Long value; public Amount() { } public Amount currency(String currency) { - this.currency = currency; return this; } @@ -72,19 +55,22 @@ public Amount currency(String currency) { * @return currency **/ @ApiModelProperty(required = true, value = "The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes).") + @JsonProperty(JSON_PROPERTY_CURRENCY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getCurrency() { return currency; } + @JsonProperty(JSON_PROPERTY_CURRENCY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCurrency(String currency) { this.currency = currency; } public Amount value(Long value) { - this.value = value; return this; } @@ -94,18 +80,24 @@ public Amount value(Long value) { * @return value **/ @ApiModelProperty(required = true, value = "The amount of the transaction, in [minor units](https://docs.adyen.com/development-resources/currency-codes).") + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getValue() { return value; } + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setValue(Long value) { this.value = value; } - + /** + * Return true if this Amount object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -145,108 +137,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("currency"); - openapiFields.add("value"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("currency"); - openapiRequiredFields.add("value"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(Amount.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to Amount - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (Amount.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in Amount is not found in the empty JSON string", Amount.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!Amount.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `Amount` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Amount.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field currency - if (jsonObj.get("currency") != null && !jsonObj.get("currency").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `currency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("currency").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Amount.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Amount' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Amount.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Amount value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Amount read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of Amount given an JSON string - * - * @param jsonString JSON string - * @return An instance of Amount - * @throws IOException if the JSON string is invalid with respect to Amount - */ - public static Amount fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Amount.class); +/** + * 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() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/BRLocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/BRLocalAccountIdentification.java index 543be08cf..65eae1a5c 100644 --- a/src/main/java/com/adyen/model/transfers/BRLocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/BRLocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,58 +14,42 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * BRLocalAccountIdentification */ +@JsonPropertyOrder({ + BRLocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + BRLocalAccountIdentification.JSON_PROPERTY_BANK_CODE, + BRLocalAccountIdentification.JSON_PROPERTY_BRANCH_NUMBER, + BRLocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class BRLocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; - public static final String SERIALIZED_NAME_BANK_CODE = "bankCode"; - @SerializedName(SERIALIZED_NAME_BANK_CODE) + public static final String JSON_PROPERTY_BANK_CODE = "bankCode"; private String bankCode; - public static final String SERIALIZED_NAME_BRANCH_NUMBER = "branchNumber"; - @SerializedName(SERIALIZED_NAME_BRANCH_NUMBER) + public static final String JSON_PROPERTY_BRANCH_NUMBER = "branchNumber"; private String branchNumber; /** * **brLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { BRLOCAL("brLocal"); @@ -75,6 +59,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -84,6 +69,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -92,30 +78,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.BRLOCAL; public BRLocalAccountIdentification() { } public BRLocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -125,19 +96,22 @@ public BRLocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The bank account number (without separators or whitespace).") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public BRLocalAccountIdentification bankCode(String bankCode) { - this.bankCode = bankCode; return this; } @@ -147,19 +121,22 @@ public BRLocalAccountIdentification bankCode(String bankCode) { * @return bankCode **/ @ApiModelProperty(required = true, value = "The 3-digit Brazilian bank code (with leading zeros).") + @JsonProperty(JSON_PROPERTY_BANK_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBankCode() { return bankCode; } + @JsonProperty(JSON_PROPERTY_BANK_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBankCode(String bankCode) { this.bankCode = bankCode; } public BRLocalAccountIdentification branchNumber(String branchNumber) { - this.branchNumber = branchNumber; return this; } @@ -169,19 +146,22 @@ public BRLocalAccountIdentification branchNumber(String branchNumber) { * @return branchNumber **/ @ApiModelProperty(required = true, value = "The bank account branch number (without separators or whitespace).") + @JsonProperty(JSON_PROPERTY_BRANCH_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBranchNumber() { return branchNumber; } + @JsonProperty(JSON_PROPERTY_BRANCH_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBranchNumber(String branchNumber) { this.branchNumber = branchNumber; } public BRLocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -191,18 +171,24 @@ public BRLocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**brLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this BRLocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -246,127 +232,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("bankCode"); - openapiFields.add("branchNumber"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("bankCode"); - openapiRequiredFields.add("branchNumber"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(BRLocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to BRLocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (BRLocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in BRLocalAccountIdentification is not found in the empty JSON string", BRLocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!BRLocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `BRLocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : BRLocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // validate the optional field bankCode - if (jsonObj.get("bankCode") != null && !jsonObj.get("bankCode").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `bankCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bankCode").toString())); - } - // validate the optional field branchNumber - if (jsonObj.get("branchNumber") != null && !jsonObj.get("branchNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `branchNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("branchNumber").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!BRLocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'BRLocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(BRLocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, BRLocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public BRLocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of BRLocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of BRLocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to BRLocalAccountIdentification - */ - public static BRLocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, BRLocalAccountIdentification.class); +/** + * Create an instance of BRLocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of BRLocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to BRLocalAccountIdentification + */ + public static BRLocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, BRLocalAccountIdentification.class); } - - /** +/** * Convert an instance of BRLocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/BankAccountV3.java b/src/main/java/com/adyen/model/transfers/BankAccountV3.java index 364c25a68..3ce18365e 100644 --- a/src/main/java/com/adyen/model/transfers/BankAccountV3.java +++ b/src/main/java/com/adyen/model/transfers/BankAccountV3.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,57 +14,40 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.BankAccountV3AccountIdentification; import com.adyen.model.transfers.PartyIdentification2; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.adyen.model.transfers.JSON; /** * BankAccountV3 */ +@JsonPropertyOrder({ + BankAccountV3.JSON_PROPERTY_ACCOUNT_HOLDER, + BankAccountV3.JSON_PROPERTY_ACCOUNT_IDENTIFICATION +}) public class BankAccountV3 { - public static final String SERIALIZED_NAME_ACCOUNT_HOLDER = "accountHolder"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_HOLDER) + public static final String JSON_PROPERTY_ACCOUNT_HOLDER = "accountHolder"; private PartyIdentification2 accountHolder; - public static final String SERIALIZED_NAME_ACCOUNT_IDENTIFICATION = "accountIdentification"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_IDENTIFICATION) + public static final String JSON_PROPERTY_ACCOUNT_IDENTIFICATION = "accountIdentification"; private BankAccountV3AccountIdentification accountIdentification; public BankAccountV3() { } public BankAccountV3 accountHolder(PartyIdentification2 accountHolder) { - this.accountHolder = accountHolder; return this; } @@ -74,19 +57,22 @@ public BankAccountV3 accountHolder(PartyIdentification2 accountHolder) { * @return accountHolder **/ @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public PartyIdentification2 getAccountHolder() { return accountHolder; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountHolder(PartyIdentification2 accountHolder) { this.accountHolder = accountHolder; } public BankAccountV3 accountIdentification(BankAccountV3AccountIdentification accountIdentification) { - this.accountIdentification = accountIdentification; return this; } @@ -96,18 +82,24 @@ public BankAccountV3 accountIdentification(BankAccountV3AccountIdentification ac * @return accountIdentification **/ @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_ACCOUNT_IDENTIFICATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public BankAccountV3AccountIdentification getAccountIdentification() { return accountIdentification; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_IDENTIFICATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountIdentification(BankAccountV3AccountIdentification accountIdentification) { this.accountIdentification = accountIdentification; } - + /** + * Return true if this BankAccountV3 object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -147,112 +139,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountHolder"); - openapiFields.add("accountIdentification"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountHolder"); - openapiRequiredFields.add("accountIdentification"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(BankAccountV3.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to BankAccountV3 - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (BankAccountV3.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in BankAccountV3 is not found in the empty JSON string", BankAccountV3.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!BankAccountV3.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `BankAccountV3` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : BankAccountV3.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field `accountHolder` - if (jsonObj.getAsJsonObject("accountHolder") != null) { - PartyIdentification2.validateJsonObject(jsonObj.getAsJsonObject("accountHolder")); - } - // validate the optional field `accountIdentification` - if (jsonObj.getAsJsonObject("accountIdentification") != null) { - BankAccountV3AccountIdentification.validateJsonObject(jsonObj.getAsJsonObject("accountIdentification")); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!BankAccountV3.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'BankAccountV3' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(BankAccountV3.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, BankAccountV3 value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public BankAccountV3 read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of BankAccountV3 given an JSON string - * - * @param jsonString JSON string - * @return An instance of BankAccountV3 - * @throws IOException if the JSON string is invalid with respect to BankAccountV3 - */ - public static BankAccountV3 fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, BankAccountV3.class); +/** + * Create an instance of BankAccountV3 given an JSON string + * + * @param jsonString JSON string + * @return An instance of BankAccountV3 + * @throws JsonProcessingException if the JSON string is invalid with respect to BankAccountV3 + */ + public static BankAccountV3 fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, BankAccountV3.class); } - - /** +/** * Convert an instance of BankAccountV3 to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/BankAccountV3AccountIdentification.java b/src/main/java/com/adyen/model/transfers/BankAccountV3AccountIdentification.java index d08cade45..6d028a129 100644 --- a/src/main/java/com/adyen/model/transfers/BankAccountV3AccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/BankAccountV3AccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,6 +14,8 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.AULocalAccountIdentification; import com.adyen.model.transfers.AdditionalBankIdentification; import com.adyen.model.transfers.BRLocalAccountIdentification; @@ -29,384 +31,497 @@ import com.adyen.model.transfers.SGLocalAccountIdentification; import com.adyen.model.transfers.UKLocalAccountIdentification; import com.adyen.model.transfers.USLocalAccountIdentification; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import jakarta.ws.rs.core.GenericType; +import com.fasterxml.jackson.core.type.TypeReference; +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.core.Response; import java.io.IOException; -import java.lang.reflect.Type; import java.util.logging.Level; import java.util.logging.Logger; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; -import java.util.HashMap; -import java.util.Map; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.JsonPrimitive; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; - -import com.adyen.model.transfers.JSON; - +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + + +@JsonDeserialize(using = BankAccountV3AccountIdentification.BankAccountV3AccountIdentificationDeserializer.class) +@JsonSerialize(using = BankAccountV3AccountIdentification.BankAccountV3AccountIdentificationSerializer.class) public class BankAccountV3AccountIdentification extends AbstractOpenApiSchema { private static final Logger log = Logger.getLogger(BankAccountV3AccountIdentification.class.getName()); - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") + public static class BankAccountV3AccountIdentificationSerializer extends StdSerializer { + public BankAccountV3AccountIdentificationSerializer(Class t) { + super(t); + } + + public BankAccountV3AccountIdentificationSerializer() { + this(null); + } + @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!BankAccountV3AccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'BankAccountV3AccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter adapterAULocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(AULocalAccountIdentification.class)); - final TypeAdapter adapterBRLocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(BRLocalAccountIdentification.class)); - final TypeAdapter adapterCALocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(CALocalAccountIdentification.class)); - final TypeAdapter adapterCZLocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(CZLocalAccountIdentification.class)); - final TypeAdapter adapterDKLocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(DKLocalAccountIdentification.class)); - final TypeAdapter adapterHULocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(HULocalAccountIdentification.class)); - final TypeAdapter adapterIbanAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(IbanAccountIdentification.class)); - final TypeAdapter adapterNOLocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(NOLocalAccountIdentification.class)); - final TypeAdapter adapterNumberAndBicAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(NumberAndBicAccountIdentification.class)); - final TypeAdapter adapterPLLocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(PLLocalAccountIdentification.class)); - final TypeAdapter adapterSELocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(SELocalAccountIdentification.class)); - final TypeAdapter adapterSGLocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(SGLocalAccountIdentification.class)); - final TypeAdapter adapterUKLocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(UKLocalAccountIdentification.class)); - final TypeAdapter adapterUSLocalAccountIdentification = gson.getDelegateAdapter(this, TypeToken.get(USLocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, BankAccountV3AccountIdentification value) throws IOException { - if (value == null || value.getActualInstance() == null) { - elementAdapter.write(out, null); - return; - } + public void serialize(BankAccountV3AccountIdentification value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } - // check if the actual instance is of the type `AULocalAccountIdentification` - if (value.getActualInstance() instanceof AULocalAccountIdentification) { - JsonObject obj = adapterAULocalAccountIdentification.toJsonTree((AULocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; - } + public static class BankAccountV3AccountIdentificationDeserializer extends StdDeserializer { + public BankAccountV3AccountIdentificationDeserializer() { + this(BankAccountV3AccountIdentification.class); + } - // check if the actual instance is of the type `BRLocalAccountIdentification` - if (value.getActualInstance() instanceof BRLocalAccountIdentification) { - JsonObject obj = adapterBRLocalAccountIdentification.toJsonTree((BRLocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; - } + public BankAccountV3AccountIdentificationDeserializer(Class vc) { + super(vc); + } - // check if the actual instance is of the type `CALocalAccountIdentification` - if (value.getActualInstance() instanceof CALocalAccountIdentification) { - JsonObject obj = adapterCALocalAccountIdentification.toJsonTree((CALocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; + @Override + public BankAccountV3AccountIdentification deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // Local Object Mapper that forces strict validation + ObjectMapper localObjectMapper = JSON.getMapper(); + localObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true); + + // deserialize AULocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (AULocalAccountIdentification.class.equals(Integer.class) || AULocalAccountIdentification.class.equals(Long.class) || AULocalAccountIdentification.class.equals(Float.class) || AULocalAccountIdentification.class.equals(Double.class) || AULocalAccountIdentification.class.equals(Boolean.class) || AULocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((AULocalAccountIdentification.class.equals(Integer.class) || AULocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((AULocalAccountIdentification.class.equals(Float.class) || AULocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (AULocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (AULocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(AULocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), AULocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'AULocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'AULocalAccountIdentification'", e); + } - // check if the actual instance is of the type `CZLocalAccountIdentification` - if (value.getActualInstance() instanceof CZLocalAccountIdentification) { - JsonObject obj = adapterCZLocalAccountIdentification.toJsonTree((CZLocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; - } - // check if the actual instance is of the type `DKLocalAccountIdentification` - if (value.getActualInstance() instanceof DKLocalAccountIdentification) { - JsonObject obj = adapterDKLocalAccountIdentification.toJsonTree((DKLocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; + // deserialize BRLocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (BRLocalAccountIdentification.class.equals(Integer.class) || BRLocalAccountIdentification.class.equals(Long.class) || BRLocalAccountIdentification.class.equals(Float.class) || BRLocalAccountIdentification.class.equals(Double.class) || BRLocalAccountIdentification.class.equals(Boolean.class) || BRLocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((BRLocalAccountIdentification.class.equals(Integer.class) || BRLocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((BRLocalAccountIdentification.class.equals(Float.class) || BRLocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (BRLocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (BRLocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(BRLocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), BRLocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'BRLocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'BRLocalAccountIdentification'", e); + } - // check if the actual instance is of the type `HULocalAccountIdentification` - if (value.getActualInstance() instanceof HULocalAccountIdentification) { - JsonObject obj = adapterHULocalAccountIdentification.toJsonTree((HULocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; - } - // check if the actual instance is of the type `IbanAccountIdentification` - if (value.getActualInstance() instanceof IbanAccountIdentification) { - JsonObject obj = adapterIbanAccountIdentification.toJsonTree((IbanAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; + // deserialize CALocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (CALocalAccountIdentification.class.equals(Integer.class) || CALocalAccountIdentification.class.equals(Long.class) || CALocalAccountIdentification.class.equals(Float.class) || CALocalAccountIdentification.class.equals(Double.class) || CALocalAccountIdentification.class.equals(Boolean.class) || CALocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((CALocalAccountIdentification.class.equals(Integer.class) || CALocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((CALocalAccountIdentification.class.equals(Float.class) || CALocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (CALocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (CALocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(CALocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), CALocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'CALocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'CALocalAccountIdentification'", e); + } - // check if the actual instance is of the type `NOLocalAccountIdentification` - if (value.getActualInstance() instanceof NOLocalAccountIdentification) { - JsonObject obj = adapterNOLocalAccountIdentification.toJsonTree((NOLocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; - } - // check if the actual instance is of the type `NumberAndBicAccountIdentification` - if (value.getActualInstance() instanceof NumberAndBicAccountIdentification) { - JsonObject obj = adapterNumberAndBicAccountIdentification.toJsonTree((NumberAndBicAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; + // deserialize CZLocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (CZLocalAccountIdentification.class.equals(Integer.class) || CZLocalAccountIdentification.class.equals(Long.class) || CZLocalAccountIdentification.class.equals(Float.class) || CZLocalAccountIdentification.class.equals(Double.class) || CZLocalAccountIdentification.class.equals(Boolean.class) || CZLocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((CZLocalAccountIdentification.class.equals(Integer.class) || CZLocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((CZLocalAccountIdentification.class.equals(Float.class) || CZLocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (CZLocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (CZLocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(CZLocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), CZLocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'CZLocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'CZLocalAccountIdentification'", e); + } - // check if the actual instance is of the type `PLLocalAccountIdentification` - if (value.getActualInstance() instanceof PLLocalAccountIdentification) { - JsonObject obj = adapterPLLocalAccountIdentification.toJsonTree((PLLocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; - } - // check if the actual instance is of the type `SELocalAccountIdentification` - if (value.getActualInstance() instanceof SELocalAccountIdentification) { - JsonObject obj = adapterSELocalAccountIdentification.toJsonTree((SELocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; + // deserialize DKLocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DKLocalAccountIdentification.class.equals(Integer.class) || DKLocalAccountIdentification.class.equals(Long.class) || DKLocalAccountIdentification.class.equals(Float.class) || DKLocalAccountIdentification.class.equals(Double.class) || DKLocalAccountIdentification.class.equals(Boolean.class) || DKLocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((DKLocalAccountIdentification.class.equals(Integer.class) || DKLocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((DKLocalAccountIdentification.class.equals(Float.class) || DKLocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (DKLocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (DKLocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(DKLocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), DKLocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'DKLocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DKLocalAccountIdentification'", e); + } - // check if the actual instance is of the type `SGLocalAccountIdentification` - if (value.getActualInstance() instanceof SGLocalAccountIdentification) { - JsonObject obj = adapterSGLocalAccountIdentification.toJsonTree((SGLocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; - } - // check if the actual instance is of the type `UKLocalAccountIdentification` - if (value.getActualInstance() instanceof UKLocalAccountIdentification) { - JsonObject obj = adapterUKLocalAccountIdentification.toJsonTree((UKLocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; + // deserialize HULocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (HULocalAccountIdentification.class.equals(Integer.class) || HULocalAccountIdentification.class.equals(Long.class) || HULocalAccountIdentification.class.equals(Float.class) || HULocalAccountIdentification.class.equals(Double.class) || HULocalAccountIdentification.class.equals(Boolean.class) || HULocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((HULocalAccountIdentification.class.equals(Integer.class) || HULocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((HULocalAccountIdentification.class.equals(Float.class) || HULocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (HULocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (HULocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(HULocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), HULocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'HULocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'HULocalAccountIdentification'", e); + } - // check if the actual instance is of the type `USLocalAccountIdentification` - if (value.getActualInstance() instanceof USLocalAccountIdentification) { - JsonObject obj = adapterUSLocalAccountIdentification.toJsonTree((USLocalAccountIdentification)value.getActualInstance()).getAsJsonObject(); - elementAdapter.write(out, obj); - return; - } - throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: AULocalAccountIdentification, BRLocalAccountIdentification, CALocalAccountIdentification, CZLocalAccountIdentification, DKLocalAccountIdentification, HULocalAccountIdentification, IbanAccountIdentification, NOLocalAccountIdentification, NumberAndBicAccountIdentification, PLLocalAccountIdentification, SELocalAccountIdentification, SGLocalAccountIdentification, UKLocalAccountIdentification, USLocalAccountIdentification"); + // deserialize IbanAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (IbanAccountIdentification.class.equals(Integer.class) || IbanAccountIdentification.class.equals(Long.class) || IbanAccountIdentification.class.equals(Float.class) || IbanAccountIdentification.class.equals(Double.class) || IbanAccountIdentification.class.equals(Boolean.class) || IbanAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((IbanAccountIdentification.class.equals(Integer.class) || IbanAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((IbanAccountIdentification.class.equals(Float.class) || IbanAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (IbanAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (IbanAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(IbanAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), IbanAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'IbanAccountIdentification'"); } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'IbanAccountIdentification'", e); + } - @Override - public BankAccountV3AccountIdentification read(JsonReader in) throws IOException { - Object deserialized = null; - JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); - - int match = 0; - ArrayList errorMessages = new ArrayList<>(); - TypeAdapter actualAdapter = elementAdapter; - - // deserialize AULocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - AULocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterAULocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'AULocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for AULocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'AULocalAccountIdentification'", e); - } - // deserialize BRLocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - BRLocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterBRLocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'BRLocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for BRLocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'BRLocalAccountIdentification'", e); + // deserialize NOLocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (NOLocalAccountIdentification.class.equals(Integer.class) || NOLocalAccountIdentification.class.equals(Long.class) || NOLocalAccountIdentification.class.equals(Float.class) || NOLocalAccountIdentification.class.equals(Double.class) || NOLocalAccountIdentification.class.equals(Boolean.class) || NOLocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((NOLocalAccountIdentification.class.equals(Integer.class) || NOLocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((NOLocalAccountIdentification.class.equals(Float.class) || NOLocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (NOLocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (NOLocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(NOLocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), NOLocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'NOLocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'NOLocalAccountIdentification'", e); + } - // deserialize CALocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - CALocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterCALocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'CALocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for CALocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'CALocalAccountIdentification'", e); - } - // deserialize CZLocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - CZLocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterCZLocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'CZLocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for CZLocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'CZLocalAccountIdentification'", e); + // deserialize NumberAndBicAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (NumberAndBicAccountIdentification.class.equals(Integer.class) || NumberAndBicAccountIdentification.class.equals(Long.class) || NumberAndBicAccountIdentification.class.equals(Float.class) || NumberAndBicAccountIdentification.class.equals(Double.class) || NumberAndBicAccountIdentification.class.equals(Boolean.class) || NumberAndBicAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((NumberAndBicAccountIdentification.class.equals(Integer.class) || NumberAndBicAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((NumberAndBicAccountIdentification.class.equals(Float.class) || NumberAndBicAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (NumberAndBicAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (NumberAndBicAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(NumberAndBicAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), NumberAndBicAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'NumberAndBicAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'NumberAndBicAccountIdentification'", e); + } - // deserialize DKLocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - DKLocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterDKLocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'DKLocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for DKLocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'DKLocalAccountIdentification'", e); - } - // deserialize HULocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - HULocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterHULocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'HULocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for HULocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'HULocalAccountIdentification'", e); + // deserialize PLLocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (PLLocalAccountIdentification.class.equals(Integer.class) || PLLocalAccountIdentification.class.equals(Long.class) || PLLocalAccountIdentification.class.equals(Float.class) || PLLocalAccountIdentification.class.equals(Double.class) || PLLocalAccountIdentification.class.equals(Boolean.class) || PLLocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((PLLocalAccountIdentification.class.equals(Integer.class) || PLLocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((PLLocalAccountIdentification.class.equals(Float.class) || PLLocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (PLLocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (PLLocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(PLLocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), PLLocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'PLLocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'PLLocalAccountIdentification'", e); + } - // deserialize IbanAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - IbanAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterIbanAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'IbanAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for IbanAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'IbanAccountIdentification'", e); - } - // deserialize NOLocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - NOLocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterNOLocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'NOLocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for NOLocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'NOLocalAccountIdentification'", e); + // deserialize SELocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (SELocalAccountIdentification.class.equals(Integer.class) || SELocalAccountIdentification.class.equals(Long.class) || SELocalAccountIdentification.class.equals(Float.class) || SELocalAccountIdentification.class.equals(Double.class) || SELocalAccountIdentification.class.equals(Boolean.class) || SELocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((SELocalAccountIdentification.class.equals(Integer.class) || SELocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((SELocalAccountIdentification.class.equals(Float.class) || SELocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (SELocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (SELocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(SELocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), SELocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'SELocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'SELocalAccountIdentification'", e); + } - // deserialize NumberAndBicAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - NumberAndBicAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterNumberAndBicAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'NumberAndBicAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for NumberAndBicAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'NumberAndBicAccountIdentification'", e); - } - // deserialize PLLocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - PLLocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterPLLocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'PLLocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for PLLocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'PLLocalAccountIdentification'", e); + // deserialize SGLocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (SGLocalAccountIdentification.class.equals(Integer.class) || SGLocalAccountIdentification.class.equals(Long.class) || SGLocalAccountIdentification.class.equals(Float.class) || SGLocalAccountIdentification.class.equals(Double.class) || SGLocalAccountIdentification.class.equals(Boolean.class) || SGLocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((SGLocalAccountIdentification.class.equals(Integer.class) || SGLocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((SGLocalAccountIdentification.class.equals(Float.class) || SGLocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (SGLocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (SGLocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(SGLocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), SGLocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'SGLocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'SGLocalAccountIdentification'", e); + } - // deserialize SELocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - SELocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterSELocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'SELocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for SELocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'SELocalAccountIdentification'", e); - } - // deserialize SGLocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - SGLocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterSGLocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'SGLocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for SGLocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'SGLocalAccountIdentification'", e); + // deserialize UKLocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (UKLocalAccountIdentification.class.equals(Integer.class) || UKLocalAccountIdentification.class.equals(Long.class) || UKLocalAccountIdentification.class.equals(Float.class) || UKLocalAccountIdentification.class.equals(Double.class) || UKLocalAccountIdentification.class.equals(Boolean.class) || UKLocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((UKLocalAccountIdentification.class.equals(Integer.class) || UKLocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((UKLocalAccountIdentification.class.equals(Float.class) || UKLocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (UKLocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (UKLocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(UKLocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), UKLocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'UKLocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'UKLocalAccountIdentification'", e); + } - // deserialize UKLocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - UKLocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterUKLocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'UKLocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for UKLocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'UKLocalAccountIdentification'", e); - } - // deserialize USLocalAccountIdentification - try { - // validate the JSON object to see if any exception is thrown - USLocalAccountIdentification.validateJsonObject(jsonObject); - actualAdapter = adapterUSLocalAccountIdentification; - match++; - log.log(Level.FINER, "Input data matches schema 'USLocalAccountIdentification'"); - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format("Deserialization for USLocalAccountIdentification failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'USLocalAccountIdentification'", e); + // deserialize USLocalAccountIdentification + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (USLocalAccountIdentification.class.equals(Integer.class) || USLocalAccountIdentification.class.equals(Long.class) || USLocalAccountIdentification.class.equals(Float.class) || USLocalAccountIdentification.class.equals(Double.class) || USLocalAccountIdentification.class.equals(Boolean.class) || USLocalAccountIdentification.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= ((USLocalAccountIdentification.class.equals(Integer.class) || USLocalAccountIdentification.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= ((USLocalAccountIdentification.class.equals(Float.class) || USLocalAccountIdentification.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= (USLocalAccountIdentification.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (USLocalAccountIdentification.class.equals(String.class) && token == JsonToken.VALUE_STRING); } + } + // Checks if the unique type of the oneOf json matches any of the object TypeEnum values + boolean typeMatch = Arrays.stream(USLocalAccountIdentification.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + if (attemptParsing || typeMatch) { + // Strict deserialization for oneOf models + deserialized = localObjectMapper.readValue(tree.toString(), USLocalAccountIdentification.class); + // typeMatch should enforce proper deserialization + match++; + log.log(Level.FINER, "Input data matches schema 'USLocalAccountIdentification'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'USLocalAccountIdentification'", e); + } - if (match == 1) { - BankAccountV3AccountIdentification ret = new BankAccountV3AccountIdentification(); - ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); - return ret; - } + // Throw error if there is no match + if (match == 0) { + throw new IOException(String.format("Failed deserialization for BankAccountV3AccountIdentification: %d classes match result, expected 1", match)); + } + // Log warning if there is more than one match + if (match > 1) { + log.log(Level.WARNING, String.format("Warning, indecisive deserialization for BankAccountV3AccountIdentification: %d classes match result, expected 1", match)); + } - throw new IOException(String.format("Failed deserialization for BankAccountV3AccountIdentification: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonObject.toString())); - } - }.nullSafe(); + localObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + BankAccountV3AccountIdentification ret = new BankAccountV3AccountIdentification(); + ret.setActualInstance(deserialized); + return ret; + } + + /** + * Handle deserialization of the 'null' value. + */ + @Override + public BankAccountV3AccountIdentification getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "BankAccountV3AccountIdentification cannot be null"); } } @@ -516,6 +631,7 @@ public BankAccountV3AccountIdentification(USLocalAccountIdentification o) { }); schemas.put("USLocalAccountIdentification", new GenericType() { }); + JSON.registerDescendants(BankAccountV3AccountIdentification.class, Collections.unmodifiableMap(schemas)); } @Override @@ -533,72 +649,72 @@ public Map getSchemas() { */ @Override public void setActualInstance(Object instance) { - if (instance instanceof AULocalAccountIdentification) { + if (JSON.isInstanceOf(AULocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof BRLocalAccountIdentification) { + if (JSON.isInstanceOf(BRLocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof CALocalAccountIdentification) { + if (JSON.isInstanceOf(CALocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof CZLocalAccountIdentification) { + if (JSON.isInstanceOf(CZLocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof DKLocalAccountIdentification) { + if (JSON.isInstanceOf(DKLocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof HULocalAccountIdentification) { + if (JSON.isInstanceOf(HULocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof IbanAccountIdentification) { + if (JSON.isInstanceOf(IbanAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof NOLocalAccountIdentification) { + if (JSON.isInstanceOf(NOLocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof NumberAndBicAccountIdentification) { + if (JSON.isInstanceOf(NumberAndBicAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof PLLocalAccountIdentification) { + if (JSON.isInstanceOf(PLLocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof SELocalAccountIdentification) { + if (JSON.isInstanceOf(SELocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof SGLocalAccountIdentification) { + if (JSON.isInstanceOf(SGLocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof UKLocalAccountIdentification) { + if (JSON.isInstanceOf(UKLocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (instance instanceof USLocalAccountIdentification) { + if (JSON.isInstanceOf(USLocalAccountIdentification.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } @@ -771,166 +887,5 @@ public USLocalAccountIdentification getUSLocalAccountIdentification() throws Cla return (USLocalAccountIdentification)super.getActualInstance(); } - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to BankAccountV3AccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - // validate oneOf schemas one by one - int validCount = 0; - ArrayList errorMessages = new ArrayList<>(); - // validate the json string with AULocalAccountIdentification - try { - Logger.getLogger(AULocalAccountIdentification.class.getName()).setLevel(Level.OFF); - AULocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for AULocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with BRLocalAccountIdentification - try { - Logger.getLogger(BRLocalAccountIdentification.class.getName()).setLevel(Level.OFF); - BRLocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for BRLocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with CALocalAccountIdentification - try { - Logger.getLogger(CALocalAccountIdentification.class.getName()).setLevel(Level.OFF); - CALocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for CALocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with CZLocalAccountIdentification - try { - Logger.getLogger(CZLocalAccountIdentification.class.getName()).setLevel(Level.OFF); - CZLocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for CZLocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with DKLocalAccountIdentification - try { - Logger.getLogger(DKLocalAccountIdentification.class.getName()).setLevel(Level.OFF); - DKLocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for DKLocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with HULocalAccountIdentification - try { - Logger.getLogger(HULocalAccountIdentification.class.getName()).setLevel(Level.OFF); - HULocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for HULocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with IbanAccountIdentification - try { - Logger.getLogger(IbanAccountIdentification.class.getName()).setLevel(Level.OFF); - IbanAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for IbanAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with NOLocalAccountIdentification - try { - Logger.getLogger(NOLocalAccountIdentification.class.getName()).setLevel(Level.OFF); - NOLocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for NOLocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with NumberAndBicAccountIdentification - try { - Logger.getLogger(NumberAndBicAccountIdentification.class.getName()).setLevel(Level.OFF); - NumberAndBicAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for NumberAndBicAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with PLLocalAccountIdentification - try { - Logger.getLogger(PLLocalAccountIdentification.class.getName()).setLevel(Level.OFF); - PLLocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for PLLocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with SELocalAccountIdentification - try { - Logger.getLogger(SELocalAccountIdentification.class.getName()).setLevel(Level.OFF); - SELocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for SELocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with SGLocalAccountIdentification - try { - Logger.getLogger(SGLocalAccountIdentification.class.getName()).setLevel(Level.OFF); - SGLocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for SGLocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with UKLocalAccountIdentification - try { - Logger.getLogger(UKLocalAccountIdentification.class.getName()).setLevel(Level.OFF); - UKLocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for UKLocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with USLocalAccountIdentification - try { - Logger.getLogger(USLocalAccountIdentification.class.getName()).setLevel(Level.OFF); - USLocalAccountIdentification.validateJsonObject(jsonObj); - validCount++; - } catch (Exception e) { - errorMessages.add(String.format("Deserialization for USLocalAccountIdentification failed with `%s`.", e.getMessage())); - // continue to the next one - } - if (validCount != 1) { - throw new IOException(String.format("The JSON string is invalid for BankAccountV3AccountIdentification with oneOf schemas: AULocalAccountIdentification, BRLocalAccountIdentification, CALocalAccountIdentification, CZLocalAccountIdentification, DKLocalAccountIdentification, HULocalAccountIdentification, IbanAccountIdentification, NOLocalAccountIdentification, NumberAndBicAccountIdentification, PLLocalAccountIdentification, SELocalAccountIdentification, SGLocalAccountIdentification, UKLocalAccountIdentification, USLocalAccountIdentification. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonObj.toString())); - } - } - - /** - * Create an instance of BankAccountV3AccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of BankAccountV3AccountIdentification - * @throws IOException if the JSON string is invalid with respect to BankAccountV3AccountIdentification - */ - public static BankAccountV3AccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, BankAccountV3AccountIdentification.class); - } - - /** - * Convert an instance of BankAccountV3AccountIdentification to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } } diff --git a/src/main/java/com/adyen/model/transfers/CALocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/CALocalAccountIdentification.java index 46a76c1ce..a202d596c 100644 --- a/src/main/java/com/adyen/model/transfers/CALocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/CALocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,50 +14,37 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * CALocalAccountIdentification */ +@JsonPropertyOrder({ + CALocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + CALocalAccountIdentification.JSON_PROPERTY_ACCOUNT_TYPE, + CALocalAccountIdentification.JSON_PROPERTY_INSTITUTION_NUMBER, + CALocalAccountIdentification.JSON_PROPERTY_TRANSIT_NUMBER, + CALocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class CALocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; /** * The bank account type. Possible values: **checking** or **savings**. Defaults to **checking**. */ - @JsonAdapter(AccountTypeEnum.Adapter.class) public enum AccountTypeEnum { CHECKING("checking"), @@ -69,6 +56,7 @@ public enum AccountTypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -78,6 +66,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static AccountTypeEnum fromValue(String value) { for (AccountTypeEnum b : AccountTypeEnum.values()) { if (b.value.equals(value)) { @@ -86,37 +75,20 @@ public static AccountTypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final AccountTypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public AccountTypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return AccountTypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_ACCOUNT_TYPE = "accountType"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_TYPE) + public static final String JSON_PROPERTY_ACCOUNT_TYPE = "accountType"; private AccountTypeEnum accountType = AccountTypeEnum.CHECKING; - public static final String SERIALIZED_NAME_INSTITUTION_NUMBER = "institutionNumber"; - @SerializedName(SERIALIZED_NAME_INSTITUTION_NUMBER) + public static final String JSON_PROPERTY_INSTITUTION_NUMBER = "institutionNumber"; private String institutionNumber; - public static final String SERIALIZED_NAME_TRANSIT_NUMBER = "transitNumber"; - @SerializedName(SERIALIZED_NAME_TRANSIT_NUMBER) + public static final String JSON_PROPERTY_TRANSIT_NUMBER = "transitNumber"; private String transitNumber; /** * **caLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { CALOCAL("caLocal"); @@ -126,6 +98,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -135,6 +108,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -143,30 +117,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.CALOCAL; public CALocalAccountIdentification() { } public CALocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -176,19 +135,22 @@ public CALocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The 5- to 12-digit bank account number, without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public CALocalAccountIdentification accountType(AccountTypeEnum accountType) { - this.accountType = accountType; return this; } @@ -198,19 +160,22 @@ public CALocalAccountIdentification accountType(AccountTypeEnum accountType) { * @return accountType **/ @ApiModelProperty(value = "The bank account type. Possible values: **checking** or **savings**. Defaults to **checking**.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public AccountTypeEnum getAccountType() { return accountType; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountType(AccountTypeEnum accountType) { this.accountType = accountType; } public CALocalAccountIdentification institutionNumber(String institutionNumber) { - this.institutionNumber = institutionNumber; return this; } @@ -220,19 +185,22 @@ public CALocalAccountIdentification institutionNumber(String institutionNumber) * @return institutionNumber **/ @ApiModelProperty(required = true, value = "The 3-digit institution number, without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_INSTITUTION_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getInstitutionNumber() { return institutionNumber; } + @JsonProperty(JSON_PROPERTY_INSTITUTION_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setInstitutionNumber(String institutionNumber) { this.institutionNumber = institutionNumber; } public CALocalAccountIdentification transitNumber(String transitNumber) { - this.transitNumber = transitNumber; return this; } @@ -242,19 +210,22 @@ public CALocalAccountIdentification transitNumber(String transitNumber) { * @return transitNumber **/ @ApiModelProperty(required = true, value = "The 5-digit transit number, without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_TRANSIT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getTransitNumber() { return transitNumber; } + @JsonProperty(JSON_PROPERTY_TRANSIT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTransitNumber(String transitNumber) { this.transitNumber = transitNumber; } public CALocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -264,18 +235,24 @@ public CALocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**caLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this CALocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -321,135 +298,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("accountType"); - openapiFields.add("institutionNumber"); - openapiFields.add("transitNumber"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("institutionNumber"); - openapiRequiredFields.add("transitNumber"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(CALocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to CALocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (CALocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in CALocalAccountIdentification is not found in the empty JSON string", CALocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!CALocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `CALocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : CALocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // ensure the field accountType can be parsed to an enum value - if (jsonObj.get("accountType") != null) { - if(!jsonObj.get("accountType").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `accountType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountType").toString())); - } - AccountTypeEnum.fromValue(jsonObj.get("accountType").getAsString()); - } - // validate the optional field institutionNumber - if (jsonObj.get("institutionNumber") != null && !jsonObj.get("institutionNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `institutionNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("institutionNumber").toString())); - } - // validate the optional field transitNumber - if (jsonObj.get("transitNumber") != null && !jsonObj.get("transitNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `transitNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transitNumber").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!CALocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'CALocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(CALocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, CALocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public CALocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of CALocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of CALocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to CALocalAccountIdentification - */ - public static CALocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, CALocalAccountIdentification.class); +/** + * Create an instance of CALocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of CALocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to CALocalAccountIdentification + */ + public static CALocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CALocalAccountIdentification.class); } - - /** +/** * Convert an instance of CALocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/CZLocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/CZLocalAccountIdentification.java index 8b5fbea4a..10837bd75 100644 --- a/src/main/java/com/adyen/model/transfers/CZLocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/CZLocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,54 +14,38 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * CZLocalAccountIdentification */ +@JsonPropertyOrder({ + CZLocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + CZLocalAccountIdentification.JSON_PROPERTY_BANK_CODE, + CZLocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class CZLocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; - public static final String SERIALIZED_NAME_BANK_CODE = "bankCode"; - @SerializedName(SERIALIZED_NAME_BANK_CODE) + public static final String JSON_PROPERTY_BANK_CODE = "bankCode"; private String bankCode; /** * **czLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { CZLOCAL("czLocal"); @@ -71,6 +55,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -80,6 +65,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -88,30 +74,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.CZLOCAL; public CZLocalAccountIdentification() { } public CZLocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -121,19 +92,22 @@ public CZLocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The 2- to 16-digit bank account number (Číslo účtu) in the following format: - The optional prefix (předčíslí). - The required second part (základní část) which must be at least two non-zero digits. Examples: - **19-123457** (with prefix) - **123457** (without prefix) - **000019-0000123457** (with prefix, normalized) - **000000-0000123457** (without prefix, normalized)") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public CZLocalAccountIdentification bankCode(String bankCode) { - this.bankCode = bankCode; return this; } @@ -143,19 +117,22 @@ public CZLocalAccountIdentification bankCode(String bankCode) { * @return bankCode **/ @ApiModelProperty(required = true, value = "The 4-digit bank code (Kód banky), without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_BANK_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBankCode() { return bankCode; } + @JsonProperty(JSON_PROPERTY_BANK_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBankCode(String bankCode) { this.bankCode = bankCode; } public CZLocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -165,18 +142,24 @@ public CZLocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**czLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this CZLocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -218,121 +201,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("bankCode"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("bankCode"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(CZLocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to CZLocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (CZLocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in CZLocalAccountIdentification is not found in the empty JSON string", CZLocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!CZLocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `CZLocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : CZLocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // validate the optional field bankCode - if (jsonObj.get("bankCode") != null && !jsonObj.get("bankCode").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `bankCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bankCode").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!CZLocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'CZLocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(CZLocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, CZLocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public CZLocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of CZLocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of CZLocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to CZLocalAccountIdentification - */ - public static CZLocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, CZLocalAccountIdentification.class); +/** + * Create an instance of CZLocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of CZLocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to CZLocalAccountIdentification + */ + public static CZLocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CZLocalAccountIdentification.class); } - - /** +/** * Convert an instance of CZLocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/CapitalBalance.java b/src/main/java/com/adyen/model/transfers/CapitalBalance.java new file mode 100644 index 000000000..13cf13720 --- /dev/null +++ b/src/main/java/com/adyen/model/transfers/CapitalBalance.java @@ -0,0 +1,221 @@ +/* + * Transfers API + * + * The version of the OpenAPI document: 3 + * + * + * 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.transfers; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * CapitalBalance + */ +@JsonPropertyOrder({ + CapitalBalance.JSON_PROPERTY_CURRENCY, + CapitalBalance.JSON_PROPERTY_FEE, + CapitalBalance.JSON_PROPERTY_PRINCIPAL, + CapitalBalance.JSON_PROPERTY_TOTAL +}) + +public class CapitalBalance { + public static final String JSON_PROPERTY_CURRENCY = "currency"; + private String currency; + + public static final String JSON_PROPERTY_FEE = "fee"; + private Long fee; + + public static final String JSON_PROPERTY_PRINCIPAL = "principal"; + private Long principal; + + public static final String JSON_PROPERTY_TOTAL = "total"; + private Long total; + + public CapitalBalance() { + } + + public CapitalBalance currency(String currency) { + this.currency = currency; + return this; + } + + /** + * The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes). + * @return currency + **/ + @ApiModelProperty(required = true, value = "The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes).") + @JsonProperty(JSON_PROPERTY_CURRENCY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getCurrency() { + return currency; + } + + + @JsonProperty(JSON_PROPERTY_CURRENCY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCurrency(String currency) { + this.currency = currency; + } + + + public CapitalBalance fee(Long fee) { + this.fee = fee; + return this; + } + + /** + * Fee amount. + * @return fee + **/ + @ApiModelProperty(required = true, value = "Fee amount.") + @JsonProperty(JSON_PROPERTY_FEE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Long getFee() { + return fee; + } + + + @JsonProperty(JSON_PROPERTY_FEE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFee(Long fee) { + this.fee = fee; + } + + + public CapitalBalance principal(Long principal) { + this.principal = principal; + return this; + } + + /** + * Principal amount. + * @return principal + **/ + @ApiModelProperty(required = true, value = "Principal amount.") + @JsonProperty(JSON_PROPERTY_PRINCIPAL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Long getPrincipal() { + return principal; + } + + + @JsonProperty(JSON_PROPERTY_PRINCIPAL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPrincipal(Long principal) { + this.principal = principal; + } + + + public CapitalBalance total(Long total) { + this.total = total; + return this; + } + + /** + * Total amount. A sum of principal amount and fee amount. + * @return total + **/ + @ApiModelProperty(required = true, value = "Total amount. A sum of principal amount and fee amount.") + @JsonProperty(JSON_PROPERTY_TOTAL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Long getTotal() { + return total; + } + + + @JsonProperty(JSON_PROPERTY_TOTAL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTotal(Long total) { + this.total = total; + } + + + /** + * Return true if this CapitalBalance object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CapitalBalance capitalBalance = (CapitalBalance) o; + return Objects.equals(this.currency, capitalBalance.currency) && + Objects.equals(this.fee, capitalBalance.fee) && + Objects.equals(this.principal, capitalBalance.principal) && + Objects.equals(this.total, capitalBalance.total); + } + + @Override + public int hashCode() { + return Objects.hash(currency, fee, principal, total); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CapitalBalance {\n"); + sb.append(" currency: ").append(toIndentedString(currency)).append("\n"); + sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); + sb.append(" principal: ").append(toIndentedString(principal)).append("\n"); + sb.append(" total: ").append(toIndentedString(total)).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 CapitalBalance given an JSON string + * + * @param jsonString JSON string + * @return An instance of CapitalBalance + * @throws JsonProcessingException if the JSON string is invalid with respect to CapitalBalance + */ + public static CapitalBalance fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CapitalBalance.class); + } +/** + * Convert an instance of CapitalBalance 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/transfers/CapitalGrant.java b/src/main/java/com/adyen/model/transfers/CapitalGrant.java new file mode 100644 index 000000000..e84248e19 --- /dev/null +++ b/src/main/java/com/adyen/model/transfers/CapitalGrant.java @@ -0,0 +1,418 @@ +/* + * Transfers API + * + * The version of the OpenAPI document: 3 + * + * + * 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.transfers; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.adyen.model.transfers.Amount; +import com.adyen.model.transfers.CapitalBalance; +import com.adyen.model.transfers.Counterparty2; +import com.adyen.model.transfers.Fee; +import com.adyen.model.transfers.Repayment; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * CapitalGrant + */ +@JsonPropertyOrder({ + CapitalGrant.JSON_PROPERTY_AMOUNT, + CapitalGrant.JSON_PROPERTY_BALANCES, + CapitalGrant.JSON_PROPERTY_COUNTERPARTY, + CapitalGrant.JSON_PROPERTY_FEE, + CapitalGrant.JSON_PROPERTY_GRANT_ACCOUNT_ID, + CapitalGrant.JSON_PROPERTY_GRANT_OFFER_ID, + CapitalGrant.JSON_PROPERTY_ID, + CapitalGrant.JSON_PROPERTY_REPAYMENT, + CapitalGrant.JSON_PROPERTY_STATUS +}) + +public class CapitalGrant { + public static final String JSON_PROPERTY_AMOUNT = "amount"; + private Amount amount; + + public static final String JSON_PROPERTY_BALANCES = "balances"; + private CapitalBalance balances; + + public static final String JSON_PROPERTY_COUNTERPARTY = "counterparty"; + private Counterparty2 counterparty; + + public static final String JSON_PROPERTY_FEE = "fee"; + private Fee fee; + + public static final String JSON_PROPERTY_GRANT_ACCOUNT_ID = "grantAccountId"; + private String grantAccountId; + + public static final String JSON_PROPERTY_GRANT_OFFER_ID = "grantOfferId"; + private String grantOfferId; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_REPAYMENT = "repayment"; + private Repayment repayment; + + /** + * The current status of the grant. Possible values: **Pending**, **Active**, **Repaid**. + */ + public enum StatusEnum { + PENDING("Pending"), + + ACTIVE("Active"), + + REPAID("Repaid"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + private StatusEnum status; + + public CapitalGrant() { + } + + public CapitalGrant amount(Amount amount) { + this.amount = amount; + return this; + } + + /** + * Get amount + * @return amount + **/ + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Amount getAmount() { + return amount; + } + + + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAmount(Amount amount) { + this.amount = amount; + } + + + public CapitalGrant balances(CapitalBalance balances) { + this.balances = balances; + return this; + } + + /** + * Get balances + * @return balances + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_BALANCES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public CapitalBalance getBalances() { + return balances; + } + + + @JsonProperty(JSON_PROPERTY_BALANCES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBalances(CapitalBalance balances) { + this.balances = balances; + } + + + public CapitalGrant counterparty(Counterparty2 counterparty) { + this.counterparty = counterparty; + return this; + } + + /** + * Get counterparty + * @return counterparty + **/ + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Counterparty2 getCounterparty() { + return counterparty; + } + + + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCounterparty(Counterparty2 counterparty) { + this.counterparty = counterparty; + } + + + public CapitalGrant fee(Fee fee) { + this.fee = fee; + return this; + } + + /** + * Get fee + * @return fee + **/ + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_FEE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Fee getFee() { + return fee; + } + + + @JsonProperty(JSON_PROPERTY_FEE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFee(Fee fee) { + this.fee = fee; + } + + + public CapitalGrant grantAccountId(String grantAccountId) { + this.grantAccountId = grantAccountId; + return this; + } + + /** + * The identifier of the grant account used for the grant. + * @return grantAccountId + **/ + @ApiModelProperty(required = true, value = "The identifier of the grant account used for the grant.") + @JsonProperty(JSON_PROPERTY_GRANT_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getGrantAccountId() { + return grantAccountId; + } + + + @JsonProperty(JSON_PROPERTY_GRANT_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setGrantAccountId(String grantAccountId) { + this.grantAccountId = grantAccountId; + } + + + public CapitalGrant grantOfferId(String grantOfferId) { + this.grantOfferId = grantOfferId; + return this; + } + + /** + * The identifier of the grant offer that has been selected and from which the grant details will be used. + * @return grantOfferId + **/ + @ApiModelProperty(required = true, value = "The identifier of the grant offer that has been selected and from which the grant details will be used.") + @JsonProperty(JSON_PROPERTY_GRANT_OFFER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getGrantOfferId() { + return grantOfferId; + } + + + @JsonProperty(JSON_PROPERTY_GRANT_OFFER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setGrantOfferId(String grantOfferId) { + this.grantOfferId = grantOfferId; + } + + + public CapitalGrant id(String id) { + this.id = id; + return this; + } + + /** + * The identifier of the grant reference. + * @return id + **/ + @ApiModelProperty(required = true, value = "The identifier of the grant reference.") + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + + public CapitalGrant repayment(Repayment repayment) { + this.repayment = repayment; + return this; + } + + /** + * Get repayment + * @return repayment + **/ + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_REPAYMENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Repayment getRepayment() { + return repayment; + } + + + @JsonProperty(JSON_PROPERTY_REPAYMENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRepayment(Repayment repayment) { + this.repayment = repayment; + } + + + public CapitalGrant status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * The current status of the grant. Possible values: **Pending**, **Active**, **Repaid**. + * @return status + **/ + @ApiModelProperty(required = true, value = "The current status of the grant. Possible values: **Pending**, **Active**, **Repaid**.") + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public StatusEnum getStatus() { + return status; + } + + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(StatusEnum status) { + this.status = status; + } + + + /** + * Return true if this CapitalGrant object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CapitalGrant capitalGrant = (CapitalGrant) o; + return Objects.equals(this.amount, capitalGrant.amount) && + Objects.equals(this.balances, capitalGrant.balances) && + Objects.equals(this.counterparty, capitalGrant.counterparty) && + Objects.equals(this.fee, capitalGrant.fee) && + Objects.equals(this.grantAccountId, capitalGrant.grantAccountId) && + Objects.equals(this.grantOfferId, capitalGrant.grantOfferId) && + Objects.equals(this.id, capitalGrant.id) && + Objects.equals(this.repayment, capitalGrant.repayment) && + Objects.equals(this.status, capitalGrant.status); + } + + @Override + public int hashCode() { + return Objects.hash(amount, balances, counterparty, fee, grantAccountId, grantOfferId, id, repayment, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CapitalGrant {\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" balances: ").append(toIndentedString(balances)).append("\n"); + sb.append(" counterparty: ").append(toIndentedString(counterparty)).append("\n"); + sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); + sb.append(" grantAccountId: ").append(toIndentedString(grantAccountId)).append("\n"); + sb.append(" grantOfferId: ").append(toIndentedString(grantOfferId)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" repayment: ").append(toIndentedString(repayment)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).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 CapitalGrant given an JSON string + * + * @param jsonString JSON string + * @return An instance of CapitalGrant + * @throws JsonProcessingException if the JSON string is invalid with respect to CapitalGrant + */ + public static CapitalGrant fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CapitalGrant.class); + } +/** + * Convert an instance of CapitalGrant 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/transfers/CapitalGrantInfo.java b/src/main/java/com/adyen/model/transfers/CapitalGrantInfo.java new file mode 100644 index 000000000..3d63c5de2 --- /dev/null +++ b/src/main/java/com/adyen/model/transfers/CapitalGrantInfo.java @@ -0,0 +1,191 @@ +/* + * Transfers API + * + * The version of the OpenAPI document: 3 + * + * + * 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.transfers; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.adyen.model.transfers.Counterparty2; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * CapitalGrantInfo + */ +@JsonPropertyOrder({ + CapitalGrantInfo.JSON_PROPERTY_COUNTERPARTY, + CapitalGrantInfo.JSON_PROPERTY_GRANT_ACCOUNT_ID, + CapitalGrantInfo.JSON_PROPERTY_GRANT_OFFER_ID +}) + +public class CapitalGrantInfo { + public static final String JSON_PROPERTY_COUNTERPARTY = "counterparty"; + private Counterparty2 counterparty; + + public static final String JSON_PROPERTY_GRANT_ACCOUNT_ID = "grantAccountId"; + private String grantAccountId; + + public static final String JSON_PROPERTY_GRANT_OFFER_ID = "grantOfferId"; + private String grantOfferId; + + public CapitalGrantInfo() { + } + + public CapitalGrantInfo counterparty(Counterparty2 counterparty) { + this.counterparty = counterparty; + return this; + } + + /** + * Get counterparty + * @return counterparty + **/ + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Counterparty2 getCounterparty() { + return counterparty; + } + + + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCounterparty(Counterparty2 counterparty) { + this.counterparty = counterparty; + } + + + public CapitalGrantInfo grantAccountId(String grantAccountId) { + this.grantAccountId = grantAccountId; + return this; + } + + /** + * The identifier of the grant account used for the grant. + * @return grantAccountId + **/ + @ApiModelProperty(required = true, value = "The identifier of the grant account used for the grant.") + @JsonProperty(JSON_PROPERTY_GRANT_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getGrantAccountId() { + return grantAccountId; + } + + + @JsonProperty(JSON_PROPERTY_GRANT_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setGrantAccountId(String grantAccountId) { + this.grantAccountId = grantAccountId; + } + + + public CapitalGrantInfo grantOfferId(String grantOfferId) { + this.grantOfferId = grantOfferId; + return this; + } + + /** + * The identifier of the grant offer that has been selected and from which the grant details will be used. + * @return grantOfferId + **/ + @ApiModelProperty(required = true, value = "The identifier of the grant offer that has been selected and from which the grant details will be used.") + @JsonProperty(JSON_PROPERTY_GRANT_OFFER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getGrantOfferId() { + return grantOfferId; + } + + + @JsonProperty(JSON_PROPERTY_GRANT_OFFER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setGrantOfferId(String grantOfferId) { + this.grantOfferId = grantOfferId; + } + + + /** + * Return true if this CapitalGrantInfo object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CapitalGrantInfo capitalGrantInfo = (CapitalGrantInfo) o; + return Objects.equals(this.counterparty, capitalGrantInfo.counterparty) && + Objects.equals(this.grantAccountId, capitalGrantInfo.grantAccountId) && + Objects.equals(this.grantOfferId, capitalGrantInfo.grantOfferId); + } + + @Override + public int hashCode() { + return Objects.hash(counterparty, grantAccountId, grantOfferId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CapitalGrantInfo {\n"); + sb.append(" counterparty: ").append(toIndentedString(counterparty)).append("\n"); + sb.append(" grantAccountId: ").append(toIndentedString(grantAccountId)).append("\n"); + sb.append(" grantOfferId: ").append(toIndentedString(grantOfferId)).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 CapitalGrantInfo given an JSON string + * + * @param jsonString JSON string + * @return An instance of CapitalGrantInfo + * @throws JsonProcessingException if the JSON string is invalid with respect to CapitalGrantInfo + */ + public static CapitalGrantInfo fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CapitalGrantInfo.class); + } +/** + * Convert an instance of CapitalGrantInfo 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/transfers/CapitalGrants.java b/src/main/java/com/adyen/model/transfers/CapitalGrants.java new file mode 100644 index 000000000..7a7352ce2 --- /dev/null +++ b/src/main/java/com/adyen/model/transfers/CapitalGrants.java @@ -0,0 +1,136 @@ +/* + * Transfers API + * + * The version of the OpenAPI document: 3 + * + * + * 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.transfers; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.adyen.model.transfers.CapitalGrant; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * CapitalGrants + */ +@JsonPropertyOrder({ + CapitalGrants.JSON_PROPERTY_GRANTS +}) + +public class CapitalGrants { + public static final String JSON_PROPERTY_GRANTS = "grants"; + private List grants = new ArrayList<>(); + + public CapitalGrants() { + } + + public CapitalGrants grants(List grants) { + this.grants = grants; + return this; + } + + public CapitalGrants addGrantsItem(CapitalGrant grantsItem) { + this.grants.add(grantsItem); + return this; + } + + /** + * The unique identifier of the grant. + * @return grants + **/ + @ApiModelProperty(required = true, value = "The unique identifier of the grant.") + @JsonProperty(JSON_PROPERTY_GRANTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public List getGrants() { + return grants; + } + + + @JsonProperty(JSON_PROPERTY_GRANTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setGrants(List grants) { + this.grants = grants; + } + + + /** + * Return true if this CapitalGrants object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CapitalGrants capitalGrants = (CapitalGrants) o; + return Objects.equals(this.grants, capitalGrants.grants); + } + + @Override + public int hashCode() { + return Objects.hash(grants); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CapitalGrants {\n"); + sb.append(" grants: ").append(toIndentedString(grants)).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 CapitalGrants given an JSON string + * + * @param jsonString JSON string + * @return An instance of CapitalGrants + * @throws JsonProcessingException if the JSON string is invalid with respect to CapitalGrants + */ + public static CapitalGrants fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CapitalGrants.class); + } +/** + * Convert an instance of CapitalGrants 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/transfers/Counterparty2.java b/src/main/java/com/adyen/model/transfers/Counterparty2.java new file mode 100644 index 000000000..0aba921b1 --- /dev/null +++ b/src/main/java/com/adyen/model/transfers/Counterparty2.java @@ -0,0 +1,191 @@ +/* + * Transfers API + * + * The version of the OpenAPI document: 3 + * + * + * 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.transfers; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * Counterparty2 + */ +@JsonPropertyOrder({ + Counterparty2.JSON_PROPERTY_ACCOUNT_HOLDER_ID, + Counterparty2.JSON_PROPERTY_BALANCE_ACCOUNT_ID, + Counterparty2.JSON_PROPERTY_TRANSFER_INSTRUMENT_ID +}) +@JsonTypeName("Counterparty-2") + +public class Counterparty2 { + public static final String JSON_PROPERTY_ACCOUNT_HOLDER_ID = "accountHolderId"; + private String accountHolderId; + + public static final String JSON_PROPERTY_BALANCE_ACCOUNT_ID = "balanceAccountId"; + private String balanceAccountId; + + public static final String JSON_PROPERTY_TRANSFER_INSTRUMENT_ID = "transferInstrumentId"; + private String transferInstrumentId; + + public Counterparty2() { + } + + public Counterparty2 accountHolderId(String accountHolderId) { + this.accountHolderId = accountHolderId; + return this; + } + + /** + * The identifier of the receiving account holder. The payout will default to the primary balance account of this account holder if no `balanceAccountId` is provided. + * @return accountHolderId + **/ + @ApiModelProperty(value = "The identifier of the receiving account holder. The payout will default to the primary balance account of this account holder if no `balanceAccountId` is provided.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getAccountHolderId() { + return accountHolderId; + } + + + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAccountHolderId(String accountHolderId) { + this.accountHolderId = accountHolderId; + } + + + public Counterparty2 balanceAccountId(String balanceAccountId) { + this.balanceAccountId = balanceAccountId; + return this; + } + + /** + * The identifier of the balance account that belongs to the receiving account holder. + * @return balanceAccountId + **/ + @ApiModelProperty(value = "The identifier of the balance account that belongs to the receiving account holder.") + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getBalanceAccountId() { + return balanceAccountId; + } + + + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBalanceAccountId(String balanceAccountId) { + this.balanceAccountId = balanceAccountId; + } + + + public Counterparty2 transferInstrumentId(String transferInstrumentId) { + this.transferInstrumentId = transferInstrumentId; + return this; + } + + /** + * The identifier of the transfer instrument that belongs to the legal entity of the account holder. + * @return transferInstrumentId + **/ + @ApiModelProperty(value = "The identifier of the transfer instrument that belongs to the legal entity of the account holder.") + @JsonProperty(JSON_PROPERTY_TRANSFER_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getTransferInstrumentId() { + return transferInstrumentId; + } + + + @JsonProperty(JSON_PROPERTY_TRANSFER_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTransferInstrumentId(String transferInstrumentId) { + this.transferInstrumentId = transferInstrumentId; + } + + + /** + * Return true if this Counterparty-2 object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Counterparty2 counterparty2 = (Counterparty2) o; + return Objects.equals(this.accountHolderId, counterparty2.accountHolderId) && + Objects.equals(this.balanceAccountId, counterparty2.balanceAccountId) && + Objects.equals(this.transferInstrumentId, counterparty2.transferInstrumentId); + } + + @Override + public int hashCode() { + return Objects.hash(accountHolderId, balanceAccountId, transferInstrumentId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Counterparty2 {\n"); + sb.append(" accountHolderId: ").append(toIndentedString(accountHolderId)).append("\n"); + sb.append(" balanceAccountId: ").append(toIndentedString(balanceAccountId)).append("\n"); + sb.append(" transferInstrumentId: ").append(toIndentedString(transferInstrumentId)).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 Counterparty2 given an JSON string + * + * @param jsonString JSON string + * @return An instance of Counterparty2 + * @throws JsonProcessingException if the JSON string is invalid with respect to Counterparty2 + */ + public static Counterparty2 fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Counterparty2.class); + } +/** + * Convert an instance of Counterparty2 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/transfers/CounterpartyInfoV3.java b/src/main/java/com/adyen/model/transfers/CounterpartyInfoV3.java index 081f88daf..845a3953b 100644 --- a/src/main/java/com/adyen/model/transfers/CounterpartyInfoV3.java +++ b/src/main/java/com/adyen/model/transfers/CounterpartyInfoV3.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,60 +14,43 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.BankAccountV3; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * CounterpartyInfoV3 */ +@JsonPropertyOrder({ + CounterpartyInfoV3.JSON_PROPERTY_BALANCE_ACCOUNT_ID, + CounterpartyInfoV3.JSON_PROPERTY_BANK_ACCOUNT, + CounterpartyInfoV3.JSON_PROPERTY_TRANSFER_INSTRUMENT_ID +}) public class CounterpartyInfoV3 { - public static final String SERIALIZED_NAME_BALANCE_ACCOUNT_ID = "balanceAccountId"; - @SerializedName(SERIALIZED_NAME_BALANCE_ACCOUNT_ID) + public static final String JSON_PROPERTY_BALANCE_ACCOUNT_ID = "balanceAccountId"; private String balanceAccountId; - public static final String SERIALIZED_NAME_BANK_ACCOUNT = "bankAccount"; - @SerializedName(SERIALIZED_NAME_BANK_ACCOUNT) + public static final String JSON_PROPERTY_BANK_ACCOUNT = "bankAccount"; private BankAccountV3 bankAccount; - public static final String SERIALIZED_NAME_TRANSFER_INSTRUMENT_ID = "transferInstrumentId"; - @SerializedName(SERIALIZED_NAME_TRANSFER_INSTRUMENT_ID) + public static final String JSON_PROPERTY_TRANSFER_INSTRUMENT_ID = "transferInstrumentId"; private String transferInstrumentId; public CounterpartyInfoV3() { } public CounterpartyInfoV3 balanceAccountId(String balanceAccountId) { - this.balanceAccountId = balanceAccountId; return this; } @@ -77,19 +60,22 @@ public CounterpartyInfoV3 balanceAccountId(String balanceAccountId) { * @return balanceAccountId **/ @ApiModelProperty(value = "Unique identifier of the [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id).") + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBalanceAccountId() { return balanceAccountId; } + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalanceAccountId(String balanceAccountId) { this.balanceAccountId = balanceAccountId; } public CounterpartyInfoV3 bankAccount(BankAccountV3 bankAccount) { - this.bankAccount = bankAccount; return this; } @@ -99,19 +85,22 @@ public CounterpartyInfoV3 bankAccount(BankAccountV3 bankAccount) { * @return bankAccount **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_BANK_ACCOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public BankAccountV3 getBankAccount() { return bankAccount; } + @JsonProperty(JSON_PROPERTY_BANK_ACCOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBankAccount(BankAccountV3 bankAccount) { this.bankAccount = bankAccount; } public CounterpartyInfoV3 transferInstrumentId(String transferInstrumentId) { - this.transferInstrumentId = transferInstrumentId; return this; } @@ -121,18 +110,24 @@ public CounterpartyInfoV3 transferInstrumentId(String transferInstrumentId) { * @return transferInstrumentId **/ @ApiModelProperty(value = "Unique identifier of the [transfer instrument](https://docs.adyen.com/api-explorer/#/legalentity/latest/post/transferInstruments__resParam_id).") + @JsonProperty(JSON_PROPERTY_TRANSFER_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getTransferInstrumentId() { return transferInstrumentId; } + @JsonProperty(JSON_PROPERTY_TRANSFER_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTransferInstrumentId(String transferInstrumentId) { this.transferInstrumentId = transferInstrumentId; } - + /** + * Return true if this CounterpartyInfoV3 object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -174,108 +169,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("balanceAccountId"); - openapiFields.add("bankAccount"); - openapiFields.add("transferInstrumentId"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(CounterpartyInfoV3.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to CounterpartyInfoV3 - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (CounterpartyInfoV3.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in CounterpartyInfoV3 is not found in the empty JSON string", CounterpartyInfoV3.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!CounterpartyInfoV3.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `CounterpartyInfoV3` properties.", entry.getKey())); - } - } - // validate the optional field balanceAccountId - if (jsonObj.get("balanceAccountId") != null && !jsonObj.get("balanceAccountId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `balanceAccountId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("balanceAccountId").toString())); - } - // validate the optional field `bankAccount` - if (jsonObj.getAsJsonObject("bankAccount") != null) { - BankAccountV3.validateJsonObject(jsonObj.getAsJsonObject("bankAccount")); - } - // validate the optional field transferInstrumentId - if (jsonObj.get("transferInstrumentId") != null && !jsonObj.get("transferInstrumentId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `transferInstrumentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transferInstrumentId").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!CounterpartyInfoV3.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'CounterpartyInfoV3' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(CounterpartyInfoV3.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, CounterpartyInfoV3 value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public CounterpartyInfoV3 read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of CounterpartyInfoV3 given an JSON string - * - * @param jsonString JSON string - * @return An instance of CounterpartyInfoV3 - * @throws IOException if the JSON string is invalid with respect to CounterpartyInfoV3 - */ - public static CounterpartyInfoV3 fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, CounterpartyInfoV3.class); +/** + * Create an instance of CounterpartyInfoV3 given an JSON string + * + * @param jsonString JSON string + * @return An instance of CounterpartyInfoV3 + * @throws JsonProcessingException if the JSON string is invalid with respect to CounterpartyInfoV3 + */ + public static CounterpartyInfoV3 fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CounterpartyInfoV3.class); } - - /** +/** * Convert an instance of CounterpartyInfoV3 to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/CounterpartyV3.java b/src/main/java/com/adyen/model/transfers/CounterpartyV3.java index 71fe37c48..ea2b56b9a 100644 --- a/src/main/java/com/adyen/model/transfers/CounterpartyV3.java +++ b/src/main/java/com/adyen/model/transfers/CounterpartyV3.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,65 +14,48 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.BankAccountV3; import com.adyen.model.transfers.MerchantData; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * CounterpartyV3 */ +@JsonPropertyOrder({ + CounterpartyV3.JSON_PROPERTY_BALANCE_ACCOUNT_ID, + CounterpartyV3.JSON_PROPERTY_BANK_ACCOUNT, + CounterpartyV3.JSON_PROPERTY_MERCHANT, + CounterpartyV3.JSON_PROPERTY_TRANSFER_INSTRUMENT_ID +}) public class CounterpartyV3 { - public static final String SERIALIZED_NAME_BALANCE_ACCOUNT_ID = "balanceAccountId"; - @SerializedName(SERIALIZED_NAME_BALANCE_ACCOUNT_ID) + public static final String JSON_PROPERTY_BALANCE_ACCOUNT_ID = "balanceAccountId"; private String balanceAccountId; - public static final String SERIALIZED_NAME_BANK_ACCOUNT = "bankAccount"; - @SerializedName(SERIALIZED_NAME_BANK_ACCOUNT) + public static final String JSON_PROPERTY_BANK_ACCOUNT = "bankAccount"; private BankAccountV3 bankAccount; - public static final String SERIALIZED_NAME_MERCHANT = "merchant"; - @SerializedName(SERIALIZED_NAME_MERCHANT) + public static final String JSON_PROPERTY_MERCHANT = "merchant"; private MerchantData merchant; - public static final String SERIALIZED_NAME_TRANSFER_INSTRUMENT_ID = "transferInstrumentId"; - @SerializedName(SERIALIZED_NAME_TRANSFER_INSTRUMENT_ID) + public static final String JSON_PROPERTY_TRANSFER_INSTRUMENT_ID = "transferInstrumentId"; private String transferInstrumentId; public CounterpartyV3() { } public CounterpartyV3 balanceAccountId(String balanceAccountId) { - this.balanceAccountId = balanceAccountId; return this; } @@ -82,19 +65,22 @@ public CounterpartyV3 balanceAccountId(String balanceAccountId) { * @return balanceAccountId **/ @ApiModelProperty(value = "Unique identifier of the [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id).") + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBalanceAccountId() { return balanceAccountId; } + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalanceAccountId(String balanceAccountId) { this.balanceAccountId = balanceAccountId; } public CounterpartyV3 bankAccount(BankAccountV3 bankAccount) { - this.bankAccount = bankAccount; return this; } @@ -104,19 +90,22 @@ public CounterpartyV3 bankAccount(BankAccountV3 bankAccount) { * @return bankAccount **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_BANK_ACCOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public BankAccountV3 getBankAccount() { return bankAccount; } + @JsonProperty(JSON_PROPERTY_BANK_ACCOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBankAccount(BankAccountV3 bankAccount) { this.bankAccount = bankAccount; } public CounterpartyV3 merchant(MerchantData merchant) { - this.merchant = merchant; return this; } @@ -126,19 +115,22 @@ public CounterpartyV3 merchant(MerchantData merchant) { * @return merchant **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_MERCHANT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public MerchantData getMerchant() { return merchant; } + @JsonProperty(JSON_PROPERTY_MERCHANT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setMerchant(MerchantData merchant) { this.merchant = merchant; } public CounterpartyV3 transferInstrumentId(String transferInstrumentId) { - this.transferInstrumentId = transferInstrumentId; return this; } @@ -148,18 +140,24 @@ public CounterpartyV3 transferInstrumentId(String transferInstrumentId) { * @return transferInstrumentId **/ @ApiModelProperty(value = "Unique identifier of the [transfer instrument](https://docs.adyen.com/api-explorer/#/legalentity/latest/post/transferInstruments__resParam_id).") + @JsonProperty(JSON_PROPERTY_TRANSFER_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getTransferInstrumentId() { return transferInstrumentId; } + @JsonProperty(JSON_PROPERTY_TRANSFER_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTransferInstrumentId(String transferInstrumentId) { this.transferInstrumentId = transferInstrumentId; } - + /** + * Return true if this CounterpartyV3 object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -203,113 +201,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("balanceAccountId"); - openapiFields.add("bankAccount"); - openapiFields.add("merchant"); - openapiFields.add("transferInstrumentId"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(CounterpartyV3.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to CounterpartyV3 - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (CounterpartyV3.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in CounterpartyV3 is not found in the empty JSON string", CounterpartyV3.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!CounterpartyV3.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `CounterpartyV3` properties.", entry.getKey())); - } - } - // validate the optional field balanceAccountId - if (jsonObj.get("balanceAccountId") != null && !jsonObj.get("balanceAccountId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `balanceAccountId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("balanceAccountId").toString())); - } - // validate the optional field `bankAccount` - if (jsonObj.getAsJsonObject("bankAccount") != null) { - BankAccountV3.validateJsonObject(jsonObj.getAsJsonObject("bankAccount")); - } - // validate the optional field `merchant` - if (jsonObj.getAsJsonObject("merchant") != null) { - MerchantData.validateJsonObject(jsonObj.getAsJsonObject("merchant")); - } - // validate the optional field transferInstrumentId - if (jsonObj.get("transferInstrumentId") != null && !jsonObj.get("transferInstrumentId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `transferInstrumentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transferInstrumentId").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!CounterpartyV3.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'CounterpartyV3' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(CounterpartyV3.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, CounterpartyV3 value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public CounterpartyV3 read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of CounterpartyV3 given an JSON string - * - * @param jsonString JSON string - * @return An instance of CounterpartyV3 - * @throws IOException if the JSON string is invalid with respect to CounterpartyV3 - */ - public static CounterpartyV3 fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, CounterpartyV3.class); +/** + * Create an instance of CounterpartyV3 given an JSON string + * + * @param jsonString JSON string + * @return An instance of CounterpartyV3 + * @throws JsonProcessingException if the JSON string is invalid with respect to CounterpartyV3 + */ + public static CounterpartyV3 fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, CounterpartyV3.class); } - - /** +/** * Convert an instance of CounterpartyV3 to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/DKLocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/DKLocalAccountIdentification.java index 174c324b2..b143e3cfd 100644 --- a/src/main/java/com/adyen/model/transfers/DKLocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/DKLocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,54 +14,38 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * DKLocalAccountIdentification */ +@JsonPropertyOrder({ + DKLocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + DKLocalAccountIdentification.JSON_PROPERTY_BANK_CODE, + DKLocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class DKLocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; - public static final String SERIALIZED_NAME_BANK_CODE = "bankCode"; - @SerializedName(SERIALIZED_NAME_BANK_CODE) + public static final String JSON_PROPERTY_BANK_CODE = "bankCode"; private String bankCode; /** * **dkLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { DKLOCAL("dkLocal"); @@ -71,6 +55,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -80,6 +65,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -88,30 +74,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.DKLOCAL; public DKLocalAccountIdentification() { } public DKLocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -121,19 +92,22 @@ public DKLocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The 4-10 digits bank account number (Kontonummer) (without separators or whitespace).") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public DKLocalAccountIdentification bankCode(String bankCode) { - this.bankCode = bankCode; return this; } @@ -143,19 +117,22 @@ public DKLocalAccountIdentification bankCode(String bankCode) { * @return bankCode **/ @ApiModelProperty(required = true, value = "The 4-digit bank code (Registreringsnummer) (without separators or whitespace).") + @JsonProperty(JSON_PROPERTY_BANK_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBankCode() { return bankCode; } + @JsonProperty(JSON_PROPERTY_BANK_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBankCode(String bankCode) { this.bankCode = bankCode; } public DKLocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -165,18 +142,24 @@ public DKLocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**dkLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this DKLocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -218,121 +201,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("bankCode"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("bankCode"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(DKLocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to DKLocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (DKLocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in DKLocalAccountIdentification is not found in the empty JSON string", DKLocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!DKLocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `DKLocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : DKLocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // validate the optional field bankCode - if (jsonObj.get("bankCode") != null && !jsonObj.get("bankCode").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `bankCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bankCode").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!DKLocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'DKLocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(DKLocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, DKLocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public DKLocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of DKLocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of DKLocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to DKLocalAccountIdentification - */ - public static DKLocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, DKLocalAccountIdentification.class); +/** + * Create an instance of DKLocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of DKLocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to DKLocalAccountIdentification + */ + public static DKLocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, DKLocalAccountIdentification.class); } - - /** +/** * Convert an instance of DKLocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/Fee.java b/src/main/java/com/adyen/model/transfers/Fee.java new file mode 100644 index 000000000..8042a674a --- /dev/null +++ b/src/main/java/com/adyen/model/transfers/Fee.java @@ -0,0 +1,129 @@ +/* + * Transfers API + * + * The version of the OpenAPI document: 3 + * + * + * 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.transfers; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.adyen.model.transfers.Amount; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * Fee + */ +@JsonPropertyOrder({ + Fee.JSON_PROPERTY_AMOUNT +}) + +public class Fee { + public static final String JSON_PROPERTY_AMOUNT = "amount"; + private Amount amount; + + public Fee() { + } + + public Fee amount(Amount amount) { + this.amount = amount; + return this; + } + + /** + * Get amount + * @return amount + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Amount getAmount() { + return amount; + } + + + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAmount(Amount amount) { + this.amount = amount; + } + + + /** + * Return true if this Fee object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Fee fee = (Fee) o; + return Objects.equals(this.amount, fee.amount); + } + + @Override + public int hashCode() { + return Objects.hash(amount); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Fee {\n"); + sb.append(" amount: ").append(toIndentedString(amount)).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 Fee given an JSON string + * + * @param jsonString JSON string + * @return An instance of Fee + * @throws JsonProcessingException if the JSON string is invalid with respect to Fee + */ + public static Fee fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Fee.class); + } +/** + * Convert an instance of Fee 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/transfers/HULocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/HULocalAccountIdentification.java index 0e2e3bec4..5131ff507 100644 --- a/src/main/java/com/adyen/model/transfers/HULocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/HULocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,50 +14,34 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * HULocalAccountIdentification */ +@JsonPropertyOrder({ + HULocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + HULocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class HULocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; /** * **huLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { HULOCAL("huLocal"); @@ -67,6 +51,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -76,6 +61,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -84,30 +70,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.HULOCAL; public HULocalAccountIdentification() { } public HULocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -117,19 +88,22 @@ public HULocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The 24-digit bank account number, without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public HULocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -139,18 +113,24 @@ public HULocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**huLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this HULocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -190,115 +170,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(HULocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to HULocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (HULocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in HULocalAccountIdentification is not found in the empty JSON string", HULocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!HULocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `HULocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : HULocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!HULocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'HULocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(HULocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, HULocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public HULocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of HULocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of HULocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to HULocalAccountIdentification - */ - public static HULocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, HULocalAccountIdentification.class); +/** + * Create an instance of HULocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of HULocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to HULocalAccountIdentification + */ + public static HULocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, HULocalAccountIdentification.class); } - - /** +/** * Convert an instance of HULocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/IbanAccountIdentification.java b/src/main/java/com/adyen/model/transfers/IbanAccountIdentification.java index 4e86f1d57..d86dc123c 100644 --- a/src/main/java/com/adyen/model/transfers/IbanAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/IbanAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,50 +14,34 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * IbanAccountIdentification */ +@JsonPropertyOrder({ + IbanAccountIdentification.JSON_PROPERTY_IBAN, + IbanAccountIdentification.JSON_PROPERTY_TYPE +}) public class IbanAccountIdentification { - public static final String SERIALIZED_NAME_IBAN = "iban"; - @SerializedName(SERIALIZED_NAME_IBAN) + public static final String JSON_PROPERTY_IBAN = "iban"; private String iban; /** * **iban** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { IBAN("iban"); @@ -67,6 +51,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -76,6 +61,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -84,30 +70,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.IBAN; public IbanAccountIdentification() { } public IbanAccountIdentification iban(String iban) { - this.iban = iban; return this; } @@ -117,19 +88,22 @@ public IbanAccountIdentification iban(String iban) { * @return iban **/ @ApiModelProperty(required = true, value = "The international bank account number as defined in the [ISO-13616](https://www.iso.org/standard/81090.html) standard.") + @JsonProperty(JSON_PROPERTY_IBAN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getIban() { return iban; } + @JsonProperty(JSON_PROPERTY_IBAN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setIban(String iban) { this.iban = iban; } public IbanAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -139,18 +113,24 @@ public IbanAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**iban**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this IbanAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -190,115 +170,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("iban"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("iban"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(IbanAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to IbanAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (IbanAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in IbanAccountIdentification is not found in the empty JSON string", IbanAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!IbanAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `IbanAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : IbanAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field iban - if (jsonObj.get("iban") != null && !jsonObj.get("iban").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `iban` to be a primitive type in the JSON string but got `%s`", jsonObj.get("iban").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!IbanAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'IbanAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(IbanAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, IbanAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public IbanAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of IbanAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of IbanAccountIdentification - * @throws IOException if the JSON string is invalid with respect to IbanAccountIdentification - */ - public static IbanAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, IbanAccountIdentification.class); +/** + * Create an instance of IbanAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of IbanAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to IbanAccountIdentification + */ + public static IbanAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, IbanAccountIdentification.class); } - - /** +/** * Convert an instance of IbanAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/InvalidField.java b/src/main/java/com/adyen/model/transfers/InvalidField.java index 75106bac2..868860d33 100644 --- a/src/main/java/com/adyen/model/transfers/InvalidField.java +++ b/src/main/java/com/adyen/model/transfers/InvalidField.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,59 +14,42 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * InvalidField */ +@JsonPropertyOrder({ + InvalidField.JSON_PROPERTY_MESSAGE, + InvalidField.JSON_PROPERTY_NAME, + InvalidField.JSON_PROPERTY_VALUE +}) public class InvalidField { - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) + public static final String JSON_PROPERTY_MESSAGE = "message"; private String message; - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) + public static final String JSON_PROPERTY_NAME = "name"; private String name; - public static final String SERIALIZED_NAME_VALUE = "value"; - @SerializedName(SERIALIZED_NAME_VALUE) + public static final String JSON_PROPERTY_VALUE = "value"; private String value; public InvalidField() { } public InvalidField message(String message) { - this.message = message; return this; } @@ -76,19 +59,22 @@ public InvalidField message(String message) { * @return message **/ @ApiModelProperty(required = true, value = "Description of the validation error.") + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getMessage() { return message; } + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setMessage(String message) { this.message = message; } public InvalidField name(String name) { - this.name = name; return this; } @@ -98,19 +84,22 @@ public InvalidField name(String name) { * @return name **/ @ApiModelProperty(required = true, value = "The field that has an invalid value.") + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getName() { return name; } + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setName(String name) { this.name = name; } public InvalidField value(String value) { - this.value = value; return this; } @@ -120,18 +109,24 @@ public InvalidField value(String value) { * @return value **/ @ApiModelProperty(required = true, value = "The invalid value.") + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getValue() { return value; } + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setValue(String value) { this.value = value; } - + /** + * Return true if this InvalidField object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -173,118 +168,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("message"); - openapiFields.add("name"); - openapiFields.add("value"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("message"); - openapiRequiredFields.add("name"); - openapiRequiredFields.add("value"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(InvalidField.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to InvalidField - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (InvalidField.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in InvalidField is not found in the empty JSON string", InvalidField.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!InvalidField.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `InvalidField` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : InvalidField.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field message - if (jsonObj.get("message") != null && !jsonObj.get("message").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - // validate the optional field name - if (jsonObj.get("name") != null && !jsonObj.get("name").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); - } - // validate the optional field value - if (jsonObj.get("value") != null && !jsonObj.get("value").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!InvalidField.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'InvalidField' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(InvalidField.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, InvalidField value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public InvalidField read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of InvalidField given an JSON string - * - * @param jsonString JSON string - * @return An instance of InvalidField - * @throws IOException if the JSON string is invalid with respect to InvalidField - */ - public static InvalidField fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, InvalidField.class); +/** + * 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() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/JSON.java b/src/main/java/com/adyen/model/transfers/JSON.java index 92d18adb6..4baea8013 100644 --- a/src/main/java/com/adyen/model/transfers/JSON.java +++ b/src/main/java/com/adyen/model/transfers/JSON.java @@ -1,435 +1,251 @@ -/* - * Transfers API - * - * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com - * - * 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.transfers; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapter; -import com.google.gson.internal.bind.util.ISO8601Utils; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.google.gson.JsonElement; -import io.gsonfire.GsonFireBuilder; -import io.gsonfire.TypeSelector; +import com.adyen.serializer.ByteArraySerializer; +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.adyen.model.transfers.*; -import org.apache.commons.codec.binary.Base64; - -import java.io.IOException; -import java.io.StringReader; -import java.lang.reflect.Type; import java.text.DateFormat; -import java.text.ParseException; -import java.text.ParsePosition; -import java.time.LocalDate; -import java.time.OffsetDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Date; -import java.util.Locale; -import java.util.Map; import java.util.HashMap; - -/* - * A JSON utility class - * - * NOTE: in the future, this class may be converted to static, which may break - * backward-compatibility - */ -public class JSON { - private static Gson gson; - private static boolean isLenientOnJson = false; - private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); - private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); - private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); - private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); - private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); - - @SuppressWarnings("unchecked") - public static GsonBuilder createGson() { - GsonFireBuilder fireBuilder = new GsonFireBuilder() - ; - GsonBuilder builder = fireBuilder.createGsonBuilder(); - return builder; - } - - private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { - JsonElement element = readElement.getAsJsonObject().get(discriminatorField); - if (null == element) { - throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); - } - return element.getAsString(); - } - - /** - * Returns the Java class that implements the OpenAPI schema for the specified discriminator value. - * - * @param classByDiscriminatorValue The map of discriminator values to Java classes. - * @param discriminatorValue The value of the OpenAPI discriminator in the input data. - * @return The Java class that implements the OpenAPI schema - */ - private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { - Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); - if (null == clazz) { - throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); - } - return clazz; - } - - static { - GsonBuilder gsonBuilder = createGson(); - gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); - gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); - gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); - gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); - gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.AULocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.AdditionalBankIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.Address2.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.Amount.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.BRLocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.BankAccountV3.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.BankAccountV3AccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.CALocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.CZLocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.CounterpartyInfoV3.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.CounterpartyV3.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.DKLocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.HULocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.IbanAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.InvalidField.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.JSONObject.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.JSONPath.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.Link.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.Links.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.MerchantData.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.NOLocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.NameLocation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.NumberAndBicAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.PLLocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.PartyIdentification2.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.PaymentInstrument.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.ResourceReference.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.RestServiceError.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.SELocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.SGLocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.Transaction.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.TransactionSearchResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.Transfer.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.TransferInfo.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.UKLocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.USLocalAccountIdentification.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.adyen.model.transfers.UltimatePartyIdentification.CustomTypeAdapterFactory()); - gson = gsonBuilder.create(); - } - - /** - * Get Gson. - * - * @return Gson - */ - public static Gson getGson() { - return gson; - } - - /** - * Set Gson. - * - * @param gson Gson - */ - public static void setGson(Gson gson) { - JSON.gson = gson; - } - - public static void setLenientOnJson(boolean lenientOnJson) { - isLenientOnJson = lenientOnJson; - } - - /** - * Serialize the given Java object into JSON string. - * - * @param obj Object - * @return String representation of the JSON - */ - public static String serialize(Object obj) { - return gson.toJson(obj); +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.ext.ContextResolver; + +public class JSON implements ContextResolver { + private static ObjectMapper mapper; + + public JSON() { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false); + 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()); + 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; } /** - * Deserialize the given JSON string to Java object. + * 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 Type - * @param body The JSON string - * @param returnType The type to deserialize into - * @return The deserialized Java object - */ - @SuppressWarnings("unchecked") - public static T deserialize(String body, Type returnType) { - try { - if (isLenientOnJson) { - JsonReader jsonReader = new JsonReader(new StringReader(body)); - // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) - jsonReader.setLenient(true); - return gson.fromJson(jsonReader, returnType); - } else { - return gson.fromJson(body, returnType); - } - } catch (JsonParseException e) { - // Fallback processing when failed to parse JSON form response body: - // return the response body string directly for the String return type; - if (returnType.equals(String.class)) { - return (T) body; - } else { - throw (e); - } - } - } - - /** - * Gson TypeAdapter for Byte Array type - */ - public static class ByteArrayAdapter extends TypeAdapter { - - @Override - public void write(JsonWriter out, byte[] value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(new String(value)); - } - } - - @Override - public byte[] read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String bytesAsBase64 = in.nextString(); - return Base64.decodeBase64(bytesAsBase64); - } - } - } - - /** - * Gson TypeAdapter for JSR310 OffsetDateTime type + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. */ - public static class OffsetDateTimeTypeAdapter extends TypeAdapter { - - private DateTimeFormatter formatter; - - public OffsetDateTimeTypeAdapter() { - this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); - } - - public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - - public void setFormat(DateTimeFormatter dateFormat) { - this.formatter = dateFormat; - } - - @Override - public void write(JsonWriter out, OffsetDateTime date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - out.value(formatter.format(date)); - } - } - - @Override - public OffsetDateTime read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - if (date.endsWith("+0000")) { - date = date.substring(0, date.length()-5) + "Z"; - } - return OffsetDateTime.parse(date, formatter); - } - } - } - - /** - * Gson TypeAdapter for JSR310 LocalDate type - */ - public static class LocalDateTypeAdapter extends TypeAdapter { - - private DateTimeFormatter formatter; - - public LocalDateTypeAdapter() { - this(DateTimeFormatter.ISO_LOCAL_DATE); - } - - public LocalDateTypeAdapter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - - public void setFormat(DateTimeFormatter dateFormat) { - this.formatter = dateFormat; - } - - @Override - public void write(JsonWriter out, LocalDate date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - out.value(formatter.format(date)); - } - } - - @Override - public LocalDate read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - return LocalDate.parse(date, formatter); - } - } - } - - public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - offsetDateTimeTypeAdapter.setFormat(dateFormat); - } - - public static void setLocalDateFormat(DateTimeFormatter dateFormat) { - localDateTypeAdapter.setFormat(dateFormat); - } - - /** - * Gson TypeAdapter for java.sql.Date type - * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used - * (more efficient than SimpleDateFormat). - */ - public static class SqlDateTypeAdapter extends TypeAdapter { - - private DateFormat dateFormat; - - public SqlDateTypeAdapter() {} - - public SqlDateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - @Override - public void write(JsonWriter out, java.sql.Date date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); - } else { - value = date.toString(); - } - out.value(value); - } - } - - @Override - public java.sql.Date read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return new java.sql.Date(dateFormat.parse(date).getTime()); - } - return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); - } catch (ParseException e) { - throw new JsonParseException(e); - } - } - } - } - - /** - * Gson TypeAdapter for java.util.Date type - * If the dateFormat is null, ISO8601Utils will be used. - */ - public static class DateTypeAdapter extends TypeAdapter { - - private DateFormat dateFormat; - - public DateTypeAdapter() {} - - public DateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - @Override - public void write(JsonWriter out, Date date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); - } else { - value = ISO8601Utils.format(date, true); - } - out.value(value); - } - } - - @Override - public Date read(JsonReader in) throws IOException { - try { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return dateFormat.parse(date); - } - return ISO8601Utils.parse(date, new ParsePosition(0)); - } catch (ParseException e) { - throw new JsonParseException(e); - } - } - } catch (IllegalArgumentException e) { - throw new JsonParseException(e); - } - } - } - - public static void setDateFormat(DateFormat dateFormat) { - dateTypeAdapter.setFormat(dateFormat); - } - - public static void setSqlDateFormat(DateFormat dateFormat) { - sqlDateTypeAdapter.setFormat(dateFormat); - } + 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 Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap, ClassDiscriminatorMapping>(); + + /** + * A map of oneOf/anyOf descendants for each model class. + */ + private static Map, Map> modelDescendants = new HashMap, Map>(); + + /** + * 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/transfers/JSONObject.java b/src/main/java/com/adyen/model/transfers/JSONObject.java index 12e433c1f..832f99a52 100644 --- a/src/main/java/com/adyen/model/transfers/JSONObject.java +++ b/src/main/java/com/adyen/model/transfers/JSONObject.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,58 +14,41 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.JSONPath; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.adyen.model.transfers.JSON; /** * JSONObject */ +@JsonPropertyOrder({ + JSONObject.JSON_PROPERTY_PATHS, + JSONObject.JSON_PROPERTY_ROOT_PATH +}) public class JSONObject { - public static final String SERIALIZED_NAME_PATHS = "paths"; - @SerializedName(SERIALIZED_NAME_PATHS) + public static final String JSON_PROPERTY_PATHS = "paths"; private List paths = null; - public static final String SERIALIZED_NAME_ROOT_PATH = "rootPath"; - @SerializedName(SERIALIZED_NAME_ROOT_PATH) + public static final String JSON_PROPERTY_ROOT_PATH = "rootPath"; private JSONPath rootPath; public JSONObject() { } public JSONObject paths(List paths) { - this.paths = paths; return this; } @@ -83,19 +66,22 @@ public JSONObject addPathsItem(JSONPath pathsItem) { * @return paths **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_PATHS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getPaths() { return paths; } + @JsonProperty(JSON_PROPERTY_PATHS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPaths(List paths) { this.paths = paths; } public JSONObject rootPath(JSONPath rootPath) { - this.rootPath = rootPath; return this; } @@ -105,18 +91,24 @@ public JSONObject rootPath(JSONPath rootPath) { * @return rootPath **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_ROOT_PATH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public JSONPath getRootPath() { return rootPath; } + @JsonProperty(JSON_PROPERTY_ROOT_PATH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setRootPath(JSONPath rootPath) { this.rootPath = rootPath; } - + /** + * Return true if this JSONObject object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -156,111 +148,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("paths"); - openapiFields.add("rootPath"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(JSONObject.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to JSONObject - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (JSONObject.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in JSONObject is not found in the empty JSON string", JSONObject.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!JSONObject.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `JSONObject` properties.", entry.getKey())); - } - } - JsonArray jsonArraypaths = jsonObj.getAsJsonArray("paths"); - if (jsonArraypaths != null) { - // ensure the json data is an array - if (!jsonObj.get("paths").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `paths` to be an array in the JSON string but got `%s`", jsonObj.get("paths").toString())); - } - - // validate the optional field `paths` (array) - for (int i = 0; i < jsonArraypaths.size(); i++) { - JSONPath.validateJsonObject(jsonArraypaths.get(i).getAsJsonObject()); - } - } - // validate the optional field `rootPath` - if (jsonObj.getAsJsonObject("rootPath") != null) { - JSONPath.validateJsonObject(jsonObj.getAsJsonObject("rootPath")); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!JSONObject.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'JSONObject' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(JSONObject.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, JSONObject value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public JSONObject read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of JSONObject given an JSON string - * - * @param jsonString JSON string - * @return An instance of JSONObject - * @throws IOException if the JSON string is invalid with respect to JSONObject - */ - public static JSONObject fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, JSONObject.class); +/** + * Create an instance of JSONObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of JSONObject + * @throws JsonProcessingException if the JSON string is invalid with respect to JSONObject + */ + public static JSONObject fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, JSONObject.class); } - - /** +/** * Convert an instance of JSONObject to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/JSONPath.java b/src/main/java/com/adyen/model/transfers/JSONPath.java index 5dd5c5774..d6b614c02 100644 --- a/src/main/java/com/adyen/model/transfers/JSONPath.java +++ b/src/main/java/com/adyen/model/transfers/JSONPath.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,53 +14,36 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.adyen.model.transfers.JSON; /** * JSONPath */ +@JsonPropertyOrder({ + JSONPath.JSON_PROPERTY_CONTENT +}) public class JSONPath { - public static final String SERIALIZED_NAME_CONTENT = "content"; - @SerializedName(SERIALIZED_NAME_CONTENT) + public static final String JSON_PROPERTY_CONTENT = "content"; private List content = null; public JSONPath() { } public JSONPath content(List content) { - this.content = content; return this; } @@ -78,18 +61,24 @@ public JSONPath addContentItem(String contentItem) { * @return content **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_CONTENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getContent() { return content; } + @JsonProperty(JSON_PROPERTY_CONTENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setContent(List content) { this.content = content; } - + /** + * Return true if this JSONPath object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -127,98 +116,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("content"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(JSONPath.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to JSONPath - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (JSONPath.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in JSONPath is not found in the empty JSON string", JSONPath.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!JSONPath.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `JSONPath` properties.", entry.getKey())); - } - } - // ensure the json data is an array - if (jsonObj.get("content") != null && !jsonObj.get("content").isJsonArray()) { - log.log(Level.WARNING, String.format("Expected the field `content` to be an array in the JSON string but got `%s`", jsonObj.get("content").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!JSONPath.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'JSONPath' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(JSONPath.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, JSONPath value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public JSONPath read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of JSONPath given an JSON string - * - * @param jsonString JSON string - * @return An instance of JSONPath - * @throws IOException if the JSON string is invalid with respect to JSONPath - */ - public static JSONPath fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, JSONPath.class); +/** + * Create an instance of JSONPath given an JSON string + * + * @param jsonString JSON string + * @return An instance of JSONPath + * @throws JsonProcessingException if the JSON string is invalid with respect to JSONPath + */ + public static JSONPath fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, JSONPath.class); } - - /** +/** * Convert an instance of JSONPath to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/Link.java b/src/main/java/com/adyen/model/transfers/Link.java index 2fcf9879e..c62ea3295 100644 --- a/src/main/java/com/adyen/model/transfers/Link.java +++ b/src/main/java/com/adyen/model/transfers/Link.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,51 +14,34 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * Link */ +@JsonPropertyOrder({ + Link.JSON_PROPERTY_HREF +}) public class Link { - public static final String SERIALIZED_NAME_HREF = "href"; - @SerializedName(SERIALIZED_NAME_HREF) + public static final String JSON_PROPERTY_HREF = "href"; private String href; public Link() { } public Link href(String href) { - this.href = href; return this; } @@ -68,18 +51,24 @@ public Link href(String href) { * @return href **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_HREF) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getHref() { return href; } + @JsonProperty(JSON_PROPERTY_HREF) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setHref(String href) { this.href = href; } - + /** + * Return true if this Link object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -117,98 +106,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("href"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(Link.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to Link - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (Link.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in Link is not found in the empty JSON string", Link.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!Link.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `Link` properties.", entry.getKey())); - } - } - // validate the optional field href - if (jsonObj.get("href") != null && !jsonObj.get("href").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `href` to be a primitive type in the JSON string but got `%s`", jsonObj.get("href").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Link.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Link' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Link.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Link value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Link read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of Link given an JSON string - * - * @param jsonString JSON string - * @return An instance of Link - * @throws IOException if the JSON string is invalid with respect to Link - */ - public static Link fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Link.class); +/** + * Create an instance of Link given an JSON string + * + * @param jsonString JSON string + * @return An instance of Link + * @throws JsonProcessingException if the JSON string is invalid with respect to Link + */ + public static Link fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Link.class); } - - /** +/** * Convert an instance of Link to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/Links.java b/src/main/java/com/adyen/model/transfers/Links.java index 6998b11a6..ab1790f6e 100644 --- a/src/main/java/com/adyen/model/transfers/Links.java +++ b/src/main/java/com/adyen/model/transfers/Links.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,56 +14,39 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.Link; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * Links */ +@JsonPropertyOrder({ + Links.JSON_PROPERTY_NEXT, + Links.JSON_PROPERTY_PREV +}) public class Links { - public static final String SERIALIZED_NAME_NEXT = "next"; - @SerializedName(SERIALIZED_NAME_NEXT) + public static final String JSON_PROPERTY_NEXT = "next"; private Link next; - public static final String SERIALIZED_NAME_PREV = "prev"; - @SerializedName(SERIALIZED_NAME_PREV) + public static final String JSON_PROPERTY_PREV = "prev"; private Link prev; public Links() { } public Links next(Link next) { - this.next = next; return this; } @@ -73,19 +56,22 @@ public Links next(Link next) { * @return next **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_NEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Link getNext() { return next; } + @JsonProperty(JSON_PROPERTY_NEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setNext(Link next) { this.next = next; } public Links prev(Link prev) { - this.prev = prev; return this; } @@ -95,18 +81,24 @@ public Links prev(Link prev) { * @return prev **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_PREV) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Link getPrev() { return prev; } + @JsonProperty(JSON_PROPERTY_PREV) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPrev(Link prev) { this.prev = prev; } - + /** + * Return true if this Links object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -146,103 +138,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("next"); - openapiFields.add("prev"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(Links.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to Links - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (Links.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in Links is not found in the empty JSON string", Links.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!Links.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `Links` properties.", entry.getKey())); - } - } - // validate the optional field `next` - if (jsonObj.getAsJsonObject("next") != null) { - Link.validateJsonObject(jsonObj.getAsJsonObject("next")); - } - // validate the optional field `prev` - if (jsonObj.getAsJsonObject("prev") != null) { - Link.validateJsonObject(jsonObj.getAsJsonObject("prev")); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Links.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Links' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Links.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Links value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Links read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of Links given an JSON string - * - * @param jsonString JSON string - * @return An instance of Links - * @throws IOException if the JSON string is invalid with respect to Links - */ - public static Links fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Links.class); +/** + * Create an instance of Links given an JSON string + * + * @param jsonString JSON string + * @return An instance of Links + * @throws JsonProcessingException if the JSON string is invalid with respect to Links + */ + public static Links fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Links.class); } - - /** +/** * Convert an instance of Links to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/MerchantData.java b/src/main/java/com/adyen/model/transfers/MerchantData.java index cdd810d0f..8c9c16b8e 100644 --- a/src/main/java/com/adyen/model/transfers/MerchantData.java +++ b/src/main/java/com/adyen/model/transfers/MerchantData.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,64 +14,47 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.NameLocation; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * MerchantData */ +@JsonPropertyOrder({ + MerchantData.JSON_PROPERTY_MCC, + MerchantData.JSON_PROPERTY_MERCHANT_ID, + MerchantData.JSON_PROPERTY_NAME_LOCATION, + MerchantData.JSON_PROPERTY_POSTAL_CODE +}) public class MerchantData { - public static final String SERIALIZED_NAME_MCC = "mcc"; - @SerializedName(SERIALIZED_NAME_MCC) + public static final String JSON_PROPERTY_MCC = "mcc"; private String mcc; - public static final String SERIALIZED_NAME_MERCHANT_ID = "merchantId"; - @SerializedName(SERIALIZED_NAME_MERCHANT_ID) + public static final String JSON_PROPERTY_MERCHANT_ID = "merchantId"; private String merchantId; - public static final String SERIALIZED_NAME_NAME_LOCATION = "nameLocation"; - @SerializedName(SERIALIZED_NAME_NAME_LOCATION) + public static final String JSON_PROPERTY_NAME_LOCATION = "nameLocation"; private NameLocation nameLocation; - public static final String SERIALIZED_NAME_POSTAL_CODE = "postalCode"; - @SerializedName(SERIALIZED_NAME_POSTAL_CODE) + public static final String JSON_PROPERTY_POSTAL_CODE = "postalCode"; private String postalCode; public MerchantData() { } public MerchantData mcc(String mcc) { - this.mcc = mcc; return this; } @@ -81,19 +64,22 @@ public MerchantData mcc(String mcc) { * @return mcc **/ @ApiModelProperty(value = "The merchant category code.") + @JsonProperty(JSON_PROPERTY_MCC) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getMcc() { return mcc; } + @JsonProperty(JSON_PROPERTY_MCC) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setMcc(String mcc) { this.mcc = mcc; } public MerchantData merchantId(String merchantId) { - this.merchantId = merchantId; return this; } @@ -103,19 +89,22 @@ public MerchantData merchantId(String merchantId) { * @return merchantId **/ @ApiModelProperty(value = "The merchant identifier.") + @JsonProperty(JSON_PROPERTY_MERCHANT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getMerchantId() { return merchantId; } + @JsonProperty(JSON_PROPERTY_MERCHANT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setMerchantId(String merchantId) { this.merchantId = merchantId; } public MerchantData nameLocation(NameLocation nameLocation) { - this.nameLocation = nameLocation; return this; } @@ -125,19 +114,22 @@ public MerchantData nameLocation(NameLocation nameLocation) { * @return nameLocation **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_NAME_LOCATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public NameLocation getNameLocation() { return nameLocation; } + @JsonProperty(JSON_PROPERTY_NAME_LOCATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setNameLocation(NameLocation nameLocation) { this.nameLocation = nameLocation; } public MerchantData postalCode(String postalCode) { - this.postalCode = postalCode; return this; } @@ -147,18 +139,24 @@ public MerchantData postalCode(String postalCode) { * @return postalCode **/ @ApiModelProperty(value = "The merchant postal code.") + @JsonProperty(JSON_PROPERTY_POSTAL_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getPostalCode() { return postalCode; } + @JsonProperty(JSON_PROPERTY_POSTAL_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPostalCode(String postalCode) { this.postalCode = postalCode; } - + /** + * Return true if this MerchantData object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -202,113 +200,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("mcc"); - openapiFields.add("merchantId"); - openapiFields.add("nameLocation"); - openapiFields.add("postalCode"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(MerchantData.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to MerchantData - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (MerchantData.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in MerchantData is not found in the empty JSON string", MerchantData.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!MerchantData.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `MerchantData` properties.", entry.getKey())); - } - } - // validate the optional field mcc - if (jsonObj.get("mcc") != null && !jsonObj.get("mcc").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `mcc` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mcc").toString())); - } - // validate the optional field merchantId - if (jsonObj.get("merchantId") != null && !jsonObj.get("merchantId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `merchantId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("merchantId").toString())); - } - // validate the optional field `nameLocation` - if (jsonObj.getAsJsonObject("nameLocation") != null) { - NameLocation.validateJsonObject(jsonObj.getAsJsonObject("nameLocation")); - } - // validate the optional field postalCode - if (jsonObj.get("postalCode") != null && !jsonObj.get("postalCode").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `postalCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("postalCode").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!MerchantData.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'MerchantData' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(MerchantData.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, MerchantData value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public MerchantData read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of MerchantData given an JSON string - * - * @param jsonString JSON string - * @return An instance of MerchantData - * @throws IOException if the JSON string is invalid with respect to MerchantData - */ - public static MerchantData fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, MerchantData.class); +/** + * Create an instance of MerchantData given an JSON string + * + * @param jsonString JSON string + * @return An instance of MerchantData + * @throws JsonProcessingException if the JSON string is invalid with respect to MerchantData + */ + public static MerchantData fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, MerchantData.class); } - - /** +/** * Convert an instance of MerchantData to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/NOLocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/NOLocalAccountIdentification.java index 3544e9869..a119d1816 100644 --- a/src/main/java/com/adyen/model/transfers/NOLocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/NOLocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,50 +14,34 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * NOLocalAccountIdentification */ +@JsonPropertyOrder({ + NOLocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + NOLocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class NOLocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; /** * **noLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { NOLOCAL("noLocal"); @@ -67,6 +51,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -76,6 +61,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -84,30 +70,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.NOLOCAL; public NOLocalAccountIdentification() { } public NOLocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -117,19 +88,22 @@ public NOLocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The 11-digit bank account number, without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public NOLocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -139,18 +113,24 @@ public NOLocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**noLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this NOLocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -190,115 +170,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(NOLocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to NOLocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (NOLocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in NOLocalAccountIdentification is not found in the empty JSON string", NOLocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!NOLocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `NOLocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : NOLocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!NOLocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'NOLocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(NOLocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, NOLocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public NOLocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of NOLocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of NOLocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to NOLocalAccountIdentification - */ - public static NOLocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, NOLocalAccountIdentification.class); +/** + * Create an instance of NOLocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of NOLocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to NOLocalAccountIdentification + */ + public static NOLocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, NOLocalAccountIdentification.class); } - - /** +/** * Convert an instance of NOLocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/NameLocation.java b/src/main/java/com/adyen/model/transfers/NameLocation.java index 516f29da2..555af3c60 100644 --- a/src/main/java/com/adyen/model/transfers/NameLocation.java +++ b/src/main/java/com/adyen/model/transfers/NameLocation.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,71 +14,54 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * NameLocation */ +@JsonPropertyOrder({ + NameLocation.JSON_PROPERTY_CITY, + NameLocation.JSON_PROPERTY_COUNTRY, + NameLocation.JSON_PROPERTY_COUNTRY_OF_ORIGIN, + NameLocation.JSON_PROPERTY_NAME, + NameLocation.JSON_PROPERTY_RAW_DATA, + NameLocation.JSON_PROPERTY_STATE +}) public class NameLocation { - public static final String SERIALIZED_NAME_CITY = "city"; - @SerializedName(SERIALIZED_NAME_CITY) + public static final String JSON_PROPERTY_CITY = "city"; private String city; - public static final String SERIALIZED_NAME_COUNTRY = "country"; - @SerializedName(SERIALIZED_NAME_COUNTRY) + public static final String JSON_PROPERTY_COUNTRY = "country"; private String country; - public static final String SERIALIZED_NAME_COUNTRY_OF_ORIGIN = "countryOfOrigin"; - @SerializedName(SERIALIZED_NAME_COUNTRY_OF_ORIGIN) + public static final String JSON_PROPERTY_COUNTRY_OF_ORIGIN = "countryOfOrigin"; private String countryOfOrigin; - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) + public static final String JSON_PROPERTY_NAME = "name"; private String name; - public static final String SERIALIZED_NAME_RAW_DATA = "rawData"; - @SerializedName(SERIALIZED_NAME_RAW_DATA) + public static final String JSON_PROPERTY_RAW_DATA = "rawData"; private String rawData; - public static final String SERIALIZED_NAME_STATE = "state"; - @SerializedName(SERIALIZED_NAME_STATE) + public static final String JSON_PROPERTY_STATE = "state"; private String state; public NameLocation() { } public NameLocation city(String city) { - this.city = city; return this; } @@ -88,19 +71,22 @@ public NameLocation city(String city) { * @return city **/ @ApiModelProperty(value = "The city where the merchant is located.") + @JsonProperty(JSON_PROPERTY_CITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getCity() { return city; } + @JsonProperty(JSON_PROPERTY_CITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCity(String city) { this.city = city; } public NameLocation country(String country) { - this.country = country; return this; } @@ -110,19 +96,22 @@ public NameLocation country(String country) { * @return country **/ @ApiModelProperty(value = "The country where the merchant is located in [three-letter country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) format.") + @JsonProperty(JSON_PROPERTY_COUNTRY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getCountry() { return country; } + @JsonProperty(JSON_PROPERTY_COUNTRY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCountry(String country) { this.country = country; } public NameLocation countryOfOrigin(String countryOfOrigin) { - this.countryOfOrigin = countryOfOrigin; return this; } @@ -132,19 +121,22 @@ public NameLocation countryOfOrigin(String countryOfOrigin) { * @return countryOfOrigin **/ @ApiModelProperty(value = "The home country in [three-digit country code](https://en.wikipedia.org/wiki/ISO_3166-1_numeric) format, used for government-controlled merchants such as embassies.") + @JsonProperty(JSON_PROPERTY_COUNTRY_OF_ORIGIN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getCountryOfOrigin() { return countryOfOrigin; } + @JsonProperty(JSON_PROPERTY_COUNTRY_OF_ORIGIN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCountryOfOrigin(String countryOfOrigin) { this.countryOfOrigin = countryOfOrigin; } public NameLocation name(String name) { - this.name = name; return this; } @@ -154,19 +146,22 @@ public NameLocation name(String name) { * @return name **/ @ApiModelProperty(value = "The name of the merchant's shop or service.") + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getName() { return name; } + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setName(String name) { this.name = name; } public NameLocation rawData(String rawData) { - this.rawData = rawData; return this; } @@ -176,19 +171,22 @@ public NameLocation rawData(String rawData) { * @return rawData **/ @ApiModelProperty(value = "The raw data.") + @JsonProperty(JSON_PROPERTY_RAW_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getRawData() { return rawData; } + @JsonProperty(JSON_PROPERTY_RAW_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setRawData(String rawData) { this.rawData = rawData; } public NameLocation state(String state) { - this.state = state; return this; } @@ -198,18 +196,24 @@ public NameLocation state(String state) { * @return state **/ @ApiModelProperty(value = "The state where the merchant is located.") + @JsonProperty(JSON_PROPERTY_STATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getState() { return state; } + @JsonProperty(JSON_PROPERTY_STATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setState(String state) { this.state = state; } - + /** + * Return true if this NameLocation object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -257,123 +261,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("city"); - openapiFields.add("country"); - openapiFields.add("countryOfOrigin"); - openapiFields.add("name"); - openapiFields.add("rawData"); - openapiFields.add("state"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(NameLocation.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to NameLocation - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (NameLocation.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in NameLocation is not found in the empty JSON string", NameLocation.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!NameLocation.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `NameLocation` properties.", entry.getKey())); - } - } - // validate the optional field city - if (jsonObj.get("city") != null && !jsonObj.get("city").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `city` to be a primitive type in the JSON string but got `%s`", jsonObj.get("city").toString())); - } - // validate the optional field country - if (jsonObj.get("country") != null && !jsonObj.get("country").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `country` to be a primitive type in the JSON string but got `%s`", jsonObj.get("country").toString())); - } - // validate the optional field countryOfOrigin - if (jsonObj.get("countryOfOrigin") != null && !jsonObj.get("countryOfOrigin").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `countryOfOrigin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("countryOfOrigin").toString())); - } - // validate the optional field name - if (jsonObj.get("name") != null && !jsonObj.get("name").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); - } - // validate the optional field rawData - if (jsonObj.get("rawData") != null && !jsonObj.get("rawData").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `rawData` to be a primitive type in the JSON string but got `%s`", jsonObj.get("rawData").toString())); - } - // validate the optional field state - if (jsonObj.get("state") != null && !jsonObj.get("state").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `state` to be a primitive type in the JSON string but got `%s`", jsonObj.get("state").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!NameLocation.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'NameLocation' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(NameLocation.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, NameLocation value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public NameLocation read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of NameLocation given an JSON string - * - * @param jsonString JSON string - * @return An instance of NameLocation - * @throws IOException if the JSON string is invalid with respect to NameLocation - */ - public static NameLocation fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, NameLocation.class); +/** + * Create an instance of NameLocation given an JSON string + * + * @param jsonString JSON string + * @return An instance of NameLocation + * @throws JsonProcessingException if the JSON string is invalid with respect to NameLocation + */ + public static NameLocation fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, NameLocation.class); } - - /** +/** * Convert an instance of NameLocation to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/NumberAndBicAccountIdentification.java b/src/main/java/com/adyen/model/transfers/NumberAndBicAccountIdentification.java index e55e6170d..bb1a0e776 100644 --- a/src/main/java/com/adyen/model/transfers/NumberAndBicAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/NumberAndBicAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,59 +14,43 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.AdditionalBankIdentification; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * NumberAndBicAccountIdentification */ +@JsonPropertyOrder({ + NumberAndBicAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + NumberAndBicAccountIdentification.JSON_PROPERTY_ADDITIONAL_BANK_IDENTIFICATION, + NumberAndBicAccountIdentification.JSON_PROPERTY_BIC, + NumberAndBicAccountIdentification.JSON_PROPERTY_TYPE +}) public class NumberAndBicAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; - public static final String SERIALIZED_NAME_ADDITIONAL_BANK_IDENTIFICATION = "additionalBankIdentification"; - @SerializedName(SERIALIZED_NAME_ADDITIONAL_BANK_IDENTIFICATION) + public static final String JSON_PROPERTY_ADDITIONAL_BANK_IDENTIFICATION = "additionalBankIdentification"; private AdditionalBankIdentification additionalBankIdentification; - public static final String SERIALIZED_NAME_BIC = "bic"; - @SerializedName(SERIALIZED_NAME_BIC) + public static final String JSON_PROPERTY_BIC = "bic"; private String bic; /** * **numberAndBic** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { NUMBERANDBIC("numberAndBic"); @@ -76,6 +60,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -85,6 +70,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -93,30 +79,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.NUMBERANDBIC; public NumberAndBicAccountIdentification() { } public NumberAndBicAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -126,19 +97,22 @@ public NumberAndBicAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The bank account number, without separators or whitespace. The length and format depends on the bank or country.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public NumberAndBicAccountIdentification additionalBankIdentification(AdditionalBankIdentification additionalBankIdentification) { - this.additionalBankIdentification = additionalBankIdentification; return this; } @@ -148,19 +122,22 @@ public NumberAndBicAccountIdentification additionalBankIdentification(Additional * @return additionalBankIdentification **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_ADDITIONAL_BANK_IDENTIFICATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public AdditionalBankIdentification getAdditionalBankIdentification() { return additionalBankIdentification; } + @JsonProperty(JSON_PROPERTY_ADDITIONAL_BANK_IDENTIFICATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAdditionalBankIdentification(AdditionalBankIdentification additionalBankIdentification) { this.additionalBankIdentification = additionalBankIdentification; } public NumberAndBicAccountIdentification bic(String bic) { - this.bic = bic; return this; } @@ -170,19 +147,22 @@ public NumberAndBicAccountIdentification bic(String bic) { * @return bic **/ @ApiModelProperty(required = true, value = "The bank's 8- or 11-character BIC or SWIFT code.") + @JsonProperty(JSON_PROPERTY_BIC) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBic() { return bic; } + @JsonProperty(JSON_PROPERTY_BIC) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBic(String bic) { this.bic = bic; } public NumberAndBicAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -192,18 +172,24 @@ public NumberAndBicAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**numberAndBic**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this NumberAndBicAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -247,126 +233,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("additionalBankIdentification"); - openapiFields.add("bic"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("bic"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(NumberAndBicAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to NumberAndBicAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (NumberAndBicAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in NumberAndBicAccountIdentification is not found in the empty JSON string", NumberAndBicAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!NumberAndBicAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `NumberAndBicAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : NumberAndBicAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // validate the optional field `additionalBankIdentification` - if (jsonObj.getAsJsonObject("additionalBankIdentification") != null) { - AdditionalBankIdentification.validateJsonObject(jsonObj.getAsJsonObject("additionalBankIdentification")); - } - // validate the optional field bic - if (jsonObj.get("bic") != null && !jsonObj.get("bic").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `bic` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bic").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!NumberAndBicAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'NumberAndBicAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(NumberAndBicAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, NumberAndBicAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public NumberAndBicAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of NumberAndBicAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of NumberAndBicAccountIdentification - * @throws IOException if the JSON string is invalid with respect to NumberAndBicAccountIdentification - */ - public static NumberAndBicAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, NumberAndBicAccountIdentification.class); +/** + * Create an instance of NumberAndBicAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of NumberAndBicAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to NumberAndBicAccountIdentification + */ + public static NumberAndBicAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, NumberAndBicAccountIdentification.class); } - - /** +/** * Convert an instance of NumberAndBicAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/PLLocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/PLLocalAccountIdentification.java index e7234c3b3..163b31ef5 100644 --- a/src/main/java/com/adyen/model/transfers/PLLocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/PLLocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,50 +14,34 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * PLLocalAccountIdentification */ +@JsonPropertyOrder({ + PLLocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + PLLocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class PLLocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; /** * **plLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { PLLOCAL("plLocal"); @@ -67,6 +51,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -76,6 +61,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -84,30 +70,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.PLLOCAL; public PLLocalAccountIdentification() { } public PLLocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -117,19 +88,22 @@ public PLLocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The 26-digit bank account number ([Numer rachunku](https://pl.wikipedia.org/wiki/Numer_Rachunku_Bankowego)), without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public PLLocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -139,18 +113,24 @@ public PLLocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**plLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this PLLocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -190,115 +170,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(PLLocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to PLLocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (PLLocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in PLLocalAccountIdentification is not found in the empty JSON string", PLLocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!PLLocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `PLLocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : PLLocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!PLLocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'PLLocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(PLLocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, PLLocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public PLLocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of PLLocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of PLLocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to PLLocalAccountIdentification - */ - public static PLLocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, PLLocalAccountIdentification.class); +/** + * Create an instance of PLLocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of PLLocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to PLLocalAccountIdentification + */ + public static PLLocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, PLLocalAccountIdentification.class); } - - /** +/** * Convert an instance of PLLocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/PartyIdentification2.java b/src/main/java/com/adyen/model/transfers/PartyIdentification2.java index d121b8ca0..96ea59aa3 100644 --- a/src/main/java/com/adyen/model/transfers/PartyIdentification2.java +++ b/src/main/java/com/adyen/model/transfers/PartyIdentification2.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,72 +14,57 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.Address2; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; import java.time.LocalDate; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.adyen.model.transfers.JSON; /** * PartyIdentification2 */ +@JsonPropertyOrder({ + PartyIdentification2.JSON_PROPERTY_ADDRESS, + PartyIdentification2.JSON_PROPERTY_DATE_OF_BIRTH, + PartyIdentification2.JSON_PROPERTY_FIRST_NAME, + PartyIdentification2.JSON_PROPERTY_FULL_NAME, + PartyIdentification2.JSON_PROPERTY_LAST_NAME, + PartyIdentification2.JSON_PROPERTY_REFERENCE, + PartyIdentification2.JSON_PROPERTY_TYPE +}) +@JsonTypeName("PartyIdentification-2") public class PartyIdentification2 { - public static final String SERIALIZED_NAME_ADDRESS = "address"; - @SerializedName(SERIALIZED_NAME_ADDRESS) + public static final String JSON_PROPERTY_ADDRESS = "address"; private Address2 address; - public static final String SERIALIZED_NAME_DATE_OF_BIRTH = "dateOfBirth"; - @SerializedName(SERIALIZED_NAME_DATE_OF_BIRTH) + public static final String JSON_PROPERTY_DATE_OF_BIRTH = "dateOfBirth"; private LocalDate dateOfBirth; - public static final String SERIALIZED_NAME_FIRST_NAME = "firstName"; - @SerializedName(SERIALIZED_NAME_FIRST_NAME) + public static final String JSON_PROPERTY_FIRST_NAME = "firstName"; private String firstName; - public static final String SERIALIZED_NAME_FULL_NAME = "fullName"; - @SerializedName(SERIALIZED_NAME_FULL_NAME) + public static final String JSON_PROPERTY_FULL_NAME = "fullName"; private String fullName; - public static final String SERIALIZED_NAME_LAST_NAME = "lastName"; - @SerializedName(SERIALIZED_NAME_LAST_NAME) + public static final String JSON_PROPERTY_LAST_NAME = "lastName"; private String lastName; - public static final String SERIALIZED_NAME_REFERENCE = "reference"; - @SerializedName(SERIALIZED_NAME_REFERENCE) + public static final String JSON_PROPERTY_REFERENCE = "reference"; private String reference; /** * The type of entity that owns the bank account. Possible values: **individual**, **organization**, or **unknown**. */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { INDIVIDUAL("individual"), @@ -93,6 +78,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -102,6 +88,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -110,30 +97,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.UNKNOWN; public PartyIdentification2() { } public PartyIdentification2 address(Address2 address) { - this.address = address; return this; } @@ -143,41 +115,47 @@ public PartyIdentification2 address(Address2 address) { * @return address **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_ADDRESS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Address2 getAddress() { return address; } + @JsonProperty(JSON_PROPERTY_ADDRESS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAddress(Address2 address) { this.address = address; } public PartyIdentification2 dateOfBirth(LocalDate dateOfBirth) { - this.dateOfBirth = dateOfBirth; return this; } /** - * The date of birth of the individual in [ISO-8601](https://www.w3.org/TR/NOTE-datetime) format. For example, **YYYY-MM-DD**. Allowed only when `type` is **individual**. + * The date of birth of the individual in [ISO-8601](https://www.w3.org/TR/NOTE-datetime) format. For example, **YYYY-MM-DD**. Should not be before 1st January 1900. Allowed only when `type` is **individual**. * @return dateOfBirth **/ - @ApiModelProperty(value = "The date of birth of the individual in [ISO-8601](https://www.w3.org/TR/NOTE-datetime) format. For example, **YYYY-MM-DD**. Allowed only when `type` is **individual**.") + @ApiModelProperty(value = "The date of birth of the individual in [ISO-8601](https://www.w3.org/TR/NOTE-datetime) format. For example, **YYYY-MM-DD**. Should not be before 1st January 1900. Allowed only when `type` is **individual**.") + @JsonProperty(JSON_PROPERTY_DATE_OF_BIRTH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public LocalDate getDateOfBirth() { return dateOfBirth; } + @JsonProperty(JSON_PROPERTY_DATE_OF_BIRTH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDateOfBirth(LocalDate dateOfBirth) { this.dateOfBirth = dateOfBirth; } public PartyIdentification2 firstName(String firstName) { - this.firstName = firstName; return this; } @@ -187,19 +165,22 @@ public PartyIdentification2 firstName(String firstName) { * @return firstName **/ @ApiModelProperty(value = "First name of the individual. Allowed only when `type` is **individual**.") + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getFirstName() { return firstName; } + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setFirstName(String firstName) { this.firstName = firstName; } public PartyIdentification2 fullName(String fullName) { - this.fullName = fullName; return this; } @@ -209,19 +190,22 @@ public PartyIdentification2 fullName(String fullName) { * @return fullName **/ @ApiModelProperty(required = true, value = "The name of the entity.") + @JsonProperty(JSON_PROPERTY_FULL_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getFullName() { return fullName; } + @JsonProperty(JSON_PROPERTY_FULL_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setFullName(String fullName) { this.fullName = fullName; } public PartyIdentification2 lastName(String lastName) { - this.lastName = lastName; return this; } @@ -231,19 +215,22 @@ public PartyIdentification2 lastName(String lastName) { * @return lastName **/ @ApiModelProperty(value = "Last name of the individual. Allowed only when `type` is **individual**.") + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getLastName() { return lastName; } + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setLastName(String lastName) { this.lastName = lastName; } public PartyIdentification2 reference(String reference) { - this.reference = reference; return this; } @@ -253,19 +240,22 @@ public PartyIdentification2 reference(String reference) { * @return reference **/ @ApiModelProperty(value = "Your unique reference of the party. This should be consistent for all transfers initiated to/from the same party/counterparty. e.g Your client's unique wallet or payee ID") + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getReference() { return reference; } + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReference(String reference) { this.reference = reference; } public PartyIdentification2 type(TypeEnum type) { - this.type = type; return this; } @@ -275,18 +265,24 @@ public PartyIdentification2 type(TypeEnum type) { * @return type **/ @ApiModelProperty(value = "The type of entity that owns the bank account. Possible values: **individual**, **organization**, or **unknown**.") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this PartyIdentification-2 object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -336,135 +332,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("address"); - openapiFields.add("dateOfBirth"); - openapiFields.add("firstName"); - openapiFields.add("fullName"); - openapiFields.add("lastName"); - openapiFields.add("reference"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("fullName"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(PartyIdentification2.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to PartyIdentification2 - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (PartyIdentification2.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in PartyIdentification2 is not found in the empty JSON string", PartyIdentification2.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!PartyIdentification2.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `PartyIdentification2` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : PartyIdentification2.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field `address` - if (jsonObj.getAsJsonObject("address") != null) { - Address2.validateJsonObject(jsonObj.getAsJsonObject("address")); - } - // validate the optional field firstName - if (jsonObj.get("firstName") != null && !jsonObj.get("firstName").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `firstName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("firstName").toString())); - } - // validate the optional field fullName - if (jsonObj.get("fullName") != null && !jsonObj.get("fullName").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `fullName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("fullName").toString())); - } - // validate the optional field lastName - if (jsonObj.get("lastName") != null && !jsonObj.get("lastName").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `lastName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lastName").toString())); - } - // validate the optional field reference - if (jsonObj.get("reference") != null && !jsonObj.get("reference").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!PartyIdentification2.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'PartyIdentification2' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(PartyIdentification2.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, PartyIdentification2 value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public PartyIdentification2 read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of PartyIdentification2 given an JSON string - * - * @param jsonString JSON string - * @return An instance of PartyIdentification2 - * @throws IOException if the JSON string is invalid with respect to PartyIdentification2 - */ - public static PartyIdentification2 fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, PartyIdentification2.class); +/** + * Create an instance of PartyIdentification2 given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartyIdentification2 + * @throws JsonProcessingException if the JSON string is invalid with respect to PartyIdentification2 + */ + public static PartyIdentification2 fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, PartyIdentification2.class); } - - /** +/** * Convert an instance of PartyIdentification2 to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/PaymentInstrument.java b/src/main/java/com/adyen/model/transfers/PaymentInstrument.java index 65f400c39..6301d626a 100644 --- a/src/main/java/com/adyen/model/transfers/PaymentInstrument.java +++ b/src/main/java/com/adyen/model/transfers/PaymentInstrument.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,63 +14,46 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * PaymentInstrument */ +@JsonPropertyOrder({ + PaymentInstrument.JSON_PROPERTY_DESCRIPTION, + PaymentInstrument.JSON_PROPERTY_ID, + PaymentInstrument.JSON_PROPERTY_REFERENCE, + PaymentInstrument.JSON_PROPERTY_TOKEN_TYPE +}) public class PaymentInstrument { - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - @SerializedName(SERIALIZED_NAME_DESCRIPTION) + public static final String JSON_PROPERTY_DESCRIPTION = "description"; private String description; - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) + public static final String JSON_PROPERTY_ID = "id"; private String id; - public static final String SERIALIZED_NAME_REFERENCE = "reference"; - @SerializedName(SERIALIZED_NAME_REFERENCE) + public static final String JSON_PROPERTY_REFERENCE = "reference"; private String reference; - public static final String SERIALIZED_NAME_TOKEN_TYPE = "tokenType"; - @SerializedName(SERIALIZED_NAME_TOKEN_TYPE) + public static final String JSON_PROPERTY_TOKEN_TYPE = "tokenType"; private String tokenType; public PaymentInstrument() { } public PaymentInstrument description(String description) { - this.description = description; return this; } @@ -80,19 +63,22 @@ public PaymentInstrument description(String description) { * @return description **/ @ApiModelProperty(value = "The description of the resource.") + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getDescription() { return description; } + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDescription(String description) { this.description = description; } public PaymentInstrument id(String id) { - this.id = id; return this; } @@ -102,19 +88,22 @@ public PaymentInstrument id(String id) { * @return id **/ @ApiModelProperty(value = "The unique identifier of the resource.") + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(String id) { this.id = id; } public PaymentInstrument reference(String reference) { - this.reference = reference; return this; } @@ -124,19 +113,22 @@ public PaymentInstrument reference(String reference) { * @return reference **/ @ApiModelProperty(value = "The reference for the resource.") + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getReference() { return reference; } + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReference(String reference) { this.reference = reference; } public PaymentInstrument tokenType(String tokenType) { - this.tokenType = tokenType; return this; } @@ -146,18 +138,24 @@ public PaymentInstrument tokenType(String tokenType) { * @return tokenType **/ @ApiModelProperty(value = "The type of wallet the network token is associated with.") + @JsonProperty(JSON_PROPERTY_TOKEN_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getTokenType() { return tokenType; } + @JsonProperty(JSON_PROPERTY_TOKEN_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTokenType(String tokenType) { this.tokenType = tokenType; } - + /** + * Return true if this PaymentInstrument object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -201,113 +199,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("description"); - openapiFields.add("id"); - openapiFields.add("reference"); - openapiFields.add("tokenType"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(PaymentInstrument.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to PaymentInstrument - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (PaymentInstrument.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in PaymentInstrument is not found in the empty JSON string", PaymentInstrument.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!PaymentInstrument.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `PaymentInstrument` properties.", entry.getKey())); - } - } - // validate the optional field description - if (jsonObj.get("description") != null && !jsonObj.get("description").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); - } - // validate the optional field id - if (jsonObj.get("id") != null && !jsonObj.get("id").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - // validate the optional field reference - if (jsonObj.get("reference") != null && !jsonObj.get("reference").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); - } - // validate the optional field tokenType - if (jsonObj.get("tokenType") != null && !jsonObj.get("tokenType").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `tokenType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tokenType").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!PaymentInstrument.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'PaymentInstrument' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(PaymentInstrument.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, PaymentInstrument value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public PaymentInstrument read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of PaymentInstrument given an JSON string - * - * @param jsonString JSON string - * @return An instance of PaymentInstrument - * @throws IOException if the JSON string is invalid with respect to PaymentInstrument - */ - public static PaymentInstrument fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, PaymentInstrument.class); +/** + * Create an instance of PaymentInstrument given an JSON string + * + * @param jsonString JSON string + * @return An instance of PaymentInstrument + * @throws JsonProcessingException if the JSON string is invalid with respect to PaymentInstrument + */ + public static PaymentInstrument fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, PaymentInstrument.class); } - - /** +/** * Convert an instance of PaymentInstrument to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/Repayment.java b/src/main/java/com/adyen/model/transfers/Repayment.java new file mode 100644 index 000000000..07b6dbd1e --- /dev/null +++ b/src/main/java/com/adyen/model/transfers/Repayment.java @@ -0,0 +1,192 @@ +/* + * Transfers API + * + * The version of the OpenAPI document: 3 + * + * + * 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.transfers; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.adyen.model.transfers.RepaymentTerm; +import com.adyen.model.transfers.ThresholdRepayment; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * Repayment + */ +@JsonPropertyOrder({ + Repayment.JSON_PROPERTY_BASIS_POINTS, + Repayment.JSON_PROPERTY_TERM, + Repayment.JSON_PROPERTY_THRESHOLD +}) + +public class Repayment { + public static final String JSON_PROPERTY_BASIS_POINTS = "basisPoints"; + private Integer basisPoints; + + public static final String JSON_PROPERTY_TERM = "term"; + private RepaymentTerm term; + + public static final String JSON_PROPERTY_THRESHOLD = "threshold"; + private ThresholdRepayment threshold; + + public Repayment() { + } + + public Repayment basisPoints(Integer basisPoints) { + this.basisPoints = basisPoints; + return this; + } + + /** + * The repayment that is deducted daily from incoming net volume, in [basis points](https://www.investopedia.com/terms/b/basispoint.asp). + * @return basisPoints + **/ + @ApiModelProperty(required = true, value = "The repayment that is deducted daily from incoming net volume, in [basis points](https://www.investopedia.com/terms/b/basispoint.asp).") + @JsonProperty(JSON_PROPERTY_BASIS_POINTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Integer getBasisPoints() { + return basisPoints; + } + + + @JsonProperty(JSON_PROPERTY_BASIS_POINTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBasisPoints(Integer basisPoints) { + this.basisPoints = basisPoints; + } + + + public Repayment term(RepaymentTerm term) { + this.term = term; + return this; + } + + /** + * Get term + * @return term + **/ + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_TERM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public RepaymentTerm getTerm() { + return term; + } + + + @JsonProperty(JSON_PROPERTY_TERM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTerm(RepaymentTerm term) { + this.term = term; + } + + + public Repayment threshold(ThresholdRepayment threshold) { + this.threshold = threshold; + return this; + } + + /** + * Get threshold + * @return threshold + **/ + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_THRESHOLD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public ThresholdRepayment getThreshold() { + return threshold; + } + + + @JsonProperty(JSON_PROPERTY_THRESHOLD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setThreshold(ThresholdRepayment threshold) { + this.threshold = threshold; + } + + + /** + * Return true if this Repayment object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Repayment repayment = (Repayment) o; + return Objects.equals(this.basisPoints, repayment.basisPoints) && + Objects.equals(this.term, repayment.term) && + Objects.equals(this.threshold, repayment.threshold); + } + + @Override + public int hashCode() { + return Objects.hash(basisPoints, term, threshold); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Repayment {\n"); + sb.append(" basisPoints: ").append(toIndentedString(basisPoints)).append("\n"); + sb.append(" term: ").append(toIndentedString(term)).append("\n"); + sb.append(" threshold: ").append(toIndentedString(threshold)).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 Repayment given an JSON string + * + * @param jsonString JSON string + * @return An instance of Repayment + * @throws JsonProcessingException if the JSON string is invalid with respect to Repayment + */ + public static Repayment fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Repayment.class); + } +/** + * Convert an instance of Repayment 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/transfers/RepaymentTerm.java b/src/main/java/com/adyen/model/transfers/RepaymentTerm.java new file mode 100644 index 000000000..c3f8102a5 --- /dev/null +++ b/src/main/java/com/adyen/model/transfers/RepaymentTerm.java @@ -0,0 +1,159 @@ +/* + * Transfers API + * + * The version of the OpenAPI document: 3 + * + * + * 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.transfers; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * RepaymentTerm + */ +@JsonPropertyOrder({ + RepaymentTerm.JSON_PROPERTY_ESTIMATED_DAYS, + RepaymentTerm.JSON_PROPERTY_MAXIMUM_DAYS +}) + +public class RepaymentTerm { + public static final String JSON_PROPERTY_ESTIMATED_DAYS = "estimatedDays"; + private Integer estimatedDays; + + public static final String JSON_PROPERTY_MAXIMUM_DAYS = "maximumDays"; + private Integer maximumDays; + + public RepaymentTerm() { + } + + public RepaymentTerm estimatedDays(Integer estimatedDays) { + this.estimatedDays = estimatedDays; + return this; + } + + /** + * The estimated term for repaying the grant, in days. + * @return estimatedDays + **/ + @ApiModelProperty(required = true, value = "The estimated term for repaying the grant, in days.") + @JsonProperty(JSON_PROPERTY_ESTIMATED_DAYS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Integer getEstimatedDays() { + return estimatedDays; + } + + + @JsonProperty(JSON_PROPERTY_ESTIMATED_DAYS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEstimatedDays(Integer estimatedDays) { + this.estimatedDays = estimatedDays; + } + + + public RepaymentTerm maximumDays(Integer maximumDays) { + this.maximumDays = maximumDays; + return this; + } + + /** + * The maximum term for repaying the grant, in days. Only applies when `contractType` is **loan**. + * @return maximumDays + **/ + @ApiModelProperty(value = "The maximum term for repaying the grant, in days. Only applies when `contractType` is **loan**.") + @JsonProperty(JSON_PROPERTY_MAXIMUM_DAYS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Integer getMaximumDays() { + return maximumDays; + } + + + @JsonProperty(JSON_PROPERTY_MAXIMUM_DAYS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMaximumDays(Integer maximumDays) { + this.maximumDays = maximumDays; + } + + + /** + * Return true if this RepaymentTerm object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RepaymentTerm repaymentTerm = (RepaymentTerm) o; + return Objects.equals(this.estimatedDays, repaymentTerm.estimatedDays) && + Objects.equals(this.maximumDays, repaymentTerm.maximumDays); + } + + @Override + public int hashCode() { + return Objects.hash(estimatedDays, maximumDays); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RepaymentTerm {\n"); + sb.append(" estimatedDays: ").append(toIndentedString(estimatedDays)).append("\n"); + sb.append(" maximumDays: ").append(toIndentedString(maximumDays)).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 RepaymentTerm given an JSON string + * + * @param jsonString JSON string + * @return An instance of RepaymentTerm + * @throws JsonProcessingException if the JSON string is invalid with respect to RepaymentTerm + */ + public static RepaymentTerm fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, RepaymentTerm.class); + } +/** + * Convert an instance of RepaymentTerm 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/transfers/ResourceReference.java b/src/main/java/com/adyen/model/transfers/ResourceReference.java index b78fa8b0d..9566e4531 100644 --- a/src/main/java/com/adyen/model/transfers/ResourceReference.java +++ b/src/main/java/com/adyen/model/transfers/ResourceReference.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,59 +14,42 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * ResourceReference */ +@JsonPropertyOrder({ + ResourceReference.JSON_PROPERTY_DESCRIPTION, + ResourceReference.JSON_PROPERTY_ID, + ResourceReference.JSON_PROPERTY_REFERENCE +}) public class ResourceReference { - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - @SerializedName(SERIALIZED_NAME_DESCRIPTION) + public static final String JSON_PROPERTY_DESCRIPTION = "description"; private String description; - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) + public static final String JSON_PROPERTY_ID = "id"; private String id; - public static final String SERIALIZED_NAME_REFERENCE = "reference"; - @SerializedName(SERIALIZED_NAME_REFERENCE) + public static final String JSON_PROPERTY_REFERENCE = "reference"; private String reference; public ResourceReference() { } public ResourceReference description(String description) { - this.description = description; return this; } @@ -76,19 +59,22 @@ public ResourceReference description(String description) { * @return description **/ @ApiModelProperty(value = "The description of the resource.") + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getDescription() { return description; } + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDescription(String description) { this.description = description; } public ResourceReference id(String id) { - this.id = id; return this; } @@ -98,19 +84,22 @@ public ResourceReference id(String id) { * @return id **/ @ApiModelProperty(value = "The unique identifier of the resource.") + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(String id) { this.id = id; } public ResourceReference reference(String reference) { - this.reference = reference; return this; } @@ -120,18 +109,24 @@ public ResourceReference reference(String reference) { * @return reference **/ @ApiModelProperty(value = "The reference for the resource.") + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getReference() { return reference; } + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReference(String reference) { this.reference = reference; } - + /** + * Return true if this ResourceReference object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -173,108 +168,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("description"); - openapiFields.add("id"); - openapiFields.add("reference"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(ResourceReference.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to ResourceReference - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (ResourceReference.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in ResourceReference is not found in the empty JSON string", ResourceReference.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!ResourceReference.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `ResourceReference` properties.", entry.getKey())); - } - } - // validate the optional field description - if (jsonObj.get("description") != null && !jsonObj.get("description").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); - } - // validate the optional field id - if (jsonObj.get("id") != null && !jsonObj.get("id").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - // validate the optional field reference - if (jsonObj.get("reference") != null && !jsonObj.get("reference").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!ResourceReference.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ResourceReference' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ResourceReference.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, ResourceReference value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public ResourceReference read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of ResourceReference given an JSON string - * - * @param jsonString JSON string - * @return An instance of ResourceReference - * @throws IOException if the JSON string is invalid with respect to ResourceReference - */ - public static ResourceReference fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ResourceReference.class); +/** + * Create an instance of ResourceReference given an JSON string + * + * @param jsonString JSON string + * @return An instance of ResourceReference + * @throws JsonProcessingException if the JSON string is invalid with respect to ResourceReference + */ + public static ResourceReference fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, ResourceReference.class); } - - /** +/** * Convert an instance of ResourceReference to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/RestServiceError.java b/src/main/java/com/adyen/model/transfers/RestServiceError.java index f59ec90c8..921184209 100644 --- a/src/main/java/com/adyen/model/transfers/RestServiceError.java +++ b/src/main/java/com/adyen/model/transfers/RestServiceError.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,87 +14,70 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.InvalidField; import com.adyen.model.transfers.JSONObject; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.adyen.model.transfers.JSON; /** * RestServiceError */ +@JsonPropertyOrder({ + RestServiceError.JSON_PROPERTY_DETAIL, + RestServiceError.JSON_PROPERTY_ERROR_CODE, + RestServiceError.JSON_PROPERTY_INSTANCE, + RestServiceError.JSON_PROPERTY_INVALID_FIELDS, + RestServiceError.JSON_PROPERTY_REQUEST_ID, + RestServiceError.JSON_PROPERTY_RESPONSE, + RestServiceError.JSON_PROPERTY_STATUS, + RestServiceError.JSON_PROPERTY_TITLE, + RestServiceError.JSON_PROPERTY_TYPE +}) public class RestServiceError { - public static final String SERIALIZED_NAME_DETAIL = "detail"; - @SerializedName(SERIALIZED_NAME_DETAIL) + public static final String JSON_PROPERTY_DETAIL = "detail"; private String detail; - public static final String SERIALIZED_NAME_ERROR_CODE = "errorCode"; - @SerializedName(SERIALIZED_NAME_ERROR_CODE) + public static final String JSON_PROPERTY_ERROR_CODE = "errorCode"; private String errorCode; - public static final String SERIALIZED_NAME_INSTANCE = "instance"; - @SerializedName(SERIALIZED_NAME_INSTANCE) + public static final String JSON_PROPERTY_INSTANCE = "instance"; private String instance; - public static final String SERIALIZED_NAME_INVALID_FIELDS = "invalidFields"; - @SerializedName(SERIALIZED_NAME_INVALID_FIELDS) + public static final String JSON_PROPERTY_INVALID_FIELDS = "invalidFields"; private List invalidFields = null; - public static final String SERIALIZED_NAME_REQUEST_ID = "requestId"; - @SerializedName(SERIALIZED_NAME_REQUEST_ID) + public static final String JSON_PROPERTY_REQUEST_ID = "requestId"; private String requestId; - public static final String SERIALIZED_NAME_RESPONSE = "response"; - @SerializedName(SERIALIZED_NAME_RESPONSE) + public static final String JSON_PROPERTY_RESPONSE = "response"; private JSONObject response; - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) + public static final String JSON_PROPERTY_STATUS = "status"; private Integer status; - public static final String SERIALIZED_NAME_TITLE = "title"; - @SerializedName(SERIALIZED_NAME_TITLE) + public static final String JSON_PROPERTY_TITLE = "title"; private String title; - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private String type; public RestServiceError() { } public RestServiceError detail(String detail) { - this.detail = detail; return this; } @@ -104,19 +87,22 @@ public RestServiceError detail(String detail) { * @return detail **/ @ApiModelProperty(required = true, value = "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; } + @JsonProperty(JSON_PROPERTY_DETAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDetail(String detail) { this.detail = detail; } public RestServiceError errorCode(String errorCode) { - this.errorCode = errorCode; return this; } @@ -126,19 +112,22 @@ public RestServiceError errorCode(String errorCode) { * @return errorCode **/ @ApiModelProperty(required = true, value = "A code that identifies the problem type.") + @JsonProperty(JSON_PROPERTY_ERROR_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getErrorCode() { return errorCode; } + @JsonProperty(JSON_PROPERTY_ERROR_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setErrorCode(String errorCode) { this.errorCode = errorCode; } public RestServiceError instance(String instance) { - this.instance = instance; return this; } @@ -148,19 +137,22 @@ public RestServiceError instance(String instance) { * @return instance **/ @ApiModelProperty(value = "A unique URI that identifies the specific occurrence of the problem.") + @JsonProperty(JSON_PROPERTY_INSTANCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getInstance() { return instance; } + @JsonProperty(JSON_PROPERTY_INSTANCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setInstance(String instance) { this.instance = instance; } public RestServiceError invalidFields(List invalidFields) { - this.invalidFields = invalidFields; return this; } @@ -178,19 +170,22 @@ public RestServiceError addInvalidFieldsItem(InvalidField invalidFieldsItem) { * @return invalidFields **/ @ApiModelProperty(value = "Detailed explanation of each validation error, when applicable.") + @JsonProperty(JSON_PROPERTY_INVALID_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getInvalidFields() { return invalidFields; } + @JsonProperty(JSON_PROPERTY_INVALID_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setInvalidFields(List invalidFields) { this.invalidFields = invalidFields; } public RestServiceError requestId(String requestId) { - this.requestId = requestId; return this; } @@ -200,19 +195,22 @@ public RestServiceError requestId(String requestId) { * @return requestId **/ @ApiModelProperty(value = "A unique reference for the request, essentially the same as `pspReference`.") + @JsonProperty(JSON_PROPERTY_REQUEST_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getRequestId() { return requestId; } + @JsonProperty(JSON_PROPERTY_REQUEST_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setRequestId(String requestId) { this.requestId = requestId; } public RestServiceError response(JSONObject response) { - this.response = response; return this; } @@ -222,19 +220,22 @@ public RestServiceError response(JSONObject response) { * @return response **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_RESPONSE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public JSONObject getResponse() { return response; } + @JsonProperty(JSON_PROPERTY_RESPONSE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setResponse(JSONObject response) { this.response = response; } public RestServiceError status(Integer status) { - this.status = status; return this; } @@ -244,19 +245,22 @@ public RestServiceError status(Integer status) { * @return status **/ @ApiModelProperty(required = true, value = "The HTTP status code.") + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Integer getStatus() { return status; } + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setStatus(Integer status) { this.status = status; } public RestServiceError title(String title) { - this.title = title; return this; } @@ -266,19 +270,22 @@ public RestServiceError title(String title) { * @return title **/ @ApiModelProperty(required = true, value = "A short, human-readable summary of the problem type.") + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getTitle() { return title; } + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTitle(String title) { this.title = title; } public RestServiceError type(String type) { - this.type = type; return this; } @@ -288,18 +295,24 @@ public RestServiceError type(String type) { * @return type **/ @ApiModelProperty(required = true, value = "A URI that identifies the problem type, pointing to human-readable documentation on this problem type.") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(String type) { this.type = type; } - + /** + * Return true if this RestServiceError object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -353,154 +366,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("detail"); - openapiFields.add("errorCode"); - openapiFields.add("instance"); - openapiFields.add("invalidFields"); - openapiFields.add("requestId"); - openapiFields.add("response"); - openapiFields.add("status"); - openapiFields.add("title"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("detail"); - openapiRequiredFields.add("errorCode"); - openapiRequiredFields.add("status"); - openapiRequiredFields.add("title"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(RestServiceError.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to RestServiceError - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (RestServiceError.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in RestServiceError is not found in the empty JSON string", RestServiceError.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!RestServiceError.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `RestServiceError` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : RestServiceError.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field detail - if (jsonObj.get("detail") != null && !jsonObj.get("detail").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `detail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("detail").toString())); - } - // validate the optional field errorCode - if (jsonObj.get("errorCode") != null && !jsonObj.get("errorCode").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `errorCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("errorCode").toString())); - } - // validate the optional field instance - if (jsonObj.get("instance") != null && !jsonObj.get("instance").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `instance` to be a primitive type in the JSON string but got `%s`", jsonObj.get("instance").toString())); - } - JsonArray jsonArrayinvalidFields = jsonObj.getAsJsonArray("invalidFields"); - if (jsonArrayinvalidFields != null) { - // ensure the json data is an array - if (!jsonObj.get("invalidFields").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `invalidFields` to be an array in the JSON string but got `%s`", jsonObj.get("invalidFields").toString())); - } - - // validate the optional field `invalidFields` (array) - for (int i = 0; i < jsonArrayinvalidFields.size(); i++) { - InvalidField.validateJsonObject(jsonArrayinvalidFields.get(i).getAsJsonObject()); - } - } - // validate the optional field requestId - if (jsonObj.get("requestId") != null && !jsonObj.get("requestId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `requestId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("requestId").toString())); - } - // validate the optional field `response` - if (jsonObj.getAsJsonObject("response") != null) { - JSONObject.validateJsonObject(jsonObj.getAsJsonObject("response")); - } - // validate the optional field title - if (jsonObj.get("title") != null && !jsonObj.get("title").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); - } - // validate the optional field type - if (jsonObj.get("type") != null && !jsonObj.get("type").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!RestServiceError.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'RestServiceError' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(RestServiceError.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, RestServiceError value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public RestServiceError read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of RestServiceError given an JSON string - * - * @param jsonString JSON string - * @return An instance of RestServiceError - * @throws IOException if the JSON string is invalid with respect to RestServiceError - */ - public static RestServiceError fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, RestServiceError.class); +/** + * Create an instance of RestServiceError given an JSON string + * + * @param jsonString JSON string + * @return An instance of RestServiceError + * @throws JsonProcessingException if the JSON string is invalid with respect to RestServiceError + */ + public static RestServiceError fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, RestServiceError.class); } - - /** +/** * Convert an instance of RestServiceError to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/SELocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/SELocalAccountIdentification.java index d0ddc230f..cb1057c74 100644 --- a/src/main/java/com/adyen/model/transfers/SELocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/SELocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,54 +14,38 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * SELocalAccountIdentification */ +@JsonPropertyOrder({ + SELocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + SELocalAccountIdentification.JSON_PROPERTY_CLEARING_NUMBER, + SELocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class SELocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; - public static final String SERIALIZED_NAME_CLEARING_NUMBER = "clearingNumber"; - @SerializedName(SERIALIZED_NAME_CLEARING_NUMBER) + public static final String JSON_PROPERTY_CLEARING_NUMBER = "clearingNumber"; private String clearingNumber; /** * **seLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { SELOCAL("seLocal"); @@ -71,6 +55,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -80,6 +65,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -88,30 +74,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.SELOCAL; public SELocalAccountIdentification() { } public SELocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -121,19 +92,22 @@ public SELocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The 7- to 10-digit bank account number ([Bankkontonummer](https://sv.wikipedia.org/wiki/Bankkonto)), without the clearing number, separators, or whitespace.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public SELocalAccountIdentification clearingNumber(String clearingNumber) { - this.clearingNumber = clearingNumber; return this; } @@ -143,19 +117,22 @@ public SELocalAccountIdentification clearingNumber(String clearingNumber) { * @return clearingNumber **/ @ApiModelProperty(required = true, value = "The 4- to 5-digit clearing number ([Clearingnummer](https://sv.wikipedia.org/wiki/Clearingnummer)), without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_CLEARING_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getClearingNumber() { return clearingNumber; } + @JsonProperty(JSON_PROPERTY_CLEARING_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setClearingNumber(String clearingNumber) { this.clearingNumber = clearingNumber; } public SELocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -165,18 +142,24 @@ public SELocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**seLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this SELocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -218,121 +201,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("clearingNumber"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("clearingNumber"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(SELocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to SELocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (SELocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in SELocalAccountIdentification is not found in the empty JSON string", SELocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!SELocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `SELocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : SELocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // validate the optional field clearingNumber - if (jsonObj.get("clearingNumber") != null && !jsonObj.get("clearingNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `clearingNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clearingNumber").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!SELocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SELocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SELocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, SELocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public SELocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of SELocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of SELocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to SELocalAccountIdentification - */ - public static SELocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SELocalAccountIdentification.class); +/** + * Create an instance of SELocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of SELocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to SELocalAccountIdentification + */ + public static SELocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, SELocalAccountIdentification.class); } - - /** +/** * Convert an instance of SELocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/SGLocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/SGLocalAccountIdentification.java index 1ede3b65b..8ba1d88a5 100644 --- a/src/main/java/com/adyen/model/transfers/SGLocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/SGLocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,54 +14,38 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * SGLocalAccountIdentification */ +@JsonPropertyOrder({ + SGLocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + SGLocalAccountIdentification.JSON_PROPERTY_BIC, + SGLocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class SGLocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; - public static final String SERIALIZED_NAME_BIC = "bic"; - @SerializedName(SERIALIZED_NAME_BIC) + public static final String JSON_PROPERTY_BIC = "bic"; private String bic; /** * **sgLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { SGLOCAL("sgLocal"); @@ -71,6 +55,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -80,6 +65,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -88,30 +74,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.SGLOCAL; public SGLocalAccountIdentification() { } public SGLocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -121,19 +92,22 @@ public SGLocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The 4- to 19-digit bank account number, without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public SGLocalAccountIdentification bic(String bic) { - this.bic = bic; return this; } @@ -143,19 +117,22 @@ public SGLocalAccountIdentification bic(String bic) { * @return bic **/ @ApiModelProperty(required = true, value = "The bank's 8- or 11-character BIC or SWIFT code.") + @JsonProperty(JSON_PROPERTY_BIC) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBic() { return bic; } + @JsonProperty(JSON_PROPERTY_BIC) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBic(String bic) { this.bic = bic; } public SGLocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -165,18 +142,24 @@ public SGLocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(value = "**sgLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this SGLocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -218,120 +201,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("bic"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("bic"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(SGLocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to SGLocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (SGLocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in SGLocalAccountIdentification is not found in the empty JSON string", SGLocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!SGLocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `SGLocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : SGLocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // validate the optional field bic - if (jsonObj.get("bic") != null && !jsonObj.get("bic").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `bic` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bic").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!SGLocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SGLocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SGLocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, SGLocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public SGLocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of SGLocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of SGLocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to SGLocalAccountIdentification - */ - public static SGLocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SGLocalAccountIdentification.class); +/** + * Create an instance of SGLocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of SGLocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to SGLocalAccountIdentification + */ + public static SGLocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, SGLocalAccountIdentification.class); } - - /** +/** * Convert an instance of SGLocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/ThresholdRepayment.java b/src/main/java/com/adyen/model/transfers/ThresholdRepayment.java new file mode 100644 index 000000000..36aa8b334 --- /dev/null +++ b/src/main/java/com/adyen/model/transfers/ThresholdRepayment.java @@ -0,0 +1,129 @@ +/* + * Transfers API + * + * The version of the OpenAPI document: 3 + * + * + * 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.transfers; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.adyen.model.transfers.Amount; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * ThresholdRepayment + */ +@JsonPropertyOrder({ + ThresholdRepayment.JSON_PROPERTY_AMOUNT +}) + +public class ThresholdRepayment { + public static final String JSON_PROPERTY_AMOUNT = "amount"; + private Amount amount; + + public ThresholdRepayment() { + } + + public ThresholdRepayment amount(Amount amount) { + this.amount = amount; + return this; + } + + /** + * Get amount + * @return amount + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Amount getAmount() { + return amount; + } + + + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAmount(Amount amount) { + this.amount = amount; + } + + + /** + * Return true if this ThresholdRepayment object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ThresholdRepayment thresholdRepayment = (ThresholdRepayment) o; + return Objects.equals(this.amount, thresholdRepayment.amount); + } + + @Override + public int hashCode() { + return Objects.hash(amount); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ThresholdRepayment {\n"); + sb.append(" amount: ").append(toIndentedString(amount)).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 ThresholdRepayment given an JSON string + * + * @param jsonString JSON string + * @return An instance of ThresholdRepayment + * @throws JsonProcessingException if the JSON string is invalid with respect to ThresholdRepayment + */ + public static ThresholdRepayment fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, ThresholdRepayment.class); + } +/** + * Convert an instance of ThresholdRepayment 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/transfers/Transaction.java b/src/main/java/com/adyen/model/transfers/Transaction.java index ea0167d7c..e21046660 100644 --- a/src/main/java/com/adyen/model/transfers/Transaction.java +++ b/src/main/java/com/adyen/model/transfers/Transaction.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,78 +14,78 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.Amount; import com.adyen.model.transfers.CounterpartyV3; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.adyen.model.transfers.JSON; /** * Transaction */ +@JsonPropertyOrder({ + Transaction.JSON_PROPERTY_ACCOUNT_HOLDER_ID, + Transaction.JSON_PROPERTY_AMOUNT, + Transaction.JSON_PROPERTY_BALANCE_ACCOUNT_ID, + Transaction.JSON_PROPERTY_BALANCE_PLATFORM, + Transaction.JSON_PROPERTY_BOOKING_DATE, + Transaction.JSON_PROPERTY_CATEGORY, + Transaction.JSON_PROPERTY_COUNTERPARTY, + Transaction.JSON_PROPERTY_CREATED_AT, + Transaction.JSON_PROPERTY_DESCRIPTION, + Transaction.JSON_PROPERTY_ID, + Transaction.JSON_PROPERTY_INSTRUCTED_AMOUNT, + Transaction.JSON_PROPERTY_PAYMENT_INSTRUMENT_ID, + Transaction.JSON_PROPERTY_REFERENCE, + Transaction.JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY, + Transaction.JSON_PROPERTY_STATUS, + Transaction.JSON_PROPERTY_TRANSFER_ID, + Transaction.JSON_PROPERTY_TYPE, + Transaction.JSON_PROPERTY_VALUE_DATE +}) public class Transaction { - public static final String SERIALIZED_NAME_ACCOUNT_HOLDER_ID = "accountHolderId"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_HOLDER_ID) + public static final String JSON_PROPERTY_ACCOUNT_HOLDER_ID = "accountHolderId"; private String accountHolderId; - public static final String SERIALIZED_NAME_AMOUNT = "amount"; - @SerializedName(SERIALIZED_NAME_AMOUNT) + public static final String JSON_PROPERTY_AMOUNT = "amount"; private Amount amount; - public static final String SERIALIZED_NAME_BALANCE_ACCOUNT_ID = "balanceAccountId"; - @SerializedName(SERIALIZED_NAME_BALANCE_ACCOUNT_ID) + public static final String JSON_PROPERTY_BALANCE_ACCOUNT_ID = "balanceAccountId"; private String balanceAccountId; - public static final String SERIALIZED_NAME_BALANCE_PLATFORM = "balancePlatform"; - @SerializedName(SERIALIZED_NAME_BALANCE_PLATFORM) + public static final String JSON_PROPERTY_BALANCE_PLATFORM = "balancePlatform"; private String balancePlatform; - public static final String SERIALIZED_NAME_BOOKING_DATE = "bookingDate"; - @SerializedName(SERIALIZED_NAME_BOOKING_DATE) + public static final String JSON_PROPERTY_BOOKING_DATE = "bookingDate"; private OffsetDateTime bookingDate; /** * The category of the transaction indicating the type of activity. Possible values: * **platformPayment**: The transaction is a payment or payment modification made with an Adyen merchant account. * **internal**: The transaction resulted from an internal adjustment such as a deposit correction or invoice deduction. * **bank**: The transaction is a bank-related activity, such as sending a payout or receiving funds. * **issuedCard**: The transaction is a card-related activity, such as using an Adyen-issued card to pay online. */ - @JsonAdapter(CategoryEnum.Adapter.class) public enum CategoryEnum { BANK("bank"), + CARD("card"), + GRANTS("grants"), INTERNAL("internal"), ISSUEDCARD("issuedCard"), + MIGRATION("migration"), + PLATFORMPAYMENT("platformPayment"); private String value; @@ -94,6 +94,7 @@ public enum CategoryEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -103,6 +104,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static CategoryEnum fromValue(String value) { for (CategoryEnum b : CategoryEnum.values()) { if (b.value.equals(value)) { @@ -111,61 +113,38 @@ public static CategoryEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public CategoryEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return CategoryEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_CATEGORY = "category"; - @SerializedName(SERIALIZED_NAME_CATEGORY) + public static final String JSON_PROPERTY_CATEGORY = "category"; private CategoryEnum category; - public static final String SERIALIZED_NAME_COUNTERPARTY = "counterparty"; - @SerializedName(SERIALIZED_NAME_COUNTERPARTY) + public static final String JSON_PROPERTY_COUNTERPARTY = "counterparty"; private CounterpartyV3 counterparty; - public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; - @SerializedName(SERIALIZED_NAME_CREATED_AT) + public static final String JSON_PROPERTY_CREATED_AT = "createdAt"; private OffsetDateTime createdAt; - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - @SerializedName(SERIALIZED_NAME_DESCRIPTION) + public static final String JSON_PROPERTY_DESCRIPTION = "description"; private String description; - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) + public static final String JSON_PROPERTY_ID = "id"; private String id; - public static final String SERIALIZED_NAME_INSTRUCTED_AMOUNT = "instructedAmount"; - @SerializedName(SERIALIZED_NAME_INSTRUCTED_AMOUNT) + public static final String JSON_PROPERTY_INSTRUCTED_AMOUNT = "instructedAmount"; private Amount instructedAmount; - public static final String SERIALIZED_NAME_PAYMENT_INSTRUMENT_ID = "paymentInstrumentId"; - @SerializedName(SERIALIZED_NAME_PAYMENT_INSTRUMENT_ID) + public static final String JSON_PROPERTY_PAYMENT_INSTRUMENT_ID = "paymentInstrumentId"; private String paymentInstrumentId; - public static final String SERIALIZED_NAME_REFERENCE = "reference"; - @SerializedName(SERIALIZED_NAME_REFERENCE) + public static final String JSON_PROPERTY_REFERENCE = "reference"; private String reference; - public static final String SERIALIZED_NAME_REFERENCE_FOR_BENEFICIARY = "referenceForBeneficiary"; - @SerializedName(SERIALIZED_NAME_REFERENCE_FOR_BENEFICIARY) + public static final String JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY = "referenceForBeneficiary"; private String referenceForBeneficiary; /** * The status of the transaction. Possible values: * **pending**: The transaction is still pending. * **booked**: The transaction has been booked to the balance account. */ - @JsonAdapter(StatusEnum.Adapter.class) public enum StatusEnum { BOOKED("booked"), @@ -177,6 +156,7 @@ public enum StatusEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -186,6 +166,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { @@ -194,33 +175,17 @@ public static StatusEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public StatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return StatusEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) + public static final String JSON_PROPERTY_STATUS = "status"; private StatusEnum status; - public static final String SERIALIZED_NAME_TRANSFER_ID = "transferId"; - @SerializedName(SERIALIZED_NAME_TRANSFER_ID) + public static final String JSON_PROPERTY_TRANSFER_ID = "transferId"; private String transferId; /** * The type of the transaction. Possible values: **payment**, **capture**, **captureReversal**, **refund** **refundReversal**, **chargeback**, **chargebackReversal**, **secondChargeback**, **atmWithdrawal**, **atmWithdrawalReversal**, **internalTransfer**, **manualCorrection**, **invoiceDeduction**, **depositCorrection**, **bankTransfer**, **miscCost**, **paymentCost**, **fee** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { ATMWITHDRAWAL("atmWithdrawal"), @@ -280,6 +245,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -289,6 +255,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -297,34 +264,18 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type; - public static final String SERIALIZED_NAME_VALUE_DATE = "valueDate"; - @SerializedName(SERIALIZED_NAME_VALUE_DATE) + public static final String JSON_PROPERTY_VALUE_DATE = "valueDate"; private OffsetDateTime valueDate; public Transaction() { } public Transaction accountHolderId(String accountHolderId) { - this.accountHolderId = accountHolderId; return this; } @@ -334,19 +285,22 @@ public Transaction accountHolderId(String accountHolderId) { * @return accountHolderId **/ @ApiModelProperty(required = true, value = "Unique identifier of the account holder.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountHolderId() { return accountHolderId; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountHolderId(String accountHolderId) { this.accountHolderId = accountHolderId; } public Transaction amount(Amount amount) { - this.amount = amount; return this; } @@ -356,19 +310,22 @@ public Transaction amount(Amount amount) { * @return amount **/ @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Amount getAmount() { return amount; } + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAmount(Amount amount) { this.amount = amount; } public Transaction balanceAccountId(String balanceAccountId) { - this.balanceAccountId = balanceAccountId; return this; } @@ -378,19 +335,22 @@ public Transaction balanceAccountId(String balanceAccountId) { * @return balanceAccountId **/ @ApiModelProperty(required = true, value = "Unique identifier of the balance account.") + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBalanceAccountId() { return balanceAccountId; } + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalanceAccountId(String balanceAccountId) { this.balanceAccountId = balanceAccountId; } public Transaction balancePlatform(String balancePlatform) { - this.balancePlatform = balancePlatform; return this; } @@ -400,19 +360,22 @@ public Transaction balancePlatform(String balancePlatform) { * @return balancePlatform **/ @ApiModelProperty(required = true, value = "Unique identifier of the balance platform.") + @JsonProperty(JSON_PROPERTY_BALANCE_PLATFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBalancePlatform() { return balancePlatform; } + @JsonProperty(JSON_PROPERTY_BALANCE_PLATFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalancePlatform(String balancePlatform) { this.balancePlatform = balancePlatform; } public Transaction bookingDate(OffsetDateTime bookingDate) { - this.bookingDate = bookingDate; return this; } @@ -422,19 +385,22 @@ public Transaction bookingDate(OffsetDateTime bookingDate) { * @return bookingDate **/ @ApiModelProperty(required = true, value = "The date the transaction was booked to the balance account.") + @JsonProperty(JSON_PROPERTY_BOOKING_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public OffsetDateTime getBookingDate() { return bookingDate; } + @JsonProperty(JSON_PROPERTY_BOOKING_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBookingDate(OffsetDateTime bookingDate) { this.bookingDate = bookingDate; } public Transaction category(CategoryEnum category) { - this.category = category; return this; } @@ -444,19 +410,22 @@ public Transaction category(CategoryEnum category) { * @return category **/ @ApiModelProperty(value = "The category of the transaction indicating the type of activity. Possible values: * **platformPayment**: The transaction is a payment or payment modification made with an Adyen merchant account. * **internal**: The transaction resulted from an internal adjustment such as a deposit correction or invoice deduction. * **bank**: The transaction is a bank-related activity, such as sending a payout or receiving funds. * **issuedCard**: The transaction is a card-related activity, such as using an Adyen-issued card to pay online. ") + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public CategoryEnum getCategory() { return category; } + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCategory(CategoryEnum category) { this.category = category; } public Transaction counterparty(CounterpartyV3 counterparty) { - this.counterparty = counterparty; return this; } @@ -466,19 +435,22 @@ public Transaction counterparty(CounterpartyV3 counterparty) { * @return counterparty **/ @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public CounterpartyV3 getCounterparty() { return counterparty; } + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCounterparty(CounterpartyV3 counterparty) { this.counterparty = counterparty; } public Transaction createdAt(OffsetDateTime createdAt) { - this.createdAt = createdAt; return this; } @@ -488,19 +460,22 @@ public Transaction createdAt(OffsetDateTime createdAt) { * @return createdAt **/ @ApiModelProperty(required = true, value = "The date the transaction was created.") + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public OffsetDateTime getCreatedAt() { return createdAt; } + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreatedAt(OffsetDateTime createdAt) { this.createdAt = createdAt; } public Transaction description(String description) { - this.description = description; return this; } @@ -510,19 +485,22 @@ public Transaction description(String description) { * @return description **/ @ApiModelProperty(value = "The `description` from the `/transfers` request.") + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getDescription() { return description; } + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDescription(String description) { this.description = description; } public Transaction id(String id) { - this.id = id; return this; } @@ -532,19 +510,22 @@ public Transaction id(String id) { * @return id **/ @ApiModelProperty(required = true, value = "Unique identifier of the transaction.") + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(String id) { this.id = id; } public Transaction instructedAmount(Amount instructedAmount) { - this.instructedAmount = instructedAmount; return this; } @@ -554,19 +535,22 @@ public Transaction instructedAmount(Amount instructedAmount) { * @return instructedAmount **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_INSTRUCTED_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Amount getInstructedAmount() { return instructedAmount; } + @JsonProperty(JSON_PROPERTY_INSTRUCTED_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setInstructedAmount(Amount instructedAmount) { this.instructedAmount = instructedAmount; } public Transaction paymentInstrumentId(String paymentInstrumentId) { - this.paymentInstrumentId = paymentInstrumentId; return this; } @@ -576,19 +560,22 @@ public Transaction paymentInstrumentId(String paymentInstrumentId) { * @return paymentInstrumentId **/ @ApiModelProperty(value = "Unique identifier of the payment instrument that was used for the transaction.") + @JsonProperty(JSON_PROPERTY_PAYMENT_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getPaymentInstrumentId() { return paymentInstrumentId; } + @JsonProperty(JSON_PROPERTY_PAYMENT_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPaymentInstrumentId(String paymentInstrumentId) { this.paymentInstrumentId = paymentInstrumentId; } public Transaction reference(String reference) { - this.reference = reference; return this; } @@ -598,19 +585,22 @@ public Transaction reference(String reference) { * @return reference **/ @ApiModelProperty(required = true, value = "The [`reference`](https://docs.adyen.com/api-explorer/#/transfers/latest/post/transfers__reqParam_reference) from the `/transfers` request. If you haven't provided any, Adyen generates a unique reference.") + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getReference() { return reference; } + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReference(String reference) { this.reference = reference; } public Transaction referenceForBeneficiary(String referenceForBeneficiary) { - this.referenceForBeneficiary = referenceForBeneficiary; return this; } @@ -620,19 +610,22 @@ public Transaction referenceForBeneficiary(String referenceForBeneficiary) { * @return referenceForBeneficiary **/ @ApiModelProperty(value = "The reference sent to or received from the counterparty. * For outgoing funds, this is the [`referenceForBeneficiary`](https://docs.adyen.com/api-explorer/#/transfers/latest/post/transfers__resParam_referenceForBeneficiary) from the [`/transfers`](https://docs.adyen.com/api-explorer/#/transfers/latest/post/transfers__reqParam_referenceForBeneficiary) request. * For incoming funds, this is the reference from the sender.") + @JsonProperty(JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getReferenceForBeneficiary() { return referenceForBeneficiary; } + @JsonProperty(JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReferenceForBeneficiary(String referenceForBeneficiary) { this.referenceForBeneficiary = referenceForBeneficiary; } public Transaction status(StatusEnum status) { - this.status = status; return this; } @@ -642,19 +635,22 @@ public Transaction status(StatusEnum status) { * @return status **/ @ApiModelProperty(required = true, value = "The status of the transaction. Possible values: * **pending**: The transaction is still pending. * **booked**: The transaction has been booked to the balance account. ") + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public StatusEnum getStatus() { return status; } + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setStatus(StatusEnum status) { this.status = status; } public Transaction transferId(String transferId) { - this.transferId = transferId; return this; } @@ -664,19 +660,22 @@ public Transaction transferId(String transferId) { * @return transferId **/ @ApiModelProperty(value = "Unique identifier of the related transfer.") + @JsonProperty(JSON_PROPERTY_TRANSFER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getTransferId() { return transferId; } + @JsonProperty(JSON_PROPERTY_TRANSFER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTransferId(String transferId) { this.transferId = transferId; } public Transaction type(TypeEnum type) { - this.type = type; return this; } @@ -686,19 +685,22 @@ public Transaction type(TypeEnum type) { * @return type **/ @ApiModelProperty(value = "The type of the transaction. Possible values: **payment**, **capture**, **captureReversal**, **refund** **refundReversal**, **chargeback**, **chargebackReversal**, **secondChargeback**, **atmWithdrawal**, **atmWithdrawalReversal**, **internalTransfer**, **manualCorrection**, **invoiceDeduction**, **depositCorrection**, **bankTransfer**, **miscCost**, **paymentCost**, **fee**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } public Transaction valueDate(OffsetDateTime valueDate) { - this.valueDate = valueDate; return this; } @@ -708,18 +710,24 @@ public Transaction valueDate(OffsetDateTime valueDate) { * @return valueDate **/ @ApiModelProperty(required = true, value = "The date the transfer amount becomes available in the balance account.") + @JsonProperty(JSON_PROPERTY_VALUE_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public OffsetDateTime getValueDate() { return valueDate; } + @JsonProperty(JSON_PROPERTY_VALUE_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setValueDate(OffsetDateTime valueDate) { this.valueDate = valueDate; } - + /** + * Return true if this Transaction object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -791,198 +799,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountHolderId"); - openapiFields.add("amount"); - openapiFields.add("balanceAccountId"); - openapiFields.add("balancePlatform"); - openapiFields.add("bookingDate"); - openapiFields.add("category"); - openapiFields.add("counterparty"); - openapiFields.add("createdAt"); - openapiFields.add("description"); - openapiFields.add("id"); - openapiFields.add("instructedAmount"); - openapiFields.add("paymentInstrumentId"); - openapiFields.add("reference"); - openapiFields.add("referenceForBeneficiary"); - openapiFields.add("status"); - openapiFields.add("transferId"); - openapiFields.add("type"); - openapiFields.add("valueDate"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountHolderId"); - openapiRequiredFields.add("amount"); - openapiRequiredFields.add("balanceAccountId"); - openapiRequiredFields.add("balancePlatform"); - openapiRequiredFields.add("bookingDate"); - openapiRequiredFields.add("counterparty"); - openapiRequiredFields.add("createdAt"); - openapiRequiredFields.add("id"); - openapiRequiredFields.add("reference"); - openapiRequiredFields.add("status"); - openapiRequiredFields.add("valueDate"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(Transaction.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to Transaction - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (Transaction.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in Transaction is not found in the empty JSON string", Transaction.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!Transaction.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `Transaction` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Transaction.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountHolderId - if (jsonObj.get("accountHolderId") != null && !jsonObj.get("accountHolderId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountHolderId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountHolderId").toString())); - } - // validate the optional field `amount` - if (jsonObj.getAsJsonObject("amount") != null) { - Amount.validateJsonObject(jsonObj.getAsJsonObject("amount")); - } - // validate the optional field balanceAccountId - if (jsonObj.get("balanceAccountId") != null && !jsonObj.get("balanceAccountId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `balanceAccountId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("balanceAccountId").toString())); - } - // validate the optional field balancePlatform - if (jsonObj.get("balancePlatform") != null && !jsonObj.get("balancePlatform").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `balancePlatform` to be a primitive type in the JSON string but got `%s`", jsonObj.get("balancePlatform").toString())); - } - // ensure the field category can be parsed to an enum value - if (jsonObj.get("category") != null) { - if(!jsonObj.get("category").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); - } - CategoryEnum.fromValue(jsonObj.get("category").getAsString()); - } - // validate the optional field `counterparty` - if (jsonObj.getAsJsonObject("counterparty") != null) { - CounterpartyV3.validateJsonObject(jsonObj.getAsJsonObject("counterparty")); - } - // validate the optional field description - if (jsonObj.get("description") != null && !jsonObj.get("description").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); - } - // validate the optional field id - if (jsonObj.get("id") != null && !jsonObj.get("id").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - // validate the optional field `instructedAmount` - if (jsonObj.getAsJsonObject("instructedAmount") != null) { - Amount.validateJsonObject(jsonObj.getAsJsonObject("instructedAmount")); - } - // validate the optional field paymentInstrumentId - if (jsonObj.get("paymentInstrumentId") != null && !jsonObj.get("paymentInstrumentId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `paymentInstrumentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("paymentInstrumentId").toString())); - } - // validate the optional field reference - if (jsonObj.get("reference") != null && !jsonObj.get("reference").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); - } - // validate the optional field referenceForBeneficiary - if (jsonObj.get("referenceForBeneficiary") != null && !jsonObj.get("referenceForBeneficiary").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `referenceForBeneficiary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("referenceForBeneficiary").toString())); - } - // ensure the field status can be parsed to an enum value - if (jsonObj.get("status") != null) { - if(!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); - } - StatusEnum.fromValue(jsonObj.get("status").getAsString()); - } - // validate the optional field transferId - if (jsonObj.get("transferId") != null && !jsonObj.get("transferId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `transferId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transferId").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Transaction.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Transaction' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Transaction.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Transaction value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Transaction read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of Transaction given an JSON string - * - * @param jsonString JSON string - * @return An instance of Transaction - * @throws IOException if the JSON string is invalid with respect to Transaction - */ - public static Transaction fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Transaction.class); +/** + * Create an instance of Transaction given an JSON string + * + * @param jsonString JSON string + * @return An instance of Transaction + * @throws JsonProcessingException if the JSON string is invalid with respect to Transaction + */ + public static Transaction fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Transaction.class); } - - /** +/** * Convert an instance of Transaction to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/TransactionSearchResponse.java b/src/main/java/com/adyen/model/transfers/TransactionSearchResponse.java index b6a73fdbe..8c634311f 100644 --- a/src/main/java/com/adyen/model/transfers/TransactionSearchResponse.java +++ b/src/main/java/com/adyen/model/transfers/TransactionSearchResponse.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,59 +14,42 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.Links; import com.adyen.model.transfers.Transaction; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.adyen.model.transfers.JSON; /** * TransactionSearchResponse */ +@JsonPropertyOrder({ + TransactionSearchResponse.JSON_PROPERTY_LINKS, + TransactionSearchResponse.JSON_PROPERTY_DATA +}) public class TransactionSearchResponse { - public static final String SERIALIZED_NAME_LINKS = "_links"; - @SerializedName(SERIALIZED_NAME_LINKS) + public static final String JSON_PROPERTY_LINKS = "_links"; private Links links; - public static final String SERIALIZED_NAME_DATA = "data"; - @SerializedName(SERIALIZED_NAME_DATA) + public static final String JSON_PROPERTY_DATA = "data"; private List data = null; public TransactionSearchResponse() { } public TransactionSearchResponse links(Links links) { - this.links = links; return this; } @@ -76,19 +59,22 @@ public TransactionSearchResponse links(Links links) { * @return links **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Links getLinks() { return links; } + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setLinks(Links links) { this.links = links; } public TransactionSearchResponse data(List data) { - this.data = data; return this; } @@ -106,18 +92,24 @@ public TransactionSearchResponse addDataItem(Transaction dataItem) { * @return data **/ @ApiModelProperty(value = "Contains the transactions that match the query parameters.") + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getData() { return data; } + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setData(List data) { this.data = data; } - + /** + * Return true if this TransactionSearchResponse object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -157,111 +149,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("_links"); - openapiFields.add("data"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(TransactionSearchResponse.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to TransactionSearchResponse - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (TransactionSearchResponse.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in TransactionSearchResponse is not found in the empty JSON string", TransactionSearchResponse.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!TransactionSearchResponse.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `TransactionSearchResponse` properties.", entry.getKey())); - } - } - // validate the optional field `_links` - if (jsonObj.getAsJsonObject("_links") != null) { - Links.validateJsonObject(jsonObj.getAsJsonObject("_links")); - } - JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); - if (jsonArraydata != null) { - // ensure the json data is an array - if (!jsonObj.get("data").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); - } - - // validate the optional field `data` (array) - for (int i = 0; i < jsonArraydata.size(); i++) { - Transaction.validateJsonObject(jsonArraydata.get(i).getAsJsonObject()); - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!TransactionSearchResponse.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'TransactionSearchResponse' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(TransactionSearchResponse.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, TransactionSearchResponse value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public TransactionSearchResponse read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of TransactionSearchResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of TransactionSearchResponse - * @throws IOException if the JSON string is invalid with respect to TransactionSearchResponse - */ - public static TransactionSearchResponse fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, TransactionSearchResponse.class); +/** + * Create an instance of TransactionSearchResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of TransactionSearchResponse + * @throws JsonProcessingException if the JSON string is invalid with respect to TransactionSearchResponse + */ + public static TransactionSearchResponse fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, TransactionSearchResponse.class); } - - /** +/** * Convert an instance of TransactionSearchResponse to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/Transfer.java b/src/main/java/com/adyen/model/transfers/Transfer.java index 65fc118f9..04f5211f2 100644 --- a/src/main/java/com/adyen/model/transfers/Transfer.java +++ b/src/main/java/com/adyen/model/transfers/Transfer.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,67 +14,63 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.Amount; import com.adyen.model.transfers.CounterpartyV3; import com.adyen.model.transfers.PaymentInstrument; import com.adyen.model.transfers.ResourceReference; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * Transfer */ +@JsonPropertyOrder({ + Transfer.JSON_PROPERTY_ACCOUNT_HOLDER, + Transfer.JSON_PROPERTY_AMOUNT, + Transfer.JSON_PROPERTY_BALANCE_ACCOUNT, + Transfer.JSON_PROPERTY_BALANCE_ACCOUNT_ID, + Transfer.JSON_PROPERTY_CATEGORY, + Transfer.JSON_PROPERTY_COUNTERPARTY, + Transfer.JSON_PROPERTY_CREATION_DATE, + Transfer.JSON_PROPERTY_DESCRIPTION, + Transfer.JSON_PROPERTY_DIRECTION, + Transfer.JSON_PROPERTY_ID, + Transfer.JSON_PROPERTY_PAYMENT_INSTRUMENT, + Transfer.JSON_PROPERTY_PAYMENT_INSTRUMENT_ID, + Transfer.JSON_PROPERTY_PRIORITY, + Transfer.JSON_PROPERTY_REASON, + Transfer.JSON_PROPERTY_REFERENCE, + Transfer.JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY, + Transfer.JSON_PROPERTY_STATUS +}) public class Transfer { - public static final String SERIALIZED_NAME_ACCOUNT_HOLDER = "accountHolder"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_HOLDER) + public static final String JSON_PROPERTY_ACCOUNT_HOLDER = "accountHolder"; private ResourceReference accountHolder; - public static final String SERIALIZED_NAME_AMOUNT = "amount"; - @SerializedName(SERIALIZED_NAME_AMOUNT) + public static final String JSON_PROPERTY_AMOUNT = "amount"; private Amount amount; - public static final String SERIALIZED_NAME_BALANCE_ACCOUNT = "balanceAccount"; - @SerializedName(SERIALIZED_NAME_BALANCE_ACCOUNT) + public static final String JSON_PROPERTY_BALANCE_ACCOUNT = "balanceAccount"; private ResourceReference balanceAccount; - public static final String SERIALIZED_NAME_BALANCE_ACCOUNT_ID = "balanceAccountId"; - @Deprecated - @SerializedName(SERIALIZED_NAME_BALANCE_ACCOUNT_ID) + public static final String JSON_PROPERTY_BALANCE_ACCOUNT_ID = "balanceAccountId"; private String balanceAccountId; /** * The type of transfer. Possible values: - **bank**: Transfer to a [transfer instrument](https://docs.adyen.com/api-explorer/#/legalentity/latest/post/transferInstruments__resParam_id) or a bank account. - **internal**: Transfer to another [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id) within your platform. - **issuedCard**: Transfer initiated by a Adyen-issued card. - **platformPayment**: Fund movements related to payments that are acquired for your users. */ - @JsonAdapter(CategoryEnum.Adapter.class) public enum CategoryEnum { BANK("bank"), @@ -90,6 +86,7 @@ public enum CategoryEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -99,6 +96,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static CategoryEnum fromValue(String value) { for (CategoryEnum b : CategoryEnum.values()) { if (b.value.equals(value)) { @@ -107,37 +105,23 @@ public static CategoryEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public CategoryEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return CategoryEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_CATEGORY = "category"; - @SerializedName(SERIALIZED_NAME_CATEGORY) + public static final String JSON_PROPERTY_CATEGORY = "category"; private CategoryEnum category; - public static final String SERIALIZED_NAME_COUNTERPARTY = "counterparty"; - @SerializedName(SERIALIZED_NAME_COUNTERPARTY) + public static final String JSON_PROPERTY_COUNTERPARTY = "counterparty"; private CounterpartyV3 counterparty; - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - @SerializedName(SERIALIZED_NAME_DESCRIPTION) + public static final String JSON_PROPERTY_CREATION_DATE = "creationDate"; + private OffsetDateTime creationDate; + + public static final String JSON_PROPERTY_DESCRIPTION = "description"; private String description; /** * The direction of the transfer. Possible values: **incoming**, **outgoing**. */ - @JsonAdapter(DirectionEnum.Adapter.class) public enum DirectionEnum { INCOMING("incoming"), @@ -149,6 +133,7 @@ public enum DirectionEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -158,6 +143,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static DirectionEnum fromValue(String value) { for (DirectionEnum b : DirectionEnum.values()) { if (b.value.equals(value)) { @@ -166,42 +152,23 @@ public static DirectionEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final DirectionEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public DirectionEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return DirectionEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_DIRECTION = "direction"; - @SerializedName(SERIALIZED_NAME_DIRECTION) + public static final String JSON_PROPERTY_DIRECTION = "direction"; private DirectionEnum direction; - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) + public static final String JSON_PROPERTY_ID = "id"; private String id; - public static final String SERIALIZED_NAME_PAYMENT_INSTRUMENT = "paymentInstrument"; - @SerializedName(SERIALIZED_NAME_PAYMENT_INSTRUMENT) + public static final String JSON_PROPERTY_PAYMENT_INSTRUMENT = "paymentInstrument"; private PaymentInstrument paymentInstrument; - public static final String SERIALIZED_NAME_PAYMENT_INSTRUMENT_ID = "paymentInstrumentId"; - @Deprecated - @SerializedName(SERIALIZED_NAME_PAYMENT_INSTRUMENT_ID) + public static final String JSON_PROPERTY_PAYMENT_INSTRUMENT_ID = "paymentInstrumentId"; private String paymentInstrumentId; /** * The priority for the bank transfer. This sets the speed at which the transfer is sent and the fees that you have to pay. Required for transfers with `category` **bank**. Possible values: * **regular**: For normal, low-value transactions. * **fast**: Faster way to transfer funds but has higher fees. Recommended for high-priority, low-value transactions. * **wire**: Fastest way to transfer funds but has the highest fees. Recommended for high-priority, high-value transactions. * **instant**: Instant way to transfer funds in [SEPA countries](https://www.ecb.europa.eu/paym/integration/retail/sepa/html/index.en.html). * **crossBorder**: High-value transfer to a recipient in a different country. * **internal**: Transfer to an Adyen-issued business bank account (by bank account number/IBAN). */ - @JsonAdapter(PriorityEnum.Adapter.class) public enum PriorityEnum { CROSSBORDER("crossBorder"), @@ -223,6 +190,7 @@ public enum PriorityEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -232,6 +200,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static PriorityEnum fromValue(String value) { for (PriorityEnum b : PriorityEnum.values()) { if (b.value.equals(value)) { @@ -240,29 +209,14 @@ public static PriorityEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final PriorityEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public PriorityEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return PriorityEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_PRIORITY = "priority"; - @SerializedName(SERIALIZED_NAME_PRIORITY) + public static final String JSON_PROPERTY_PRIORITY = "priority"; private PriorityEnum priority; /** * Additional information about the status of the transfer. */ - @JsonAdapter(ReasonEnum.Adapter.class) public enum ReasonEnum { AMOUNTLIMITEXCEEDED("amountLimitExceeded"), @@ -296,6 +250,7 @@ public enum ReasonEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -305,6 +260,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static ReasonEnum fromValue(String value) { for (ReasonEnum b : ReasonEnum.values()) { if (b.value.equals(value)) { @@ -313,37 +269,20 @@ public static ReasonEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final ReasonEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public ReasonEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return ReasonEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) + public static final String JSON_PROPERTY_REASON = "reason"; private ReasonEnum reason; - public static final String SERIALIZED_NAME_REFERENCE = "reference"; - @SerializedName(SERIALIZED_NAME_REFERENCE) + public static final String JSON_PROPERTY_REFERENCE = "reference"; private String reference; - public static final String SERIALIZED_NAME_REFERENCE_FOR_BENEFICIARY = "referenceForBeneficiary"; - @SerializedName(SERIALIZED_NAME_REFERENCE_FOR_BENEFICIARY) + public static final String JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY = "referenceForBeneficiary"; private String referenceForBeneficiary; /** * The result of the transfer. For example, **authorised**, **refused**, or **error**. */ - @JsonAdapter(StatusEnum.Adapter.class) public enum StatusEnum { APPROVALPENDING("approvalPending"), @@ -379,8 +318,12 @@ public enum StatusEnum { CAPTURED("captured"), + CAPTUREDEXTERNALLY("capturedExternally"), + CHARGEBACK("chargeback"), + CHARGEBACKEXTERNALLY("chargebackExternally"), + CHARGEBACKPENDING("chargebackPending"), CHARGEBACKREVERSALPENDING("chargebackReversalPending"), @@ -453,6 +396,8 @@ public enum StatusEnum { REFUNDED("refunded"), + REFUNDEDEXTERNALLY("refundedExternally"), + REFUSED("refused"), RESERVEADJUSTMENT("reserveAdjustment"), @@ -473,6 +418,7 @@ public enum StatusEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -482,6 +428,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { @@ -490,30 +437,15 @@ public static StatusEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public StatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return StatusEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) + public static final String JSON_PROPERTY_STATUS = "status"; private StatusEnum status; public Transfer() { } public Transfer accountHolder(ResourceReference accountHolder) { - this.accountHolder = accountHolder; return this; } @@ -523,19 +455,22 @@ public Transfer accountHolder(ResourceReference accountHolder) { * @return accountHolder **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public ResourceReference getAccountHolder() { return accountHolder; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountHolder(ResourceReference accountHolder) { this.accountHolder = accountHolder; } public Transfer amount(Amount amount) { - this.amount = amount; return this; } @@ -545,19 +480,22 @@ public Transfer amount(Amount amount) { * @return amount **/ @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Amount getAmount() { return amount; } + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAmount(Amount amount) { this.amount = amount; } public Transfer balanceAccount(ResourceReference balanceAccount) { - this.balanceAccount = balanceAccount; return this; } @@ -567,20 +505,22 @@ public Transfer balanceAccount(ResourceReference balanceAccount) { * @return balanceAccount **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public ResourceReference getBalanceAccount() { return balanceAccount; } + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalanceAccount(ResourceReference balanceAccount) { this.balanceAccount = balanceAccount; } - @Deprecated public Transfer balanceAccountId(String balanceAccountId) { - this.balanceAccountId = balanceAccountId; return this; } @@ -592,6 +532,8 @@ public Transfer balanceAccountId(String balanceAccountId) { **/ @Deprecated @ApiModelProperty(value = "The unique identifier of the source [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id).") + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBalanceAccountId() { return balanceAccountId; @@ -599,13 +541,14 @@ public String getBalanceAccountId() { @Deprecated + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalanceAccountId(String balanceAccountId) { this.balanceAccountId = balanceAccountId; } public Transfer category(CategoryEnum category) { - this.category = category; return this; } @@ -615,19 +558,22 @@ public Transfer category(CategoryEnum category) { * @return category **/ @ApiModelProperty(required = true, value = "The type of transfer. Possible values: - **bank**: Transfer to a [transfer instrument](https://docs.adyen.com/api-explorer/#/legalentity/latest/post/transferInstruments__resParam_id) or a bank account. - **internal**: Transfer to another [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id) within your platform. - **issuedCard**: Transfer initiated by a Adyen-issued card. - **platformPayment**: Fund movements related to payments that are acquired for your users.") + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public CategoryEnum getCategory() { return category; } + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCategory(CategoryEnum category) { this.category = category; } public Transfer counterparty(CounterpartyV3 counterparty) { - this.counterparty = counterparty; return this; } @@ -637,19 +583,47 @@ public Transfer counterparty(CounterpartyV3 counterparty) { * @return counterparty **/ @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public CounterpartyV3 getCounterparty() { return counterparty; } + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCounterparty(CounterpartyV3 counterparty) { this.counterparty = counterparty; } + public Transfer creationDate(OffsetDateTime creationDate) { + this.creationDate = creationDate; + return this; + } + + /** + * The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**. + * @return creationDate + **/ + @ApiModelProperty(value = "The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**.") + @JsonProperty(JSON_PROPERTY_CREATION_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public OffsetDateTime getCreationDate() { + return creationDate; + } + + + @JsonProperty(JSON_PROPERTY_CREATION_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreationDate(OffsetDateTime creationDate) { + this.creationDate = creationDate; + } + + public Transfer description(String description) { - this.description = description; return this; } @@ -659,19 +633,22 @@ public Transfer description(String description) { * @return description **/ @ApiModelProperty(value = "Your description for the transfer. It is used by most banks as the transfer description. We recommend sending a maximum of 140 characters, otherwise the description may be truncated. Supported characters: **[a-z] [A-Z] [0-9] / - ?** **: ( ) . , ' + Space** Supported characters for **regular** and **fast** transfers to a US counterparty: **[a-z] [A-Z] [0-9] & $ % # @** **~ = + - _ ' \" ! ?**") + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getDescription() { return description; } + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDescription(String description) { this.description = description; } public Transfer direction(DirectionEnum direction) { - this.direction = direction; return this; } @@ -681,19 +658,22 @@ public Transfer direction(DirectionEnum direction) { * @return direction **/ @ApiModelProperty(value = "The direction of the transfer. Possible values: **incoming**, **outgoing**.") + @JsonProperty(JSON_PROPERTY_DIRECTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public DirectionEnum getDirection() { return direction; } + @JsonProperty(JSON_PROPERTY_DIRECTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDirection(DirectionEnum direction) { this.direction = direction; } public Transfer id(String id) { - this.id = id; return this; } @@ -703,19 +683,22 @@ public Transfer id(String id) { * @return id **/ @ApiModelProperty(value = "The ID of the resource.") + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(String id) { this.id = id; } public Transfer paymentInstrument(PaymentInstrument paymentInstrument) { - this.paymentInstrument = paymentInstrument; return this; } @@ -725,20 +708,22 @@ public Transfer paymentInstrument(PaymentInstrument paymentInstrument) { * @return paymentInstrument **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_PAYMENT_INSTRUMENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public PaymentInstrument getPaymentInstrument() { return paymentInstrument; } + @JsonProperty(JSON_PROPERTY_PAYMENT_INSTRUMENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPaymentInstrument(PaymentInstrument paymentInstrument) { this.paymentInstrument = paymentInstrument; } - @Deprecated public Transfer paymentInstrumentId(String paymentInstrumentId) { - this.paymentInstrumentId = paymentInstrumentId; return this; } @@ -750,6 +735,8 @@ public Transfer paymentInstrumentId(String paymentInstrumentId) { **/ @Deprecated @ApiModelProperty(value = "The unique identifier of the [payment instrument](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id) used in the transfer.") + @JsonProperty(JSON_PROPERTY_PAYMENT_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getPaymentInstrumentId() { return paymentInstrumentId; @@ -757,13 +744,14 @@ public String getPaymentInstrumentId() { @Deprecated + @JsonProperty(JSON_PROPERTY_PAYMENT_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPaymentInstrumentId(String paymentInstrumentId) { this.paymentInstrumentId = paymentInstrumentId; } public Transfer priority(PriorityEnum priority) { - this.priority = priority; return this; } @@ -773,19 +761,22 @@ public Transfer priority(PriorityEnum priority) { * @return priority **/ @ApiModelProperty(value = "The priority for the bank transfer. This sets the speed at which the transfer is sent and the fees that you have to pay. Required for transfers with `category` **bank**. Possible values: * **regular**: For normal, low-value transactions. * **fast**: Faster way to transfer funds but has higher fees. Recommended for high-priority, low-value transactions. * **wire**: Fastest way to transfer funds but has the highest fees. Recommended for high-priority, high-value transactions. * **instant**: Instant way to transfer funds in [SEPA countries](https://www.ecb.europa.eu/paym/integration/retail/sepa/html/index.en.html). * **crossBorder**: High-value transfer to a recipient in a different country. * **internal**: Transfer to an Adyen-issued business bank account (by bank account number/IBAN).") + @JsonProperty(JSON_PROPERTY_PRIORITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public PriorityEnum getPriority() { return priority; } + @JsonProperty(JSON_PROPERTY_PRIORITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPriority(PriorityEnum priority) { this.priority = priority; } public Transfer reason(ReasonEnum reason) { - this.reason = reason; return this; } @@ -795,19 +786,22 @@ public Transfer reason(ReasonEnum reason) { * @return reason **/ @ApiModelProperty(value = "Additional information about the status of the transfer.") + @JsonProperty(JSON_PROPERTY_REASON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public ReasonEnum getReason() { return reason; } + @JsonProperty(JSON_PROPERTY_REASON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReason(ReasonEnum reason) { this.reason = reason; } public Transfer reference(String reference) { - this.reference = reference; return this; } @@ -817,19 +811,22 @@ public Transfer reference(String reference) { * @return reference **/ @ApiModelProperty(value = "Your reference for the transfer, used internally within your platform. If you don't provide this in the request, Adyen generates a unique reference.") + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getReference() { return reference; } + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReference(String reference) { this.reference = reference; } public Transfer referenceForBeneficiary(String referenceForBeneficiary) { - this.referenceForBeneficiary = referenceForBeneficiary; return this; } @@ -839,19 +836,22 @@ public Transfer referenceForBeneficiary(String referenceForBeneficiary) { * @return referenceForBeneficiary **/ @ApiModelProperty(value = " A reference that is sent to the recipient. This reference is also sent in all webhooks related to the transfer, so you can use it to track statuses for both the source and recipient of funds. Supported characters: **a-z**, **A-Z**, **0-9**. The maximum length depends on the `category`. - **internal**: 80 characters - **bank**: 35 characters when transferring to an IBAN, 15 characters for others.") + @JsonProperty(JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getReferenceForBeneficiary() { return referenceForBeneficiary; } + @JsonProperty(JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReferenceForBeneficiary(String referenceForBeneficiary) { this.referenceForBeneficiary = referenceForBeneficiary; } public Transfer status(StatusEnum status) { - this.status = status; return this; } @@ -861,18 +861,24 @@ public Transfer status(StatusEnum status) { * @return status **/ @ApiModelProperty(required = true, value = "The result of the transfer. For example, **authorised**, **refused**, or **error**.") + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public StatusEnum getStatus() { return status; } + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setStatus(StatusEnum status) { this.status = status; } - + /** + * Return true if this Transfer object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -888,6 +894,7 @@ public boolean equals(Object o) { Objects.equals(this.balanceAccountId, transfer.balanceAccountId) && Objects.equals(this.category, transfer.category) && Objects.equals(this.counterparty, transfer.counterparty) && + Objects.equals(this.creationDate, transfer.creationDate) && Objects.equals(this.description, transfer.description) && Objects.equals(this.direction, transfer.direction) && Objects.equals(this.id, transfer.id) && @@ -902,7 +909,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(accountHolder, amount, balanceAccount, balanceAccountId, category, counterparty, description, direction, id, paymentInstrument, paymentInstrumentId, priority, reason, reference, referenceForBeneficiary, status); + return Objects.hash(accountHolder, amount, balanceAccount, balanceAccountId, category, counterparty, creationDate, description, direction, id, paymentInstrument, paymentInstrumentId, priority, reason, reference, referenceForBeneficiary, status); } @Override @@ -915,6 +922,7 @@ public String toString() { sb.append(" balanceAccountId: ").append(toIndentedString(balanceAccountId)).append("\n"); sb.append(" category: ").append(toIndentedString(category)).append("\n"); sb.append(" counterparty: ").append(toIndentedString(counterparty)).append("\n"); + sb.append(" creationDate: ").append(toIndentedString(creationDate)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" direction: ").append(toIndentedString(direction)).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); @@ -940,199 +948,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountHolder"); - openapiFields.add("amount"); - openapiFields.add("balanceAccount"); - openapiFields.add("balanceAccountId"); - openapiFields.add("category"); - openapiFields.add("counterparty"); - openapiFields.add("description"); - openapiFields.add("direction"); - openapiFields.add("id"); - openapiFields.add("paymentInstrument"); - openapiFields.add("paymentInstrumentId"); - openapiFields.add("priority"); - openapiFields.add("reason"); - openapiFields.add("reference"); - openapiFields.add("referenceForBeneficiary"); - openapiFields.add("status"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("amount"); - openapiRequiredFields.add("category"); - openapiRequiredFields.add("counterparty"); - openapiRequiredFields.add("status"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(Transfer.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to Transfer - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (Transfer.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in Transfer is not found in the empty JSON string", Transfer.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!Transfer.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `Transfer` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Transfer.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field `accountHolder` - if (jsonObj.getAsJsonObject("accountHolder") != null) { - ResourceReference.validateJsonObject(jsonObj.getAsJsonObject("accountHolder")); - } - // validate the optional field `amount` - if (jsonObj.getAsJsonObject("amount") != null) { - Amount.validateJsonObject(jsonObj.getAsJsonObject("amount")); - } - // validate the optional field `balanceAccount` - if (jsonObj.getAsJsonObject("balanceAccount") != null) { - ResourceReference.validateJsonObject(jsonObj.getAsJsonObject("balanceAccount")); - } - // validate the optional field balanceAccountId - if (jsonObj.get("balanceAccountId") != null && !jsonObj.get("balanceAccountId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `balanceAccountId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("balanceAccountId").toString())); - } - // ensure the field category can be parsed to an enum value - if (jsonObj.get("category") != null) { - if(!jsonObj.get("category").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); - } - CategoryEnum.fromValue(jsonObj.get("category").getAsString()); - } - // validate the optional field `counterparty` - if (jsonObj.getAsJsonObject("counterparty") != null) { - CounterpartyV3.validateJsonObject(jsonObj.getAsJsonObject("counterparty")); - } - // validate the optional field description - if (jsonObj.get("description") != null && !jsonObj.get("description").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); - } - // ensure the field direction can be parsed to an enum value - if (jsonObj.get("direction") != null) { - if(!jsonObj.get("direction").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `direction` to be a primitive type in the JSON string but got `%s`", jsonObj.get("direction").toString())); - } - DirectionEnum.fromValue(jsonObj.get("direction").getAsString()); - } - // validate the optional field id - if (jsonObj.get("id") != null && !jsonObj.get("id").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - // validate the optional field `paymentInstrument` - if (jsonObj.getAsJsonObject("paymentInstrument") != null) { - PaymentInstrument.validateJsonObject(jsonObj.getAsJsonObject("paymentInstrument")); - } - // validate the optional field paymentInstrumentId - if (jsonObj.get("paymentInstrumentId") != null && !jsonObj.get("paymentInstrumentId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `paymentInstrumentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("paymentInstrumentId").toString())); - } - // ensure the field priority can be parsed to an enum value - if (jsonObj.get("priority") != null) { - if(!jsonObj.get("priority").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `priority` to be a primitive type in the JSON string but got `%s`", jsonObj.get("priority").toString())); - } - PriorityEnum.fromValue(jsonObj.get("priority").getAsString()); - } - // ensure the field reason can be parsed to an enum value - if (jsonObj.get("reason") != null) { - if(!jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - ReasonEnum.fromValue(jsonObj.get("reason").getAsString()); - } - // validate the optional field reference - if (jsonObj.get("reference") != null && !jsonObj.get("reference").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); - } - // validate the optional field referenceForBeneficiary - if (jsonObj.get("referenceForBeneficiary") != null && !jsonObj.get("referenceForBeneficiary").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `referenceForBeneficiary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("referenceForBeneficiary").toString())); - } - // ensure the field status can be parsed to an enum value - if (jsonObj.get("status") != null) { - if(!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); - } - StatusEnum.fromValue(jsonObj.get("status").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Transfer.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Transfer' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Transfer.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Transfer value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Transfer read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of Transfer given an JSON string - * - * @param jsonString JSON string - * @return An instance of Transfer - * @throws IOException if the JSON string is invalid with respect to Transfer - */ - public static Transfer fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Transfer.class); +/** + * Create an instance of Transfer given an JSON string + * + * @param jsonString JSON string + * @return An instance of Transfer + * @throws JsonProcessingException if the JSON string is invalid with respect to Transfer + */ + public static Transfer fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Transfer.class); } - - /** +/** * Convert an instance of Transfer to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/TransferInfo.java b/src/main/java/com/adyen/model/transfers/TransferInfo.java index be88b036d..231eea349 100644 --- a/src/main/java/com/adyen/model/transfers/TransferInfo.java +++ b/src/main/java/com/adyen/model/transfers/TransferInfo.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,57 +14,49 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.Amount; import com.adyen.model.transfers.CounterpartyInfoV3; import com.adyen.model.transfers.UltimatePartyIdentification; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * TransferInfo */ +@JsonPropertyOrder({ + TransferInfo.JSON_PROPERTY_AMOUNT, + TransferInfo.JSON_PROPERTY_BALANCE_ACCOUNT_ID, + TransferInfo.JSON_PROPERTY_CATEGORY, + TransferInfo.JSON_PROPERTY_COUNTERPARTY, + TransferInfo.JSON_PROPERTY_DESCRIPTION, + TransferInfo.JSON_PROPERTY_ID, + TransferInfo.JSON_PROPERTY_PAYMENT_INSTRUMENT_ID, + TransferInfo.JSON_PROPERTY_PRIORITY, + TransferInfo.JSON_PROPERTY_REFERENCE, + TransferInfo.JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY, + TransferInfo.JSON_PROPERTY_ULTIMATE_PARTY +}) public class TransferInfo { - public static final String SERIALIZED_NAME_AMOUNT = "amount"; - @SerializedName(SERIALIZED_NAME_AMOUNT) + public static final String JSON_PROPERTY_AMOUNT = "amount"; private Amount amount; - public static final String SERIALIZED_NAME_BALANCE_ACCOUNT_ID = "balanceAccountId"; - @SerializedName(SERIALIZED_NAME_BALANCE_ACCOUNT_ID) + public static final String JSON_PROPERTY_BALANCE_ACCOUNT_ID = "balanceAccountId"; private String balanceAccountId; /** * The type of transfer. Possible values: - **bank**: Transfer to a [transfer instrument](https://docs.adyen.com/api-explorer/#/legalentity/latest/post/transferInstruments__resParam_id) or a bank account. - **internal**: Transfer to another [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id) within your platform. - **issuedCard**: Transfer initiated by a Adyen-issued card. - **platformPayment**: Fund movements related to payments that are acquired for your users. */ - @JsonAdapter(CategoryEnum.Adapter.class) public enum CategoryEnum { BANK("bank"), @@ -72,7 +64,9 @@ public enum CategoryEnum { ISSUEDCARD("issuedCard"), - PLATFORMPAYMENT("platformPayment"); + PLATFORMPAYMENT("platformPayment"), + + CARD("card"); private String value; @@ -80,6 +74,7 @@ public enum CategoryEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -89,6 +84,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static CategoryEnum fromValue(String value) { for (CategoryEnum b : CategoryEnum.values()) { if (b.value.equals(value)) { @@ -97,45 +93,26 @@ public static CategoryEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final CategoryEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public CategoryEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return CategoryEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_CATEGORY = "category"; - @SerializedName(SERIALIZED_NAME_CATEGORY) + public static final String JSON_PROPERTY_CATEGORY = "category"; private CategoryEnum category; - public static final String SERIALIZED_NAME_COUNTERPARTY = "counterparty"; - @SerializedName(SERIALIZED_NAME_COUNTERPARTY) + public static final String JSON_PROPERTY_COUNTERPARTY = "counterparty"; private CounterpartyInfoV3 counterparty; - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - @SerializedName(SERIALIZED_NAME_DESCRIPTION) + public static final String JSON_PROPERTY_DESCRIPTION = "description"; private String description; - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) + public static final String JSON_PROPERTY_ID = "id"; private String id; - public static final String SERIALIZED_NAME_PAYMENT_INSTRUMENT_ID = "paymentInstrumentId"; - @SerializedName(SERIALIZED_NAME_PAYMENT_INSTRUMENT_ID) + public static final String JSON_PROPERTY_PAYMENT_INSTRUMENT_ID = "paymentInstrumentId"; private String paymentInstrumentId; /** * The priority for the bank transfer. This sets the speed at which the transfer is sent and the fees that you have to pay. Required for transfers with `category` **bank**. Possible values: * **regular**: For normal, low-value transactions. * **fast**: Faster way to transfer funds but has higher fees. Recommended for high-priority, low-value transactions. * **wire**: Fastest way to transfer funds but has the highest fees. Recommended for high-priority, high-value transactions. * **instant**: Instant way to transfer funds in [SEPA countries](https://www.ecb.europa.eu/paym/integration/retail/sepa/html/index.en.html). * **crossBorder**: High-value transfer to a recipient in a different country. * **internal**: Transfer to an Adyen-issued business bank account (by bank account number/IBAN). */ - @JsonAdapter(PriorityEnum.Adapter.class) public enum PriorityEnum { CROSSBORDER("crossBorder"), @@ -157,6 +134,7 @@ public enum PriorityEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -166,6 +144,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static PriorityEnum fromValue(String value) { for (PriorityEnum b : PriorityEnum.values()) { if (b.value.equals(value)) { @@ -174,42 +153,24 @@ public static PriorityEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final PriorityEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public PriorityEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return PriorityEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_PRIORITY = "priority"; - @SerializedName(SERIALIZED_NAME_PRIORITY) + public static final String JSON_PROPERTY_PRIORITY = "priority"; private PriorityEnum priority; - public static final String SERIALIZED_NAME_REFERENCE = "reference"; - @SerializedName(SERIALIZED_NAME_REFERENCE) + public static final String JSON_PROPERTY_REFERENCE = "reference"; private String reference; - public static final String SERIALIZED_NAME_REFERENCE_FOR_BENEFICIARY = "referenceForBeneficiary"; - @SerializedName(SERIALIZED_NAME_REFERENCE_FOR_BENEFICIARY) + public static final String JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY = "referenceForBeneficiary"; private String referenceForBeneficiary; - public static final String SERIALIZED_NAME_ULTIMATE_PARTY = "ultimateParty"; - @SerializedName(SERIALIZED_NAME_ULTIMATE_PARTY) + public static final String JSON_PROPERTY_ULTIMATE_PARTY = "ultimateParty"; private UltimatePartyIdentification ultimateParty; public TransferInfo() { } public TransferInfo amount(Amount amount) { - this.amount = amount; return this; } @@ -219,19 +180,22 @@ public TransferInfo amount(Amount amount) { * @return amount **/ @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Amount getAmount() { return amount; } + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAmount(Amount amount) { this.amount = amount; } public TransferInfo balanceAccountId(String balanceAccountId) { - this.balanceAccountId = balanceAccountId; return this; } @@ -241,19 +205,22 @@ public TransferInfo balanceAccountId(String balanceAccountId) { * @return balanceAccountId **/ @ApiModelProperty(value = "The unique identifier of the source [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id).") + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getBalanceAccountId() { return balanceAccountId; } + @JsonProperty(JSON_PROPERTY_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalanceAccountId(String balanceAccountId) { this.balanceAccountId = balanceAccountId; } public TransferInfo category(CategoryEnum category) { - this.category = category; return this; } @@ -263,19 +230,22 @@ public TransferInfo category(CategoryEnum category) { * @return category **/ @ApiModelProperty(required = true, value = "The type of transfer. Possible values: - **bank**: Transfer to a [transfer instrument](https://docs.adyen.com/api-explorer/#/legalentity/latest/post/transferInstruments__resParam_id) or a bank account. - **internal**: Transfer to another [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id) within your platform. - **issuedCard**: Transfer initiated by a Adyen-issued card. - **platformPayment**: Fund movements related to payments that are acquired for your users.") + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public CategoryEnum getCategory() { return category; } + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCategory(CategoryEnum category) { this.category = category; } public TransferInfo counterparty(CounterpartyInfoV3 counterparty) { - this.counterparty = counterparty; return this; } @@ -285,19 +255,22 @@ public TransferInfo counterparty(CounterpartyInfoV3 counterparty) { * @return counterparty **/ @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public CounterpartyInfoV3 getCounterparty() { return counterparty; } + @JsonProperty(JSON_PROPERTY_COUNTERPARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCounterparty(CounterpartyInfoV3 counterparty) { this.counterparty = counterparty; } public TransferInfo description(String description) { - this.description = description; return this; } @@ -307,19 +280,22 @@ public TransferInfo description(String description) { * @return description **/ @ApiModelProperty(value = "Your description for the transfer. It is used by most banks as the transfer description. We recommend sending a maximum of 140 characters, otherwise the description may be truncated. Supported characters: **[a-z] [A-Z] [0-9] / - ?** **: ( ) . , ' + Space** Supported characters for **regular** and **fast** transfers to a US counterparty: **[a-z] [A-Z] [0-9] & $ % # @** **~ = + - _ ' \" ! ?**") + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getDescription() { return description; } + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDescription(String description) { this.description = description; } public TransferInfo id(String id) { - this.id = id; return this; } @@ -329,19 +305,22 @@ public TransferInfo id(String id) { * @return id **/ @ApiModelProperty(value = "The ID of the resource.") + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(String id) { this.id = id; } public TransferInfo paymentInstrumentId(String paymentInstrumentId) { - this.paymentInstrumentId = paymentInstrumentId; return this; } @@ -351,19 +330,22 @@ public TransferInfo paymentInstrumentId(String paymentInstrumentId) { * @return paymentInstrumentId **/ @ApiModelProperty(value = "The unique identifier of the source [payment instrument](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/paymentInstruments__resParam_id).") + @JsonProperty(JSON_PROPERTY_PAYMENT_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getPaymentInstrumentId() { return paymentInstrumentId; } + @JsonProperty(JSON_PROPERTY_PAYMENT_INSTRUMENT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPaymentInstrumentId(String paymentInstrumentId) { this.paymentInstrumentId = paymentInstrumentId; } public TransferInfo priority(PriorityEnum priority) { - this.priority = priority; return this; } @@ -373,19 +355,22 @@ public TransferInfo priority(PriorityEnum priority) { * @return priority **/ @ApiModelProperty(value = "The priority for the bank transfer. This sets the speed at which the transfer is sent and the fees that you have to pay. Required for transfers with `category` **bank**. Possible values: * **regular**: For normal, low-value transactions. * **fast**: Faster way to transfer funds but has higher fees. Recommended for high-priority, low-value transactions. * **wire**: Fastest way to transfer funds but has the highest fees. Recommended for high-priority, high-value transactions. * **instant**: Instant way to transfer funds in [SEPA countries](https://www.ecb.europa.eu/paym/integration/retail/sepa/html/index.en.html). * **crossBorder**: High-value transfer to a recipient in a different country. * **internal**: Transfer to an Adyen-issued business bank account (by bank account number/IBAN).") + @JsonProperty(JSON_PROPERTY_PRIORITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public PriorityEnum getPriority() { return priority; } + @JsonProperty(JSON_PROPERTY_PRIORITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPriority(PriorityEnum priority) { this.priority = priority; } public TransferInfo reference(String reference) { - this.reference = reference; return this; } @@ -395,19 +380,22 @@ public TransferInfo reference(String reference) { * @return reference **/ @ApiModelProperty(value = "Your reference for the transfer, used internally within your platform. If you don't provide this in the request, Adyen generates a unique reference.") + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getReference() { return reference; } + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReference(String reference) { this.reference = reference; } public TransferInfo referenceForBeneficiary(String referenceForBeneficiary) { - this.referenceForBeneficiary = referenceForBeneficiary; return this; } @@ -417,19 +405,22 @@ public TransferInfo referenceForBeneficiary(String referenceForBeneficiary) { * @return referenceForBeneficiary **/ @ApiModelProperty(value = " A reference that is sent to the recipient. This reference is also sent in all webhooks related to the transfer, so you can use it to track statuses for both the source and recipient of funds. Supported characters: **a-z**, **A-Z**, **0-9**. The maximum length depends on the `category`. - **internal**: 80 characters - **bank**: 35 characters when transferring to an IBAN, 15 characters for others.") + @JsonProperty(JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getReferenceForBeneficiary() { return referenceForBeneficiary; } + @JsonProperty(JSON_PROPERTY_REFERENCE_FOR_BENEFICIARY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReferenceForBeneficiary(String referenceForBeneficiary) { this.referenceForBeneficiary = referenceForBeneficiary; } public TransferInfo ultimateParty(UltimatePartyIdentification ultimateParty) { - this.ultimateParty = ultimateParty; return this; } @@ -439,18 +430,24 @@ public TransferInfo ultimateParty(UltimatePartyIdentification ultimateParty) { * @return ultimateParty **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_ULTIMATE_PARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public UltimatePartyIdentification getUltimateParty() { return ultimateParty; } + @JsonProperty(JSON_PROPERTY_ULTIMATE_PARTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setUltimateParty(UltimatePartyIdentification ultimateParty) { this.ultimateParty = ultimateParty; } - + /** + * Return true if this TransferInfo object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -508,164 +505,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("amount"); - openapiFields.add("balanceAccountId"); - openapiFields.add("category"); - openapiFields.add("counterparty"); - openapiFields.add("description"); - openapiFields.add("id"); - openapiFields.add("paymentInstrumentId"); - openapiFields.add("priority"); - openapiFields.add("reference"); - openapiFields.add("referenceForBeneficiary"); - openapiFields.add("ultimateParty"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("amount"); - openapiRequiredFields.add("category"); - openapiRequiredFields.add("counterparty"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(TransferInfo.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to TransferInfo - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (TransferInfo.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in TransferInfo is not found in the empty JSON string", TransferInfo.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!TransferInfo.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `TransferInfo` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : TransferInfo.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field `amount` - if (jsonObj.getAsJsonObject("amount") != null) { - Amount.validateJsonObject(jsonObj.getAsJsonObject("amount")); - } - // validate the optional field balanceAccountId - if (jsonObj.get("balanceAccountId") != null && !jsonObj.get("balanceAccountId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `balanceAccountId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("balanceAccountId").toString())); - } - // ensure the field category can be parsed to an enum value - if (jsonObj.get("category") != null) { - if(!jsonObj.get("category").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); - } - CategoryEnum.fromValue(jsonObj.get("category").getAsString()); - } - // validate the optional field `counterparty` - if (jsonObj.getAsJsonObject("counterparty") != null) { - CounterpartyInfoV3.validateJsonObject(jsonObj.getAsJsonObject("counterparty")); - } - // validate the optional field description - if (jsonObj.get("description") != null && !jsonObj.get("description").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); - } - // validate the optional field id - if (jsonObj.get("id") != null && !jsonObj.get("id").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - // validate the optional field paymentInstrumentId - if (jsonObj.get("paymentInstrumentId") != null && !jsonObj.get("paymentInstrumentId").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `paymentInstrumentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("paymentInstrumentId").toString())); - } - // ensure the field priority can be parsed to an enum value - if (jsonObj.get("priority") != null) { - if(!jsonObj.get("priority").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `priority` to be a primitive type in the JSON string but got `%s`", jsonObj.get("priority").toString())); - } - PriorityEnum.fromValue(jsonObj.get("priority").getAsString()); - } - // validate the optional field reference - if (jsonObj.get("reference") != null && !jsonObj.get("reference").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); - } - // validate the optional field referenceForBeneficiary - if (jsonObj.get("referenceForBeneficiary") != null && !jsonObj.get("referenceForBeneficiary").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `referenceForBeneficiary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("referenceForBeneficiary").toString())); - } - // validate the optional field `ultimateParty` - if (jsonObj.getAsJsonObject("ultimateParty") != null) { - UltimatePartyIdentification.validateJsonObject(jsonObj.getAsJsonObject("ultimateParty")); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!TransferInfo.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'TransferInfo' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(TransferInfo.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, TransferInfo value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public TransferInfo read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of TransferInfo given an JSON string - * - * @param jsonString JSON string - * @return An instance of TransferInfo - * @throws IOException if the JSON string is invalid with respect to TransferInfo - */ - public static TransferInfo fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, TransferInfo.class); +/** + * Create an instance of TransferInfo given an JSON string + * + * @param jsonString JSON string + * @return An instance of TransferInfo + * @throws JsonProcessingException if the JSON string is invalid with respect to TransferInfo + */ + public static TransferInfo fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, TransferInfo.class); } - - /** +/** * Convert an instance of TransferInfo to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/UKLocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/UKLocalAccountIdentification.java index 368a58516..6886b1715 100644 --- a/src/main/java/com/adyen/model/transfers/UKLocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/UKLocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,54 +14,38 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * UKLocalAccountIdentification */ +@JsonPropertyOrder({ + UKLocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + UKLocalAccountIdentification.JSON_PROPERTY_SORT_CODE, + UKLocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class UKLocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; - public static final String SERIALIZED_NAME_SORT_CODE = "sortCode"; - @SerializedName(SERIALIZED_NAME_SORT_CODE) + public static final String JSON_PROPERTY_SORT_CODE = "sortCode"; private String sortCode; /** * **ukLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { UKLOCAL("ukLocal"); @@ -71,6 +55,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -80,6 +65,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -88,30 +74,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.UKLOCAL; public UKLocalAccountIdentification() { } public UKLocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -121,19 +92,22 @@ public UKLocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The 8-digit bank account number, without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public UKLocalAccountIdentification sortCode(String sortCode) { - this.sortCode = sortCode; return this; } @@ -143,19 +117,22 @@ public UKLocalAccountIdentification sortCode(String sortCode) { * @return sortCode **/ @ApiModelProperty(required = true, value = "The 6-digit [sort code](https://en.wikipedia.org/wiki/Sort_code), without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_SORT_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getSortCode() { return sortCode; } + @JsonProperty(JSON_PROPERTY_SORT_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setSortCode(String sortCode) { this.sortCode = sortCode; } public UKLocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -165,18 +142,24 @@ public UKLocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**ukLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this UKLocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -218,121 +201,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("sortCode"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("sortCode"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(UKLocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to UKLocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (UKLocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in UKLocalAccountIdentification is not found in the empty JSON string", UKLocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!UKLocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `UKLocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : UKLocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // validate the optional field sortCode - if (jsonObj.get("sortCode") != null && !jsonObj.get("sortCode").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `sortCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sortCode").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!UKLocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'UKLocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(UKLocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, UKLocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public UKLocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of UKLocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of UKLocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to UKLocalAccountIdentification - */ - public static UKLocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, UKLocalAccountIdentification.class); +/** + * Create an instance of UKLocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of UKLocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to UKLocalAccountIdentification + */ + public static UKLocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, UKLocalAccountIdentification.class); } - - /** +/** * Convert an instance of UKLocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/USLocalAccountIdentification.java b/src/main/java/com/adyen/model/transfers/USLocalAccountIdentification.java index 3002cf834..bbfe28d27 100644 --- a/src/main/java/com/adyen/model/transfers/USLocalAccountIdentification.java +++ b/src/main/java/com/adyen/model/transfers/USLocalAccountIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,50 +14,36 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.adyen.model.transfers.JSON; /** * USLocalAccountIdentification */ +@JsonPropertyOrder({ + USLocalAccountIdentification.JSON_PROPERTY_ACCOUNT_NUMBER, + USLocalAccountIdentification.JSON_PROPERTY_ACCOUNT_TYPE, + USLocalAccountIdentification.JSON_PROPERTY_ROUTING_NUMBER, + USLocalAccountIdentification.JSON_PROPERTY_TYPE +}) public class USLocalAccountIdentification { - public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER) + public static final String JSON_PROPERTY_ACCOUNT_NUMBER = "accountNumber"; private String accountNumber; /** * The bank account type. Possible values: **checking** or **savings**. Defaults to **checking**. */ - @JsonAdapter(AccountTypeEnum.Adapter.class) public enum AccountTypeEnum { CHECKING("checking"), @@ -69,6 +55,7 @@ public enum AccountTypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -78,6 +65,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static AccountTypeEnum fromValue(String value) { for (AccountTypeEnum b : AccountTypeEnum.values()) { if (b.value.equals(value)) { @@ -86,33 +74,17 @@ public static AccountTypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final AccountTypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public AccountTypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return AccountTypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_ACCOUNT_TYPE = "accountType"; - @SerializedName(SERIALIZED_NAME_ACCOUNT_TYPE) + public static final String JSON_PROPERTY_ACCOUNT_TYPE = "accountType"; private AccountTypeEnum accountType = AccountTypeEnum.CHECKING; - public static final String SERIALIZED_NAME_ROUTING_NUMBER = "routingNumber"; - @SerializedName(SERIALIZED_NAME_ROUTING_NUMBER) + public static final String JSON_PROPERTY_ROUTING_NUMBER = "routingNumber"; private String routingNumber; /** * **usLocal** */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { USLOCAL("usLocal"); @@ -122,6 +94,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -131,6 +104,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -139,30 +113,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.USLOCAL; public USLocalAccountIdentification() { } public USLocalAccountIdentification accountNumber(String accountNumber) { - this.accountNumber = accountNumber; return this; } @@ -172,19 +131,22 @@ public USLocalAccountIdentification accountNumber(String accountNumber) { * @return accountNumber **/ @ApiModelProperty(required = true, value = "The bank account number, without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getAccountNumber() { return accountNumber; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; } public USLocalAccountIdentification accountType(AccountTypeEnum accountType) { - this.accountType = accountType; return this; } @@ -194,19 +156,22 @@ public USLocalAccountIdentification accountType(AccountTypeEnum accountType) { * @return accountType **/ @ApiModelProperty(value = "The bank account type. Possible values: **checking** or **savings**. Defaults to **checking**.") + @JsonProperty(JSON_PROPERTY_ACCOUNT_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public AccountTypeEnum getAccountType() { return accountType; } + @JsonProperty(JSON_PROPERTY_ACCOUNT_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountType(AccountTypeEnum accountType) { this.accountType = accountType; } public USLocalAccountIdentification routingNumber(String routingNumber) { - this.routingNumber = routingNumber; return this; } @@ -216,19 +181,22 @@ public USLocalAccountIdentification routingNumber(String routingNumber) { * @return routingNumber **/ @ApiModelProperty(required = true, value = "The 9-digit [routing number](https://en.wikipedia.org/wiki/ABA_routing_transit_number), without separators or whitespace.") + @JsonProperty(JSON_PROPERTY_ROUTING_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getRoutingNumber() { return routingNumber; } + @JsonProperty(JSON_PROPERTY_ROUTING_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setRoutingNumber(String routingNumber) { this.routingNumber = routingNumber; } public USLocalAccountIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -238,18 +206,24 @@ public USLocalAccountIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(required = true, value = "**usLocal**") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this USLocalAccountIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -293,129 +267,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("accountNumber"); - openapiFields.add("accountType"); - openapiFields.add("routingNumber"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("accountNumber"); - openapiRequiredFields.add("routingNumber"); - openapiRequiredFields.add("type"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(USLocalAccountIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to USLocalAccountIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (USLocalAccountIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in USLocalAccountIdentification is not found in the empty JSON string", USLocalAccountIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!USLocalAccountIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `USLocalAccountIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : USLocalAccountIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field accountNumber - if (jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString())); - } - // ensure the field accountType can be parsed to an enum value - if (jsonObj.get("accountType") != null) { - if(!jsonObj.get("accountType").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `accountType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountType").toString())); - } - AccountTypeEnum.fromValue(jsonObj.get("accountType").getAsString()); - } - // validate the optional field routingNumber - if (jsonObj.get("routingNumber") != null && !jsonObj.get("routingNumber").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `routingNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("routingNumber").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!USLocalAccountIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'USLocalAccountIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(USLocalAccountIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, USLocalAccountIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public USLocalAccountIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of USLocalAccountIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of USLocalAccountIdentification - * @throws IOException if the JSON string is invalid with respect to USLocalAccountIdentification - */ - public static USLocalAccountIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, USLocalAccountIdentification.class); +/** + * Create an instance of USLocalAccountIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of USLocalAccountIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to USLocalAccountIdentification + */ + public static USLocalAccountIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, USLocalAccountIdentification.class); } - - /** +/** * Convert an instance of USLocalAccountIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/model/transfers/UltimatePartyIdentification.java b/src/main/java/com/adyen/model/transfers/UltimatePartyIdentification.java index 7afce8aad..abd548433 100644 --- a/src/main/java/com/adyen/model/transfers/UltimatePartyIdentification.java +++ b/src/main/java/com/adyen/model/transfers/UltimatePartyIdentification.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,72 +14,56 @@ import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.adyen.model.transfers.Address2; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; import java.time.LocalDate; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.adyen.model.transfers.JSON; /** * UltimatePartyIdentification */ +@JsonPropertyOrder({ + UltimatePartyIdentification.JSON_PROPERTY_ADDRESS, + UltimatePartyIdentification.JSON_PROPERTY_DATE_OF_BIRTH, + UltimatePartyIdentification.JSON_PROPERTY_FIRST_NAME, + UltimatePartyIdentification.JSON_PROPERTY_FULL_NAME, + UltimatePartyIdentification.JSON_PROPERTY_LAST_NAME, + UltimatePartyIdentification.JSON_PROPERTY_REFERENCE, + UltimatePartyIdentification.JSON_PROPERTY_TYPE +}) public class UltimatePartyIdentification { - public static final String SERIALIZED_NAME_ADDRESS = "address"; - @SerializedName(SERIALIZED_NAME_ADDRESS) + public static final String JSON_PROPERTY_ADDRESS = "address"; private Address2 address; - public static final String SERIALIZED_NAME_DATE_OF_BIRTH = "dateOfBirth"; - @SerializedName(SERIALIZED_NAME_DATE_OF_BIRTH) + public static final String JSON_PROPERTY_DATE_OF_BIRTH = "dateOfBirth"; private LocalDate dateOfBirth; - public static final String SERIALIZED_NAME_FIRST_NAME = "firstName"; - @SerializedName(SERIALIZED_NAME_FIRST_NAME) + public static final String JSON_PROPERTY_FIRST_NAME = "firstName"; private String firstName; - public static final String SERIALIZED_NAME_FULL_NAME = "fullName"; - @SerializedName(SERIALIZED_NAME_FULL_NAME) + public static final String JSON_PROPERTY_FULL_NAME = "fullName"; private String fullName; - public static final String SERIALIZED_NAME_LAST_NAME = "lastName"; - @SerializedName(SERIALIZED_NAME_LAST_NAME) + public static final String JSON_PROPERTY_LAST_NAME = "lastName"; private String lastName; - public static final String SERIALIZED_NAME_REFERENCE = "reference"; - @SerializedName(SERIALIZED_NAME_REFERENCE) + public static final String JSON_PROPERTY_REFERENCE = "reference"; private String reference; /** * The type of entity that owns the bank account. Possible values: **individual**, **organization**, or **unknown**. */ - @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { INDIVIDUAL("individual"), @@ -93,6 +77,7 @@ public enum TypeEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -102,6 +87,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static TypeEnum fromValue(String value) { for (TypeEnum b : TypeEnum.values()) { if (b.value.equals(value)) { @@ -110,30 +96,15 @@ public static TypeEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) + public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type = TypeEnum.UNKNOWN; public UltimatePartyIdentification() { } public UltimatePartyIdentification address(Address2 address) { - this.address = address; return this; } @@ -143,41 +114,47 @@ public UltimatePartyIdentification address(Address2 address) { * @return address **/ @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_ADDRESS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Address2 getAddress() { return address; } + @JsonProperty(JSON_PROPERTY_ADDRESS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAddress(Address2 address) { this.address = address; } public UltimatePartyIdentification dateOfBirth(LocalDate dateOfBirth) { - this.dateOfBirth = dateOfBirth; return this; } /** - * The date of birth of the individual in [ISO-8601](https://www.w3.org/TR/NOTE-datetime) format. For example, **YYYY-MM-DD**. Allowed only when `type` is **individual**. + * The date of birth of the individual in [ISO-8601](https://www.w3.org/TR/NOTE-datetime) format. For example, **YYYY-MM-DD**. Should not be before 1st January 1900. Allowed only when `type` is **individual**. * @return dateOfBirth **/ - @ApiModelProperty(value = "The date of birth of the individual in [ISO-8601](https://www.w3.org/TR/NOTE-datetime) format. For example, **YYYY-MM-DD**. Allowed only when `type` is **individual**.") + @ApiModelProperty(value = "The date of birth of the individual in [ISO-8601](https://www.w3.org/TR/NOTE-datetime) format. For example, **YYYY-MM-DD**. Should not be before 1st January 1900. Allowed only when `type` is **individual**.") + @JsonProperty(JSON_PROPERTY_DATE_OF_BIRTH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public LocalDate getDateOfBirth() { return dateOfBirth; } + @JsonProperty(JSON_PROPERTY_DATE_OF_BIRTH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDateOfBirth(LocalDate dateOfBirth) { this.dateOfBirth = dateOfBirth; } public UltimatePartyIdentification firstName(String firstName) { - this.firstName = firstName; return this; } @@ -187,19 +164,22 @@ public UltimatePartyIdentification firstName(String firstName) { * @return firstName **/ @ApiModelProperty(value = "First name of the individual. Allowed only when `type` is **individual**.") + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getFirstName() { return firstName; } + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setFirstName(String firstName) { this.firstName = firstName; } public UltimatePartyIdentification fullName(String fullName) { - this.fullName = fullName; return this; } @@ -209,19 +189,22 @@ public UltimatePartyIdentification fullName(String fullName) { * @return fullName **/ @ApiModelProperty(required = true, value = "The name of the entity.") + @JsonProperty(JSON_PROPERTY_FULL_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getFullName() { return fullName; } + @JsonProperty(JSON_PROPERTY_FULL_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setFullName(String fullName) { this.fullName = fullName; } public UltimatePartyIdentification lastName(String lastName) { - this.lastName = lastName; return this; } @@ -231,19 +214,22 @@ public UltimatePartyIdentification lastName(String lastName) { * @return lastName **/ @ApiModelProperty(value = "Last name of the individual. Allowed only when `type` is **individual**.") + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getLastName() { return lastName; } + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setLastName(String lastName) { this.lastName = lastName; } public UltimatePartyIdentification reference(String reference) { - this.reference = reference; return this; } @@ -253,19 +239,22 @@ public UltimatePartyIdentification reference(String reference) { * @return reference **/ @ApiModelProperty(value = "Your unique reference of the party. This should be consistent for all transfers initiated to/from the same party/counterparty. e.g Your client's unique wallet or payee ID") + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getReference() { return reference; } + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReference(String reference) { this.reference = reference; } public UltimatePartyIdentification type(TypeEnum type) { - this.type = type; return this; } @@ -275,18 +264,24 @@ public UltimatePartyIdentification type(TypeEnum type) { * @return type **/ @ApiModelProperty(value = "The type of entity that owns the bank account. Possible values: **individual**, **organization**, or **unknown**.") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - + /** + * Return true if this UltimatePartyIdentification object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -336,135 +331,23 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("address"); - openapiFields.add("dateOfBirth"); - openapiFields.add("firstName"); - openapiFields.add("fullName"); - openapiFields.add("lastName"); - openapiFields.add("reference"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("fullName"); - } - /** - * logger for Deserialization Errors - */ - private static final Logger log = Logger.getLogger(UltimatePartyIdentification.class.getName()); - - /** - * Validates the JSON Object and throws an exception if issues found - * - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to UltimatePartyIdentification - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (UltimatePartyIdentification.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields - throw new IllegalArgumentException(String.format("The required field(s) %s in UltimatePartyIdentification is not found in the empty JSON string", UltimatePartyIdentification.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!UltimatePartyIdentification.openapiFields.contains(entry.getKey())) { - log.log(Level.WARNING, String.format("The field `%s` in the JSON string is not defined in the `UltimatePartyIdentification` properties.", entry.getKey())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : UltimatePartyIdentification.openapiRequiredFields) { - if (jsonObj.get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); - } - } - // validate the optional field `address` - if (jsonObj.getAsJsonObject("address") != null) { - Address2.validateJsonObject(jsonObj.getAsJsonObject("address")); - } - // validate the optional field firstName - if (jsonObj.get("firstName") != null && !jsonObj.get("firstName").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `firstName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("firstName").toString())); - } - // validate the optional field fullName - if (jsonObj.get("fullName") != null && !jsonObj.get("fullName").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `fullName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("fullName").toString())); - } - // validate the optional field lastName - if (jsonObj.get("lastName") != null && !jsonObj.get("lastName").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `lastName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lastName").toString())); - } - // validate the optional field reference - if (jsonObj.get("reference") != null && !jsonObj.get("reference").isJsonPrimitive()) { - log.log(Level.WARNING, String.format("Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); - } - // ensure the field type can be parsed to an enum value - if (jsonObj.get("type") != null) { - if(!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - TypeEnum.fromValue(jsonObj.get("type").getAsString()); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!UltimatePartyIdentification.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'UltimatePartyIdentification' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(UltimatePartyIdentification.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, UltimatePartyIdentification value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public UltimatePartyIdentification read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of UltimatePartyIdentification given an JSON string - * - * @param jsonString JSON string - * @return An instance of UltimatePartyIdentification - * @throws IOException if the JSON string is invalid with respect to UltimatePartyIdentification - */ - public static UltimatePartyIdentification fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, UltimatePartyIdentification.class); +/** + * Create an instance of UltimatePartyIdentification given an JSON string + * + * @param jsonString JSON string + * @return An instance of UltimatePartyIdentification + * @throws JsonProcessingException if the JSON string is invalid with respect to UltimatePartyIdentification + */ + public static UltimatePartyIdentification fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, UltimatePartyIdentification.class); } - - /** +/** * Convert an instance of UltimatePartyIdentification to an JSON string * * @return JSON string */ - public String toJson() { - return JSON.getGson().toJson(this); + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); } } diff --git a/src/main/java/com/adyen/service/Transfers.java b/src/main/java/com/adyen/service/Transfers.java deleted file mode 100644 index a61dab9d6..000000000 --- a/src/main/java/com/adyen/service/Transfers.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.adyen.service; - -import com.adyen.Client; -import com.adyen.Service; -import com.adyen.constants.ApiConstants; - -import com.adyen.model.transfers.TransactionSearchResponse; -import com.adyen.model.transfers.Transfer; -import com.adyen.model.transfers.TransferInfo; -import com.adyen.model.transfers.Transaction; -import com.adyen.service.exception.ApiException; -import com.adyen.service.resource.transfers.TransfersResource; - -import java.io.IOException; -import java.util.Collections; -import java.util.Map; - -public class Transfers extends Service { - - private static final String ID = "Id"; - - public Transfers(Client client) { - super(client); - } - - public Transfer transfers(TransferInfo transferInfo) throws IOException, ApiException { - String jsonRequest = transferInfo.toJson(); - TransfersResource transfersResource = new TransfersResource(this, "/transfers"); - String jsonResult = transfersResource.request(jsonRequest); - return Transfer.fromJson(jsonResult); - } - - public TransactionSearchResponse listTransactions() throws IOException, ApiException { - TransfersResource transfersResource = new TransfersResource(this, "/transactions"); - String jsonResult = transfersResource.request(null, null, ApiConstants.HttpMethod.GET, null); - return TransactionSearchResponse.fromJson(jsonResult); - } - - public Transaction getTransaction(String transactionId) throws IOException, ApiException { - Map params = Collections.singletonMap(ID, transactionId); - TransfersResource transfersResource = new TransfersResource(this, "/transactions"); - String jsonResult = transfersResource.request(null, null, ApiConstants.HttpMethod.GET, params); - return Transaction.fromJson(jsonResult); - } -} \ No newline at end of file diff --git a/src/main/java/com/adyen/service/CapitalApi.java b/src/main/java/com/adyen/service/transfers/CapitalApi.java similarity index 72% rename from src/main/java/com/adyen/service/CapitalApi.java rename to src/main/java/com/adyen/service/transfers/CapitalApi.java index 5fc729723..c3d1ee99c 100644 --- a/src/main/java/com/adyen/service/CapitalApi.java +++ b/src/main/java/com/adyen/service/transfers/CapitalApi.java @@ -1,24 +1,23 @@ /* - * Capital API - * Adyen Capital allows you to build an embedded financing offering for your users to serve their operational needs. Learn more about [Adyen Capital](https://docs.adyen.com/marketplaces-and-platforms/capital). ## Authentication Your Adyen contact will provide your API credential and an API key. To connect to the API, add an `X-API-Key` header with the API key as the value, for example: ``` curl -H \"Content-Type: application/json\" \\ -H \"X-API-Key: YOUR_API_KEY\" \\ ... ``` Alternatively, you can use the username and password to connect to the API using basic authentication. For example: ``` curl -H \"Content-Type: application/json\" \\ -U \"ws@BalancePlatform.YOUR_BALANCE_PLATFORM\":\"YOUR_WS_PASSWORD\" \\ ... ``` ## Roles and permissions To use the Capital API, you need an additional role for your API credential. Your Adyen contact will set up the roles and permissions for you. ## Versioning The Capital API supports [versioning](https://docs.adyen.com/development-resources/versioning) using a version suffix in the endpoint URL. This suffix has the following format: \"vXX\", where XX is the version number. For example: ``` https://balanceplatform-api-test.adyen.com/btl/v3/grants ``` ## Going live When going live, your Adyen contact will provide your API credential for the live environment. You can then use the username and password to send requests to `https://balanceplatform-api-live.adyen.com/btl/v3`. + * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * 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; +package com.adyen.service.transfers; import com.adyen.Client; import com.adyen.Service; import com.adyen.constants.ApiConstants; -import com.adyen.model.capital.CapitalGrant; -import com.adyen.model.capital.CapitalGrantInfo; -import com.adyen.model.capital.CapitalGrants; -import com.adyen.model.capital.RestServiceError; +import com.adyen.model.transfers.CapitalGrant; +import com.adyen.model.transfers.CapitalGrantInfo; +import com.adyen.model.transfers.CapitalGrants; +import com.adyen.model.transfers.RestServiceError; import com.adyen.model.RequestOptions; import com.adyen.service.exception.ApiException; import com.adyen.service.resource.Resource; diff --git a/src/main/java/com/adyen/service/transfers/TransactionsApi.java b/src/main/java/com/adyen/service/transfers/TransactionsApi.java index 5e998b846..a1da61fc2 100644 --- a/src/main/java/com/adyen/service/transfers/TransactionsApi.java +++ b/src/main/java/com/adyen/service/transfers/TransactionsApi.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/main/java/com/adyen/service/transfers/TransfersApi.java b/src/main/java/com/adyen/service/transfers/TransfersApi.java index 677412cb6..72fd4be54 100644 --- a/src/main/java/com/adyen/service/transfers/TransfersApi.java +++ b/src/main/java/com/adyen/service/transfers/TransfersApi.java @@ -2,7 +2,7 @@ * Transfers API * * The version of the OpenAPI document: 3 - * Contact: developer-experience@adyen.com + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/test/java/com/adyen/CapitalTest.java b/src/test/java/com/adyen/CapitalTest.java deleted file mode 100644 index 36ceb63d2..000000000 --- a/src/test/java/com/adyen/CapitalTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.adyen; - -import com.adyen.constants.ApiConstants; -import com.adyen.model.capital.CapitalGrant; -import com.adyen.model.capital.CapitalGrantInfo; -import com.adyen.service.CapitalApi; -import org.junit.Test; - -import java.util.HashMap; - -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.verify; - -public class CapitalTest extends BaseTest { - - @Test - public void TestGetCapitalAccounts() throws Exception { - Client client = createMockClientFromFile("mocks/capital/get-capital-account.json"); - CapitalApi service = new CapitalApi(client); - com.adyen.model.capital.CapitalGrants response = service.getCapitalAccount(); - assertEquals(response.getGrants().get(0).getGrantOfferId(), "string"); - verify(client.getHttpClient()).request( - "https://balanceplatform-api-test.adyen.com/btl/v3/grants", - null, - client.getConfig(), - false, - null, - ApiConstants.HttpMethod.GET, - new HashMap<>() - ); - } - - @Test - public void TestRequestGrant() throws Exception { - Client client = createMockClientFromFile("mocks/capital/request-grant.json"); - CapitalApi service = new CapitalApi(client); - CapitalGrant response = service.requestGrantPayout(new CapitalGrantInfo()); - assertEquals(response.getGrantAccountId(), "CG00000000000000000000001"); - verify(client.getHttpClient()).request( - "https://balanceplatform-api-test.adyen.com/btl/v3/grants", - "{}", - client.getConfig(), - false, - null, - ApiConstants.HttpMethod.POST, - null - ); - } -} diff --git a/src/test/java/com/adyen/TransfersTest.java b/src/test/java/com/adyen/TransfersTest.java index fad89a829..f8e465917 100644 --- a/src/test/java/com/adyen/TransfersTest.java +++ b/src/test/java/com/adyen/TransfersTest.java @@ -1,18 +1,23 @@ package com.adyen; +import com.adyen.constants.ApiConstants; import com.adyen.model.transfers.*; -import com.adyen.service.Transfers; +import com.adyen.service.transfers.*; + import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.verify; + +import java.util.HashMap; public class TransfersTest extends BaseTest { @Test public void TransferTest() throws Exception { Client client = createMockClientFromFile("mocks/transfers/post-transfers-payout-cross-border-200.json"); - Transfers transfers = new Transfers(client); - Transfer response = transfers.transfers(new TransferInfo()); + TransfersApi transfers = new TransfersApi(client); + Transfer response = transfers.transferFunds(new TransferInfo()); Amount amount = new Amount(); amount.setCurrency("EUR"); amount.setValue(80000L); @@ -24,8 +29,8 @@ public void TransferTest() throws Exception { @Test public void TransactionsListTest() throws Exception { Client client = createMockClientFromFile("mocks/transfers/get-transactions-success-200.json"); - Transfers transactions = new Transfers(client); - TransactionSearchResponse response = transactions.listTransactions(); + TransactionsApi transactions = new TransactionsApi(client); + TransactionSearchResponse response = transactions.getAllTransactions(null, null); Transaction transactionsResponse = response.getData().get(1); assertEquals(transactionsResponse.getAccountHolderId(), "AHA1B2C3D4E5F6G7H8I9J0"); assertEquals(transactionsResponse.getCounterparty().getBalanceAccountId(), "BAB8B2C3D4E5F6G7H8D9J6GD4"); @@ -35,10 +40,44 @@ public void TransactionsListTest() throws Exception { @Test public void TransactionsRetrieveTest() throws Exception { Client client = createMockClientFromFile("mocks/transfers/get-transactions-id-success-200.json"); - Transfers transactions = new Transfers(client); + TransactionsApi transactions = new TransactionsApi(client); Transaction response = transactions.getTransaction("1"); assertEquals(response.getAccountHolderId(), "AHA1B2C3D4E5F6G7H8I9J0"); assertEquals(response.getBalancePlatform(), "YOUR_BALANCE_PLATFORM"); assertEquals(response.getTransferId(), "2QP32A5U7IWC5WKG"); } + + @Test + public void TestGetCapitalAccounts() throws Exception { + Client client = createMockClientFromFile("mocks/capital/get-capital-account.json"); + CapitalApi capital = new CapitalApi(client); + CapitalGrants response = capital.getCapitalAccount(); + assertEquals(response.getGrants().get(0).getGrantOfferId(), "string"); + verify(client.getHttpClient()).request( + "https://balanceplatform-api-test.adyen.com/btl/v3/grants", + null, + client.getConfig(), + false, + null, + ApiConstants.HttpMethod.GET, + new HashMap<>() + ); + } + + @Test + public void TestRequestGrant() throws Exception { + Client client = createMockClientFromFile("mocks/capital/request-grant.json"); + CapitalApi capital = new CapitalApi(client); + CapitalGrant response = capital.requestGrantPayout(new CapitalGrantInfo()); + assertEquals(response.getGrantAccountId(), "CG00000000000000000000001"); + verify(client.getHttpClient()).request( + "https://balanceplatform-api-test.adyen.com/btl/v3/grants", + "{}", + client.getConfig(), + false, + null, + ApiConstants.HttpMethod.POST, + null + ); + } }