diff --git a/src/main/java/com/adyen/model/balancecontrol/Amount.java b/src/main/java/com/adyen/model/balancecontrol/Amount.java index 076c43f80..2fedd397b 100644 --- a/src/main/java/com/adyen/model/balancecontrol/Amount.java +++ b/src/main/java/com/adyen/model/balancecontrol/Amount.java @@ -11,6 +11,8 @@ package com.adyen.model.balancecontrol; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -23,9 +25,21 @@ public class Amount { public static final String JSON_PROPERTY_CURRENCY = "currency"; private String currency; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetCurrency = false; + public static final String JSON_PROPERTY_VALUE = "value"; private Long value; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetValue = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + public Amount() {} /** @@ -38,6 +52,7 @@ public Amount() {} */ public Amount currency(String currency) { this.currency = currency; + isSetCurrency = true; // mark as set return this; } @@ -65,6 +80,7 @@ public String getCurrency() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCurrency(String currency) { this.currency = currency; + isSetCurrency = true; // mark as set } /** @@ -77,6 +93,7 @@ public void setCurrency(String currency) { */ public Amount value(Long value) { this.value = value; + isSetValue = true; // mark as set return this; } @@ -104,6 +121,27 @@ public Long getValue() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setValue(Long value) { this.value = value; + isSetValue = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public Amount includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; } /** Return true if this Amount object is equal to o. */ @@ -117,12 +155,14 @@ public boolean equals(Object o) { } Amount amount = (Amount) o; return Objects.equals(this.currency, amount.currency) - && Objects.equals(this.value, amount.value); + && Objects.equals(this.isSetCurrency, amount.isSetCurrency) + && Objects.equals(this.value, amount.value) + && Objects.equals(this.isSetValue, amount.isSetValue); } @Override public int hashCode() { - return Objects.hash(currency, value); + return Objects.hash(currency, isSetCurrency, value, isSetValue); } @Override @@ -145,6 +185,33 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetCurrency) { + addIfNull(nulls, JSON_PROPERTY_CURRENCY, this.currency); + } + if (isSetValue) { + addIfNull(nulls, JSON_PROPERTY_VALUE, this.value); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + /** * Create an instance of Amount given an JSON string * diff --git a/src/main/java/com/adyen/model/balancecontrol/BalanceTransferRequest.java b/src/main/java/com/adyen/model/balancecontrol/BalanceTransferRequest.java index a4b8feb0b..7f48b42b3 100644 --- a/src/main/java/com/adyen/model/balancecontrol/BalanceTransferRequest.java +++ b/src/main/java/com/adyen/model/balancecontrol/BalanceTransferRequest.java @@ -11,7 +11,9 @@ package com.adyen.model.balancecontrol; +import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -34,18 +36,33 @@ public class BalanceTransferRequest { public static final String JSON_PROPERTY_AMOUNT = "amount"; private Amount amount; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetAmount = false; + public static final String JSON_PROPERTY_DESCRIPTION = "description"; private String description; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetDescription = false; + public static final String JSON_PROPERTY_FROM_MERCHANT = "fromMerchant"; private String fromMerchant; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetFromMerchant = false; + public static final String JSON_PROPERTY_REFERENCE = "reference"; private String reference; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetReference = false; + public static final String JSON_PROPERTY_TO_MERCHANT = "toMerchant"; private String toMerchant; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetToMerchant = false; + /** * The type of balance transfer. Possible values: **tax**, **fee**, **terminalSale**, **credit**, * **debit**, and **adjustment**. @@ -101,6 +118,15 @@ public static TypeEnum fromValue(String value) { public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetType = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + public BalanceTransferRequest() {} /** @@ -111,6 +137,7 @@ public BalanceTransferRequest() {} */ public BalanceTransferRequest amount(Amount amount) { this.amount = amount; + isSetAmount = true; // mark as set return this; } @@ -134,6 +161,7 @@ public Amount getAmount() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAmount(Amount amount) { this.amount = amount; + isSetAmount = true; // mark as set } /** @@ -147,6 +175,7 @@ public void setAmount(Amount amount) { */ public BalanceTransferRequest description(String description) { this.description = description; + isSetDescription = true; // mark as set return this; } @@ -176,6 +205,7 @@ public String getDescription() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDescription(String description) { this.description = description; + isSetDescription = true; // mark as set } /** @@ -187,6 +217,7 @@ public void setDescription(String description) { */ public BalanceTransferRequest fromMerchant(String fromMerchant) { this.fromMerchant = fromMerchant; + isSetFromMerchant = true; // mark as set return this; } @@ -212,6 +243,7 @@ public String getFromMerchant() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setFromMerchant(String fromMerchant) { this.fromMerchant = fromMerchant; + isSetFromMerchant = true; // mark as set } /** @@ -224,6 +256,7 @@ public void setFromMerchant(String fromMerchant) { */ public BalanceTransferRequest reference(String reference) { this.reference = reference; + isSetReference = true; // mark as set return this; } @@ -251,6 +284,7 @@ public String getReference() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReference(String reference) { this.reference = reference; + isSetReference = true; // mark as set } /** @@ -262,6 +296,7 @@ public void setReference(String reference) { */ public BalanceTransferRequest toMerchant(String toMerchant) { this.toMerchant = toMerchant; + isSetToMerchant = true; // mark as set return this; } @@ -287,6 +322,7 @@ public String getToMerchant() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setToMerchant(String toMerchant) { this.toMerchant = toMerchant; + isSetToMerchant = true; // mark as set } /** @@ -299,6 +335,7 @@ public void setToMerchant(String toMerchant) { */ public BalanceTransferRequest type(TypeEnum type) { this.type = type; + isSetType = true; // mark as set return this; } @@ -326,6 +363,27 @@ public TypeEnum getType() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; + isSetType = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public BalanceTransferRequest includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; } /** Return true if this BalanceTransferRequest object is equal to o. */ @@ -339,16 +397,34 @@ public boolean equals(Object o) { } BalanceTransferRequest balanceTransferRequest = (BalanceTransferRequest) o; return Objects.equals(this.amount, balanceTransferRequest.amount) + && Objects.equals(this.isSetAmount, balanceTransferRequest.isSetAmount) && Objects.equals(this.description, balanceTransferRequest.description) + && Objects.equals(this.isSetDescription, balanceTransferRequest.isSetDescription) && Objects.equals(this.fromMerchant, balanceTransferRequest.fromMerchant) + && Objects.equals(this.isSetFromMerchant, balanceTransferRequest.isSetFromMerchant) && Objects.equals(this.reference, balanceTransferRequest.reference) + && Objects.equals(this.isSetReference, balanceTransferRequest.isSetReference) && Objects.equals(this.toMerchant, balanceTransferRequest.toMerchant) - && Objects.equals(this.type, balanceTransferRequest.type); + && Objects.equals(this.isSetToMerchant, balanceTransferRequest.isSetToMerchant) + && Objects.equals(this.type, balanceTransferRequest.type) + && Objects.equals(this.isSetType, balanceTransferRequest.isSetType); } @Override public int hashCode() { - return Objects.hash(amount, description, fromMerchant, reference, toMerchant, type); + return Objects.hash( + amount, + isSetAmount, + description, + isSetDescription, + fromMerchant, + isSetFromMerchant, + reference, + isSetReference, + toMerchant, + isSetToMerchant, + type, + isSetType); } @Override @@ -375,6 +451,45 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetAmount) { + addIfNull(nulls, JSON_PROPERTY_AMOUNT, this.amount); + } + if (isSetDescription) { + addIfNull(nulls, JSON_PROPERTY_DESCRIPTION, this.description); + } + if (isSetFromMerchant) { + addIfNull(nulls, JSON_PROPERTY_FROM_MERCHANT, this.fromMerchant); + } + if (isSetReference) { + addIfNull(nulls, JSON_PROPERTY_REFERENCE, this.reference); + } + if (isSetToMerchant) { + addIfNull(nulls, JSON_PROPERTY_TO_MERCHANT, this.toMerchant); + } + if (isSetType) { + addIfNull(nulls, JSON_PROPERTY_TYPE, this.type); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + /** * Create an instance of BalanceTransferRequest given an JSON string * diff --git a/src/main/java/com/adyen/model/balancecontrol/BalanceTransferResponse.java b/src/main/java/com/adyen/model/balancecontrol/BalanceTransferResponse.java index e4922ef8a..417920aaf 100644 --- a/src/main/java/com/adyen/model/balancecontrol/BalanceTransferResponse.java +++ b/src/main/java/com/adyen/model/balancecontrol/BalanceTransferResponse.java @@ -11,7 +11,9 @@ package com.adyen.model.balancecontrol; +import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -38,21 +40,39 @@ public class BalanceTransferResponse { public static final String JSON_PROPERTY_AMOUNT = "amount"; private Amount amount; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetAmount = false; + public static final String JSON_PROPERTY_CREATED_AT = "createdAt"; private OffsetDateTime createdAt; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetCreatedAt = false; + public static final String JSON_PROPERTY_DESCRIPTION = "description"; private String description; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetDescription = false; + public static final String JSON_PROPERTY_FROM_MERCHANT = "fromMerchant"; private String fromMerchant; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetFromMerchant = false; + public static final String JSON_PROPERTY_PSP_REFERENCE = "pspReference"; private String pspReference; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetPspReference = false; + public static final String JSON_PROPERTY_REFERENCE = "reference"; private String reference; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetReference = false; + /** * The status of the balance transfer. Possible values: **transferred**, **failed**, **error**, * and **notEnoughBalance**. @@ -104,9 +124,15 @@ public static StatusEnum fromValue(String value) { public static final String JSON_PROPERTY_STATUS = "status"; private StatusEnum status; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetStatus = false; + public static final String JSON_PROPERTY_TO_MERCHANT = "toMerchant"; private String toMerchant; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetToMerchant = false; + /** * The type of balance transfer. Possible values: **tax**, **fee**, **terminalSale**, **credit**, * **debit**, and **adjustment**. @@ -162,6 +188,15 @@ public static TypeEnum fromValue(String value) { public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetType = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + public BalanceTransferResponse() {} /** @@ -172,6 +207,7 @@ public BalanceTransferResponse() {} */ public BalanceTransferResponse amount(Amount amount) { this.amount = amount; + isSetAmount = true; // mark as set return this; } @@ -195,6 +231,7 @@ public Amount getAmount() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAmount(Amount amount) { this.amount = amount; + isSetAmount = true; // mark as set } /** @@ -205,6 +242,7 @@ public void setAmount(Amount amount) { */ public BalanceTransferResponse createdAt(OffsetDateTime createdAt) { this.createdAt = createdAt; + isSetCreatedAt = true; // mark as set return this; } @@ -228,6 +266,7 @@ public OffsetDateTime getCreatedAt() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreatedAt(OffsetDateTime createdAt) { this.createdAt = createdAt; + isSetCreatedAt = true; // mark as set } /** @@ -241,6 +280,7 @@ public void setCreatedAt(OffsetDateTime createdAt) { */ public BalanceTransferResponse description(String description) { this.description = description; + isSetDescription = true; // mark as set return this; } @@ -270,6 +310,7 @@ public String getDescription() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDescription(String description) { this.description = description; + isSetDescription = true; // mark as set } /** @@ -281,6 +322,7 @@ public void setDescription(String description) { */ public BalanceTransferResponse fromMerchant(String fromMerchant) { this.fromMerchant = fromMerchant; + isSetFromMerchant = true; // mark as set return this; } @@ -306,6 +348,7 @@ public String getFromMerchant() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setFromMerchant(String fromMerchant) { this.fromMerchant = fromMerchant; + isSetFromMerchant = true; // mark as set } /** @@ -317,6 +360,7 @@ public void setFromMerchant(String fromMerchant) { */ public BalanceTransferResponse pspReference(String pspReference) { this.pspReference = pspReference; + isSetPspReference = true; // mark as set return this; } @@ -342,6 +386,7 @@ public String getPspReference() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPspReference(String pspReference) { this.pspReference = pspReference; + isSetPspReference = true; // mark as set } /** @@ -354,6 +399,7 @@ public void setPspReference(String pspReference) { */ public BalanceTransferResponse reference(String reference) { this.reference = reference; + isSetReference = true; // mark as set return this; } @@ -381,6 +427,7 @@ public String getReference() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReference(String reference) { this.reference = reference; + isSetReference = true; // mark as set } /** @@ -393,6 +440,7 @@ public void setReference(String reference) { */ public BalanceTransferResponse status(StatusEnum status) { this.status = status; + isSetStatus = true; // mark as set return this; } @@ -420,6 +468,7 @@ public StatusEnum getStatus() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setStatus(StatusEnum status) { this.status = status; + isSetStatus = true; // mark as set } /** @@ -431,6 +480,7 @@ public void setStatus(StatusEnum status) { */ public BalanceTransferResponse toMerchant(String toMerchant) { this.toMerchant = toMerchant; + isSetToMerchant = true; // mark as set return this; } @@ -456,6 +506,7 @@ public String getToMerchant() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setToMerchant(String toMerchant) { this.toMerchant = toMerchant; + isSetToMerchant = true; // mark as set } /** @@ -468,6 +519,7 @@ public void setToMerchant(String toMerchant) { */ public BalanceTransferResponse type(TypeEnum type) { this.type = type; + isSetType = true; // mark as set return this; } @@ -495,6 +547,27 @@ public TypeEnum getType() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; + isSetType = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public BalanceTransferResponse includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; } /** Return true if this BalanceTransferResponse object is equal to o. */ @@ -508,28 +581,46 @@ public boolean equals(Object o) { } BalanceTransferResponse balanceTransferResponse = (BalanceTransferResponse) o; return Objects.equals(this.amount, balanceTransferResponse.amount) + && Objects.equals(this.isSetAmount, balanceTransferResponse.isSetAmount) && Objects.equals(this.createdAt, balanceTransferResponse.createdAt) + && Objects.equals(this.isSetCreatedAt, balanceTransferResponse.isSetCreatedAt) && Objects.equals(this.description, balanceTransferResponse.description) + && Objects.equals(this.isSetDescription, balanceTransferResponse.isSetDescription) && Objects.equals(this.fromMerchant, balanceTransferResponse.fromMerchant) + && Objects.equals(this.isSetFromMerchant, balanceTransferResponse.isSetFromMerchant) && Objects.equals(this.pspReference, balanceTransferResponse.pspReference) + && Objects.equals(this.isSetPspReference, balanceTransferResponse.isSetPspReference) && Objects.equals(this.reference, balanceTransferResponse.reference) + && Objects.equals(this.isSetReference, balanceTransferResponse.isSetReference) && Objects.equals(this.status, balanceTransferResponse.status) + && Objects.equals(this.isSetStatus, balanceTransferResponse.isSetStatus) && Objects.equals(this.toMerchant, balanceTransferResponse.toMerchant) - && Objects.equals(this.type, balanceTransferResponse.type); + && Objects.equals(this.isSetToMerchant, balanceTransferResponse.isSetToMerchant) + && Objects.equals(this.type, balanceTransferResponse.type) + && Objects.equals(this.isSetType, balanceTransferResponse.isSetType); } @Override public int hashCode() { return Objects.hash( amount, + isSetAmount, createdAt, + isSetCreatedAt, description, + isSetDescription, fromMerchant, + isSetFromMerchant, pspReference, + isSetPspReference, reference, + isSetReference, status, + isSetStatus, toMerchant, - type); + isSetToMerchant, + type, + isSetType); } @Override @@ -559,6 +650,54 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetAmount) { + addIfNull(nulls, JSON_PROPERTY_AMOUNT, this.amount); + } + if (isSetCreatedAt) { + addIfNull(nulls, JSON_PROPERTY_CREATED_AT, this.createdAt); + } + if (isSetDescription) { + addIfNull(nulls, JSON_PROPERTY_DESCRIPTION, this.description); + } + if (isSetFromMerchant) { + addIfNull(nulls, JSON_PROPERTY_FROM_MERCHANT, this.fromMerchant); + } + if (isSetPspReference) { + addIfNull(nulls, JSON_PROPERTY_PSP_REFERENCE, this.pspReference); + } + if (isSetReference) { + addIfNull(nulls, JSON_PROPERTY_REFERENCE, this.reference); + } + if (isSetStatus) { + addIfNull(nulls, JSON_PROPERTY_STATUS, this.status); + } + if (isSetToMerchant) { + addIfNull(nulls, JSON_PROPERTY_TO_MERCHANT, this.toMerchant); + } + if (isSetType) { + addIfNull(nulls, JSON_PROPERTY_TYPE, this.type); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + /** * Create an instance of BalanceTransferResponse given an JSON string * diff --git a/src/test/java/com/adyen/CheckoutTest.java b/src/test/java/com/adyen/CheckoutTest.java index b81e95531..396880cdc 100644 --- a/src/test/java/com/adyen/CheckoutTest.java +++ b/src/test/java/com/adyen/CheckoutTest.java @@ -889,7 +889,7 @@ public void testForwardCardDetails() throws Exception { CheckoutForwardResponse response = recurringApi.forward(checkoutForwardRequest); - assertNull(response.getStoredPaymentMethodId()); // card is not tokenized + assertNull(response.getStoredPaymentMethodId()); // card is not tokenized assertNotNull(response.getResponse()); assertEquals(200, (int) response.getResponse().getStatus()); assertTrue(response.getResponse().getBody().contains("PAYMENT_METHOD_ID"));