Skip to content

Commit bab80c7

Browse files
authored
Generate Balance Webhooks models (#1607)
* Generate BalanceWebhooks models * Add test of new event * Regenerate models
1 parent b6b004f commit bab80c7

File tree

7 files changed

+1245
-0
lines changed

7 files changed

+1245
-0
lines changed
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
/*
2+
* Balance webhook
3+
*
4+
* The version of the OpenAPI document: 1
5+
*
6+
*
7+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
8+
* https://openapi-generator.tech
9+
* Do not edit the class manually.
10+
*/
11+
12+
package com.adyen.model.balancewebhooks;
13+
14+
import com.fasterxml.jackson.annotation.JsonInclude;
15+
import com.fasterxml.jackson.annotation.JsonProperty;
16+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
17+
import com.fasterxml.jackson.core.JsonProcessingException;
18+
import java.util.*;
19+
20+
/** Amount */
21+
@JsonPropertyOrder({Amount.JSON_PROPERTY_CURRENCY, Amount.JSON_PROPERTY_VALUE})
22+
public class Amount {
23+
public static final String JSON_PROPERTY_CURRENCY = "currency";
24+
private String currency;
25+
26+
public static final String JSON_PROPERTY_VALUE = "value";
27+
private Long value;
28+
29+
public Amount() {}
30+
31+
/**
32+
* The three-character [ISO currency
33+
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
34+
* amount.
35+
*
36+
* @param currency The three-character [ISO currency
37+
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
38+
* amount.
39+
* @return the current {@code Amount} instance, allowing for method chaining
40+
*/
41+
public Amount currency(String currency) {
42+
this.currency = currency;
43+
return this;
44+
}
45+
46+
/**
47+
* The three-character [ISO currency
48+
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
49+
* amount.
50+
*
51+
* @return currency The three-character [ISO currency
52+
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
53+
* amount.
54+
*/
55+
@JsonProperty(JSON_PROPERTY_CURRENCY)
56+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
57+
public String getCurrency() {
58+
return currency;
59+
}
60+
61+
/**
62+
* The three-character [ISO currency
63+
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
64+
* amount.
65+
*
66+
* @param currency The three-character [ISO currency
67+
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
68+
* amount.
69+
*/
70+
@JsonProperty(JSON_PROPERTY_CURRENCY)
71+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
72+
public void setCurrency(String currency) {
73+
this.currency = currency;
74+
}
75+
76+
/**
77+
* The numeric value of the amount, in [minor
78+
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
79+
*
80+
* @param value The numeric value of the amount, in [minor
81+
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
82+
* @return the current {@code Amount} instance, allowing for method chaining
83+
*/
84+
public Amount value(Long value) {
85+
this.value = value;
86+
return this;
87+
}
88+
89+
/**
90+
* The numeric value of the amount, in [minor
91+
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
92+
*
93+
* @return value The numeric value of the amount, in [minor
94+
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
95+
*/
96+
@JsonProperty(JSON_PROPERTY_VALUE)
97+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
98+
public Long getValue() {
99+
return value;
100+
}
101+
102+
/**
103+
* The numeric value of the amount, in [minor
104+
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
105+
*
106+
* @param value The numeric value of the amount, in [minor
107+
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
108+
*/
109+
@JsonProperty(JSON_PROPERTY_VALUE)
110+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
111+
public void setValue(Long value) {
112+
this.value = value;
113+
}
114+
115+
/** Return true if this Amount object is equal to o. */
116+
@Override
117+
public boolean equals(Object o) {
118+
if (this == o) {
119+
return true;
120+
}
121+
if (o == null || getClass() != o.getClass()) {
122+
return false;
123+
}
124+
Amount amount = (Amount) o;
125+
return Objects.equals(this.currency, amount.currency)
126+
&& Objects.equals(this.value, amount.value);
127+
}
128+
129+
@Override
130+
public int hashCode() {
131+
return Objects.hash(currency, value);
132+
}
133+
134+
@Override
135+
public String toString() {
136+
StringBuilder sb = new StringBuilder();
137+
sb.append("class Amount {\n");
138+
sb.append(" currency: ").append(toIndentedString(currency)).append("\n");
139+
sb.append(" value: ").append(toIndentedString(value)).append("\n");
140+
sb.append("}");
141+
return sb.toString();
142+
}
143+
144+
/**
145+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
146+
*/
147+
private String toIndentedString(Object o) {
148+
if (o == null) {
149+
return "null";
150+
}
151+
return o.toString().replace("\n", "\n ");
152+
}
153+
154+
/**
155+
* Create an instance of Amount given an JSON string
156+
*
157+
* @param jsonString JSON string
158+
* @return An instance of Amount
159+
* @throws JsonProcessingException if the JSON string is invalid with respect to Amount
160+
*/
161+
public static Amount fromJson(String jsonString) throws JsonProcessingException {
162+
return JSON.getMapper().readValue(jsonString, Amount.class);
163+
}
164+
165+
/**
166+
* Convert an instance of Amount to an JSON string
167+
*
168+
* @return JSON string
169+
*/
170+
public String toJson() throws JsonProcessingException {
171+
return JSON.getMapper().writeValueAsString(this);
172+
}
173+
}

src/main/java/com/adyen/model/balancewebhooks/BalanceWebhooksHandler.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,30 @@ public BalanceWebhooksHandler(String payload) {
5858
return Optional.empty();
5959
}
6060

61+
/**
62+
* Attempts to deserialize the webhook payload into a ReleasedBlockedBalanceNotificationRequest
63+
*
64+
* @return an Optional containing the deserialized object, or empty if deserialization fails
65+
*/
66+
public Optional<ReleasedBlockedBalanceNotificationRequest>
67+
getReleasedBlockedBalanceNotificationRequest() {
68+
69+
var optionalReleasedBlockedBalanceNotificationRequest =
70+
getOptionalField(ReleasedBlockedBalanceNotificationRequest.class);
71+
72+
if (optionalReleasedBlockedBalanceNotificationRequest.isPresent()) {
73+
// verify event type
74+
for (var value : ReleasedBlockedBalanceNotificationRequest.TypeEnum.values()) {
75+
if (value.equals(optionalReleasedBlockedBalanceNotificationRequest.get().getType())) {
76+
// found matching event type
77+
return optionalReleasedBlockedBalanceNotificationRequest;
78+
}
79+
}
80+
}
81+
82+
return Optional.empty();
83+
}
84+
6185
/**
6286
* Deserializes the payload into the specified class type.
6387
*

0 commit comments

Comments
 (0)