Skip to content

Commit 671ca0c

Browse files
authored
Add support for WWW-Authenticate header (SCA associations management) (#1585)
* Refactor templates * Add support for WWW-Authenticate header * Generate BalancePlatform services/models * Add tests * Test response headers in exception
1 parent 4257995 commit 671ca0c

40 files changed

+3761
-83
lines changed

src/main/java/com/adyen/constants/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ interface RequestProperty {
109109
String API_KEY = "x-api-key";
110110
String APPLICATION_JSON_TYPE = "application/json";
111111
String REQUESTED_VERIFICATION_CODE_HEADER = "x-requested-verification-code";
112+
String WWW_AUTHENTICATE_HEADER = "WWW-Authenticate";
112113
}
113114

114115
interface ThreeDS2Property {

src/main/java/com/adyen/httpclient/AdyenHttpClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import static com.adyen.constants.ApiConstants.RequestProperty.IDEMPOTENCY_KEY;
3131
import static com.adyen.constants.ApiConstants.RequestProperty.REQUESTED_VERIFICATION_CODE_HEADER;
3232
import static com.adyen.constants.ApiConstants.RequestProperty.USER_AGENT;
33+
import static com.adyen.constants.ApiConstants.RequestProperty.WWW_AUTHENTICATE_HEADER;
3334

3435
import com.adyen.Client;
3536
import com.adyen.Config;
@@ -199,6 +200,10 @@ private void setHeaders(
199200
REQUESTED_VERIFICATION_CODE_HEADER,
200201
requestOptions.getRequestedVerificationCodeHeader());
201202
}
203+
if (requestOptions.getWwwAuthenticateHeader() != null) {
204+
httpUriRequest.addHeader(
205+
WWW_AUTHENTICATE_HEADER, requestOptions.getWwwAuthenticateHeader());
206+
}
202207

203208
if (requestOptions.getAdditionalServiceHeaders() != null) {
204209
requestOptions.getAdditionalServiceHeaders().forEach(httpUriRequest::addHeader);

src/main/java/com/adyen/model/RequestOptions.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
public class RequestOptions {
66
private String idempotencyKey;
77
private String requestedVerificationCodeHeader;
8+
private String wwwAuthenticateHeader;
89
private HashMap<String, String> additionalServiceHeaders;
910

1011
public RequestOptions idempotencyKey(String idempotencyKey) {
@@ -17,11 +18,24 @@ public RequestOptions requestedVerificationCodeHeader(String requestedVerificati
1718
return this;
1819
}
1920

21+
public RequestOptions wwwAuthenticateHeader(String wwwAuthenticateHeader) {
22+
this.wwwAuthenticateHeader = wwwAuthenticateHeader;
23+
return this;
24+
}
25+
2026
public RequestOptions additionalServiceHeaders(HashMap<String, String> additionalServiceHeaders) {
2127
this.additionalServiceHeaders = additionalServiceHeaders;
2228
return this;
2329
}
2430

31+
public RequestOptions addAdditionalServiceHeader(String key, String value) {
32+
if (this.additionalServiceHeaders == null) {
33+
this.additionalServiceHeaders = new HashMap<>();
34+
}
35+
this.additionalServiceHeaders.put(key, value);
36+
return this;
37+
}
38+
2539
public String getIdempotencyKey() {
2640
return idempotencyKey;
2741
}
@@ -46,6 +60,14 @@ public void setAdditionalServiceHeaders(HashMap<String, String> additionalServic
4660
this.additionalServiceHeaders = additionalServiceHeaders;
4761
}
4862

63+
public String getWwwAuthenticateHeader() {
64+
return wwwAuthenticateHeader;
65+
}
66+
67+
public void setWwwAuthenticateHeader(String wwwAuthenticateHeader) {
68+
this.wwwAuthenticateHeader = wwwAuthenticateHeader;
69+
}
70+
4971
@Override
5072
public String toString() {
5173
return "RequestOptions{"
@@ -55,6 +77,9 @@ public String toString() {
5577
+ ", requestedVerificationCodeHeader='"
5678
+ requestedVerificationCodeHeader
5779
+ '\''
80+
+ ", wwwAuthenticateHeader='"
81+
+ wwwAuthenticateHeader
82+
+ '\''
5883
+ ", additionalServiceHeaders="
5984
+ additionalServiceHeaders
6085
+ '}';
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
/*
2+
* Configuration API
3+
*
4+
* The version of the OpenAPI document: 2
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.balanceplatform;
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+
import java.util.ArrayList;
20+
import java.util.List;
21+
22+
/** ApproveAssociationRequest */
23+
@JsonPropertyOrder({
24+
ApproveAssociationRequest.JSON_PROPERTY_ENTITY_ID,
25+
ApproveAssociationRequest.JSON_PROPERTY_ENTITY_TYPE,
26+
ApproveAssociationRequest.JSON_PROPERTY_SCA_DEVICE_IDS,
27+
ApproveAssociationRequest.JSON_PROPERTY_STATUS
28+
})
29+
public class ApproveAssociationRequest {
30+
public static final String JSON_PROPERTY_ENTITY_ID = "entityId";
31+
private String entityId;
32+
33+
public static final String JSON_PROPERTY_ENTITY_TYPE = "entityType";
34+
private ScaEntityType entityType;
35+
36+
public static final String JSON_PROPERTY_SCA_DEVICE_IDS = "scaDeviceIds";
37+
private List<String> scaDeviceIds;
38+
39+
public static final String JSON_PROPERTY_STATUS = "status";
40+
private AssociationStatus status;
41+
42+
public ApproveAssociationRequest() {}
43+
44+
/**
45+
* The unique identifier of the entity.
46+
*
47+
* @param entityId The unique identifier of the entity.
48+
* @return the current {@code ApproveAssociationRequest} instance, allowing for method chaining
49+
*/
50+
public ApproveAssociationRequest entityId(String entityId) {
51+
this.entityId = entityId;
52+
return this;
53+
}
54+
55+
/**
56+
* The unique identifier of the entity.
57+
*
58+
* @return entityId The unique identifier of the entity.
59+
*/
60+
@JsonProperty(JSON_PROPERTY_ENTITY_ID)
61+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
62+
public String getEntityId() {
63+
return entityId;
64+
}
65+
66+
/**
67+
* The unique identifier of the entity.
68+
*
69+
* @param entityId The unique identifier of the entity.
70+
*/
71+
@JsonProperty(JSON_PROPERTY_ENTITY_ID)
72+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
73+
public void setEntityId(String entityId) {
74+
this.entityId = entityId;
75+
}
76+
77+
/**
78+
* entityType
79+
*
80+
* @param entityType
81+
* @return the current {@code ApproveAssociationRequest} instance, allowing for method chaining
82+
*/
83+
public ApproveAssociationRequest entityType(ScaEntityType entityType) {
84+
this.entityType = entityType;
85+
return this;
86+
}
87+
88+
/**
89+
* Get entityType
90+
*
91+
* @return entityType
92+
*/
93+
@JsonProperty(JSON_PROPERTY_ENTITY_TYPE)
94+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
95+
public ScaEntityType getEntityType() {
96+
return entityType;
97+
}
98+
99+
/**
100+
* entityType
101+
*
102+
* @param entityType
103+
*/
104+
@JsonProperty(JSON_PROPERTY_ENTITY_TYPE)
105+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
106+
public void setEntityType(ScaEntityType entityType) {
107+
this.entityType = entityType;
108+
}
109+
110+
/**
111+
* List of device ids associated to the entity that will be approved.
112+
*
113+
* @param scaDeviceIds List of device ids associated to the entity that will be approved.
114+
* @return the current {@code ApproveAssociationRequest} instance, allowing for method chaining
115+
*/
116+
public ApproveAssociationRequest scaDeviceIds(List<String> scaDeviceIds) {
117+
this.scaDeviceIds = scaDeviceIds;
118+
return this;
119+
}
120+
121+
public ApproveAssociationRequest addScaDeviceIdsItem(String scaDeviceIdsItem) {
122+
if (this.scaDeviceIds == null) {
123+
this.scaDeviceIds = new ArrayList<>();
124+
}
125+
this.scaDeviceIds.add(scaDeviceIdsItem);
126+
return this;
127+
}
128+
129+
/**
130+
* List of device ids associated to the entity that will be approved.
131+
*
132+
* @return scaDeviceIds List of device ids associated to the entity that will be approved.
133+
*/
134+
@JsonProperty(JSON_PROPERTY_SCA_DEVICE_IDS)
135+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
136+
public List<String> getScaDeviceIds() {
137+
return scaDeviceIds;
138+
}
139+
140+
/**
141+
* List of device ids associated to the entity that will be approved.
142+
*
143+
* @param scaDeviceIds List of device ids associated to the entity that will be approved.
144+
*/
145+
@JsonProperty(JSON_PROPERTY_SCA_DEVICE_IDS)
146+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
147+
public void setScaDeviceIds(List<String> scaDeviceIds) {
148+
this.scaDeviceIds = scaDeviceIds;
149+
}
150+
151+
/**
152+
* status
153+
*
154+
* @param status
155+
* @return the current {@code ApproveAssociationRequest} instance, allowing for method chaining
156+
*/
157+
public ApproveAssociationRequest status(AssociationStatus status) {
158+
this.status = status;
159+
return this;
160+
}
161+
162+
/**
163+
* Get status
164+
*
165+
* @return status
166+
*/
167+
@JsonProperty(JSON_PROPERTY_STATUS)
168+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
169+
public AssociationStatus getStatus() {
170+
return status;
171+
}
172+
173+
/**
174+
* status
175+
*
176+
* @param status
177+
*/
178+
@JsonProperty(JSON_PROPERTY_STATUS)
179+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
180+
public void setStatus(AssociationStatus status) {
181+
this.status = status;
182+
}
183+
184+
/** Return true if this ApproveAssociationRequest object is equal to o. */
185+
@Override
186+
public boolean equals(Object o) {
187+
if (this == o) {
188+
return true;
189+
}
190+
if (o == null || getClass() != o.getClass()) {
191+
return false;
192+
}
193+
ApproveAssociationRequest approveAssociationRequest = (ApproveAssociationRequest) o;
194+
return Objects.equals(this.entityId, approveAssociationRequest.entityId)
195+
&& Objects.equals(this.entityType, approveAssociationRequest.entityType)
196+
&& Objects.equals(this.scaDeviceIds, approveAssociationRequest.scaDeviceIds)
197+
&& Objects.equals(this.status, approveAssociationRequest.status);
198+
}
199+
200+
@Override
201+
public int hashCode() {
202+
return Objects.hash(entityId, entityType, scaDeviceIds, status);
203+
}
204+
205+
@Override
206+
public String toString() {
207+
StringBuilder sb = new StringBuilder();
208+
sb.append("class ApproveAssociationRequest {\n");
209+
sb.append(" entityId: ").append(toIndentedString(entityId)).append("\n");
210+
sb.append(" entityType: ").append(toIndentedString(entityType)).append("\n");
211+
sb.append(" scaDeviceIds: ").append(toIndentedString(scaDeviceIds)).append("\n");
212+
sb.append(" status: ").append(toIndentedString(status)).append("\n");
213+
sb.append("}");
214+
return sb.toString();
215+
}
216+
217+
/**
218+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
219+
*/
220+
private String toIndentedString(Object o) {
221+
if (o == null) {
222+
return "null";
223+
}
224+
return o.toString().replace("\n", "\n ");
225+
}
226+
227+
/**
228+
* Create an instance of ApproveAssociationRequest given an JSON string
229+
*
230+
* @param jsonString JSON string
231+
* @return An instance of ApproveAssociationRequest
232+
* @throws JsonProcessingException if the JSON string is invalid with respect to
233+
* ApproveAssociationRequest
234+
*/
235+
public static ApproveAssociationRequest fromJson(String jsonString)
236+
throws JsonProcessingException {
237+
return JSON.getMapper().readValue(jsonString, ApproveAssociationRequest.class);
238+
}
239+
240+
/**
241+
* Convert an instance of ApproveAssociationRequest to an JSON string
242+
*
243+
* @return JSON string
244+
*/
245+
public String toJson() throws JsonProcessingException {
246+
return JSON.getMapper().writeValueAsString(this);
247+
}
248+
}

0 commit comments

Comments
 (0)