• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Adyen / adyen-java-api-library / #2934

11 Dec 2023 05:06PM CUT coverage: 12.835%. First build
#2934

push

web-flow
Merge 0111dd892 into d70611050

173 of 797 new or added lines in 39 files covered. (21.71%)

12464 of 97111 relevant lines covered (12.83%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.52
/src/main/java/com/adyen/service/balanceplatform/BalanceAccountsApi.java
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.service.balanceplatform;
13

14
import com.adyen.Client;
15
import com.adyen.Service;
16
import com.adyen.constants.ApiConstants;
17
import com.adyen.model.balanceplatform.BalanceAccount;
18
import com.adyen.model.balanceplatform.BalanceAccountInfo;
19
import com.adyen.model.balanceplatform.BalanceAccountUpdateRequest;
20
import com.adyen.model.balanceplatform.BalanceSweepConfigurationsResponse;
21
import com.adyen.model.balanceplatform.CreateSweepConfigurationV2;
22
import com.adyen.model.balanceplatform.PaginatedPaymentInstrumentsResponse;
23
import com.adyen.model.balanceplatform.RestServiceError;
24
import com.adyen.model.balanceplatform.SweepConfigurationV2;
25
import com.adyen.model.balanceplatform.UpdateSweepConfigurationV2;
26
import com.adyen.model.RequestOptions;
27
import com.adyen.service.exception.ApiException;
28
import com.adyen.service.resource.Resource;
29

30
import java.io.IOException;
31
import java.util.HashMap;
32
import java.util.Map;
33

34
public class BalanceAccountsApi extends Service {
35

36
    public static final String API_VERSION = "2";
37

38
    protected String baseURL;
39

40
    /**
41
    * Balance accounts constructor in {@link com.adyen.service.balanceplatform package}.
42
    * @param client {@link Client } (required)
43
    */
44
    public BalanceAccountsApi(Client client) {
45
        super(client);
1✔
46
        this.baseURL = createBaseURL("https://balanceplatform-api-test.adyen.com/bcl/v2");
1✔
47
    }
1✔
48

49
    /**
50
    * Balance accounts constructor in {@link com.adyen.service.balanceplatform package}.
51
    * Please use this constructor only if you would like to pass along your own url for routing or testing purposes. The latest API version is defined in this class as a constant.
52
    * @param client {@link Client } (required)
53
    * @param baseURL {@link String } (required)
54
    */
55
    public BalanceAccountsApi(Client client, String baseURL) {
56
        super(client);
×
57
        this.baseURL = baseURL;
×
58
    }
×
59

60
    /**
61
    * Create a balance account
62
    *
63
    * @param balanceAccountInfo {@link BalanceAccountInfo }  (required)
64
    * @return {@link BalanceAccount }
65
    * @throws ApiException if fails to make API call
66
    */
67
    public BalanceAccount createBalanceAccount(BalanceAccountInfo balanceAccountInfo) throws ApiException, IOException {
68
        return createBalanceAccount(balanceAccountInfo, null);
1✔
69
    }
70

71
    /**
72
    * Create a balance account
73
    *
74
    * @param balanceAccountInfo {@link BalanceAccountInfo }  (required)
75
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
76
    * @return {@link BalanceAccount }
77
    * @throws ApiException if fails to make API call
78
    */
79
    public BalanceAccount createBalanceAccount(BalanceAccountInfo balanceAccountInfo, RequestOptions requestOptions) throws ApiException, IOException {
80

81
        String requestBody = balanceAccountInfo.toJson();
1✔
82
        Resource resource = new Resource(this, this.baseURL + "/balanceAccounts", null);
1✔
83
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, null);
1✔
84
        return BalanceAccount.fromJson(jsonResult);
1✔
85
    }
86

87
    /**
88
    * Create a sweep
89
    *
90
    * @param balanceAccountId {@link String } The unique identifier of the balance account. (required)
91
    * @param createSweepConfigurationV2 {@link CreateSweepConfigurationV2 }  (required)
92
    * @return {@link SweepConfigurationV2 }
93
    * @throws ApiException if fails to make API call
94
    */
95
    public SweepConfigurationV2 createSweep(String balanceAccountId, CreateSweepConfigurationV2 createSweepConfigurationV2) throws ApiException, IOException {
96
        return createSweep(balanceAccountId, createSweepConfigurationV2, null);
1✔
97
    }
98

99
    /**
100
    * Create a sweep
101
    *
102
    * @param balanceAccountId {@link String } The unique identifier of the balance account. (required)
103
    * @param createSweepConfigurationV2 {@link CreateSweepConfigurationV2 }  (required)
104
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
105
    * @return {@link SweepConfigurationV2 }
106
    * @throws ApiException if fails to make API call
107
    */
108
    public SweepConfigurationV2 createSweep(String balanceAccountId, CreateSweepConfigurationV2 createSweepConfigurationV2, RequestOptions requestOptions) throws ApiException, IOException {
109
        //Add path params
110
        Map<String, String> pathParams = new HashMap<>();
1✔
111
        if (balanceAccountId == null) {
1✔
NEW
112
            throw new IllegalArgumentException("Please provide the balanceAccountId path parameter");
×
113
        }
114
        pathParams.put("balanceAccountId", balanceAccountId);
1✔
115

116
        String requestBody = createSweepConfigurationV2.toJson();
1✔
117
        Resource resource = new Resource(this, this.baseURL + "/balanceAccounts/{balanceAccountId}/sweeps", null);
1✔
118
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, pathParams);
1✔
119
        return SweepConfigurationV2.fromJson(jsonResult);
1✔
120
    }
121

122
    /**
123
    * Delete a sweep
124
    *
125
    * @param balanceAccountId {@link String } The unique identifier of the balance account. (required)
126
    * @param sweepId {@link String } The unique identifier of the sweep. (required)
127
    * @throws ApiException if fails to make API call
128
    */
129
    public void deleteSweep(String balanceAccountId, String sweepId) throws ApiException, IOException {
130
        deleteSweep(balanceAccountId, sweepId, null);
1✔
131
    }
1✔
132

133
    /**
134
    * Delete a sweep
135
    *
136
    * @param balanceAccountId {@link String } The unique identifier of the balance account. (required)
137
    * @param sweepId {@link String } The unique identifier of the sweep. (required)
138
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
139
    * @throws ApiException if fails to make API call
140
    */
141
    public void deleteSweep(String balanceAccountId, String sweepId, RequestOptions requestOptions) throws ApiException, IOException {
142
        //Add path params
143
        Map<String, String> pathParams = new HashMap<>();
1✔
144
        if (balanceAccountId == null) {
1✔
145
            throw new IllegalArgumentException("Please provide the balanceAccountId path parameter");
×
146
        }
147
        pathParams.put("balanceAccountId", balanceAccountId);
1✔
148
        if (sweepId == null) {
1✔
149
            throw new IllegalArgumentException("Please provide the sweepId path parameter");
×
150
        }
151
        pathParams.put("sweepId", sweepId);
1✔
152

153
        String requestBody = null;
1✔
154
        Resource resource = new Resource(this, this.baseURL + "/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", null);
1✔
155
        resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.DELETE, pathParams);
1✔
156
    }
1✔
157

158
    /**
159
    * Get all payment instruments for a balance account
160
    *
161
    * @param id {@link String } The unique identifier of the balance account. (required)
162
    * @return {@link PaginatedPaymentInstrumentsResponse }
163
    * @throws ApiException if fails to make API call
164
    */
165
    public PaginatedPaymentInstrumentsResponse getAllPaymentInstrumentsForBalanceAccount(String id) throws ApiException, IOException {
166
        return getAllPaymentInstrumentsForBalanceAccount(id, null,  null,  null);
1✔
167
    }
168

169
    /**
170
    * Get all payment instruments for a balance account
171
    *
172
    * @param id {@link String } The unique identifier of the balance account. (required)
173
    * @param offset {@link Integer } Query: The number of items that you want to skip. (optional)
174
    * @param limit {@link Integer } Query: The number of items returned per page, maximum 100 items. By default, the response returns 10 items per page. (optional)
175
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
176
    * @return {@link PaginatedPaymentInstrumentsResponse }
177
    * @throws ApiException if fails to make API call
178
    */
179
    public PaginatedPaymentInstrumentsResponse getAllPaymentInstrumentsForBalanceAccount(String id, Integer offset, Integer limit, RequestOptions requestOptions) throws ApiException, IOException {
180
        //Add path params
181
        Map<String, String> pathParams = new HashMap<>();
1✔
182
        if (id == null) {
1✔
NEW
183
            throw new IllegalArgumentException("Please provide the id path parameter");
×
184
        }
185
        pathParams.put("id", id);
1✔
186
        //Add query params
187
        Map<String, String> queryParams = new HashMap<>();
1✔
188
        if (offset != null) {
1✔
189
        queryParams.put("offset", offset.toString());
×
190
        }
191
        if (limit != null) {
1✔
192
        queryParams.put("limit", limit.toString());
×
193
        }
194

195
        String requestBody = null;
1✔
196
        Resource resource = new Resource(this, this.baseURL + "/balanceAccounts/{id}/paymentInstruments", null);
1✔
197
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.GET, pathParams, queryParams);
1✔
198
        return PaginatedPaymentInstrumentsResponse.fromJson(jsonResult);
1✔
199
    }
200

201
    /**
202
    * Get all sweeps for a balance account
203
    *
204
    * @param balanceAccountId {@link String } The unique identifier of the balance account. (required)
205
    * @return {@link BalanceSweepConfigurationsResponse }
206
    * @throws ApiException if fails to make API call
207
    */
208
    public BalanceSweepConfigurationsResponse getAllSweepsForBalanceAccount(String balanceAccountId) throws ApiException, IOException {
209
        return getAllSweepsForBalanceAccount(balanceAccountId, null,  null,  null);
1✔
210
    }
211

212
    /**
213
    * Get all sweeps for a balance account
214
    *
215
    * @param balanceAccountId {@link String } The unique identifier of the balance account. (required)
216
    * @param offset {@link Integer } Query: The number of items that you want to skip. (optional)
217
    * @param limit {@link Integer } Query: The number of items returned per page, maximum 100 items. By default, the response returns 10 items per page. (optional)
218
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
219
    * @return {@link BalanceSweepConfigurationsResponse }
220
    * @throws ApiException if fails to make API call
221
    */
222
    public BalanceSweepConfigurationsResponse getAllSweepsForBalanceAccount(String balanceAccountId, Integer offset, Integer limit, RequestOptions requestOptions) throws ApiException, IOException {
223
        //Add path params
224
        Map<String, String> pathParams = new HashMap<>();
1✔
225
        if (balanceAccountId == null) {
1✔
226
            throw new IllegalArgumentException("Please provide the balanceAccountId path parameter");
×
227
        }
228
        pathParams.put("balanceAccountId", balanceAccountId);
1✔
229
        //Add query params
230
        Map<String, String> queryParams = new HashMap<>();
1✔
231
        if (offset != null) {
1✔
NEW
232
        queryParams.put("offset", offset.toString());
×
233
        }
234
        if (limit != null) {
1✔
NEW
235
        queryParams.put("limit", limit.toString());
×
236
        }
237

238
        String requestBody = null;
1✔
239
        Resource resource = new Resource(this, this.baseURL + "/balanceAccounts/{balanceAccountId}/sweeps", null);
1✔
240
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.GET, pathParams, queryParams);
1✔
241
        return BalanceSweepConfigurationsResponse.fromJson(jsonResult);
1✔
242
    }
243

244
    /**
245
    * Get a balance account
246
    *
247
    * @param id {@link String } The unique identifier of the balance account. (required)
248
    * @return {@link BalanceAccount }
249
    * @throws ApiException if fails to make API call
250
    */
251
    public BalanceAccount getBalanceAccount(String id) throws ApiException, IOException {
252
        return getBalanceAccount(id, null);
1✔
253
    }
254

255
    /**
256
    * Get a balance account
257
    *
258
    * @param id {@link String } The unique identifier of the balance account. (required)
259
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
260
    * @return {@link BalanceAccount }
261
    * @throws ApiException if fails to make API call
262
    */
263
    public BalanceAccount getBalanceAccount(String id, RequestOptions requestOptions) throws ApiException, IOException {
264
        //Add path params
265
        Map<String, String> pathParams = new HashMap<>();
1✔
266
        if (id == null) {
1✔
267
            throw new IllegalArgumentException("Please provide the id path parameter");
×
268
        }
269
        pathParams.put("id", id);
1✔
270

271
        String requestBody = null;
1✔
272
        Resource resource = new Resource(this, this.baseURL + "/balanceAccounts/{id}", null);
1✔
273
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.GET, pathParams);
1✔
274
        return BalanceAccount.fromJson(jsonResult);
1✔
275
    }
276

277
    /**
278
    * Get a sweep
279
    *
280
    * @param balanceAccountId {@link String } The unique identifier of the balance account. (required)
281
    * @param sweepId {@link String } The unique identifier of the sweep. (required)
282
    * @return {@link SweepConfigurationV2 }
283
    * @throws ApiException if fails to make API call
284
    */
285
    public SweepConfigurationV2 getSweep(String balanceAccountId, String sweepId) throws ApiException, IOException {
286
        return getSweep(balanceAccountId, sweepId, null);
1✔
287
    }
288

289
    /**
290
    * Get a sweep
291
    *
292
    * @param balanceAccountId {@link String } The unique identifier of the balance account. (required)
293
    * @param sweepId {@link String } The unique identifier of the sweep. (required)
294
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
295
    * @return {@link SweepConfigurationV2 }
296
    * @throws ApiException if fails to make API call
297
    */
298
    public SweepConfigurationV2 getSweep(String balanceAccountId, String sweepId, RequestOptions requestOptions) throws ApiException, IOException {
299
        //Add path params
300
        Map<String, String> pathParams = new HashMap<>();
1✔
301
        if (balanceAccountId == null) {
1✔
302
            throw new IllegalArgumentException("Please provide the balanceAccountId path parameter");
×
303
        }
304
        pathParams.put("balanceAccountId", balanceAccountId);
1✔
305
        if (sweepId == null) {
1✔
306
            throw new IllegalArgumentException("Please provide the sweepId path parameter");
×
307
        }
308
        pathParams.put("sweepId", sweepId);
1✔
309

310
        String requestBody = null;
1✔
311
        Resource resource = new Resource(this, this.baseURL + "/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", null);
1✔
312
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.GET, pathParams);
1✔
313
        return SweepConfigurationV2.fromJson(jsonResult);
1✔
314
    }
315

316
    /**
317
    * Update a balance account
318
    *
319
    * @param id {@link String } The unique identifier of the balance account. (required)
320
    * @param balanceAccountUpdateRequest {@link BalanceAccountUpdateRequest }  (required)
321
    * @return {@link BalanceAccount }
322
    * @throws ApiException if fails to make API call
323
    */
324
    public BalanceAccount updateBalanceAccount(String id, BalanceAccountUpdateRequest balanceAccountUpdateRequest) throws ApiException, IOException {
325
        return updateBalanceAccount(id, balanceAccountUpdateRequest, null);
1✔
326
    }
327

328
    /**
329
    * Update a balance account
330
    *
331
    * @param id {@link String } The unique identifier of the balance account. (required)
332
    * @param balanceAccountUpdateRequest {@link BalanceAccountUpdateRequest }  (required)
333
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
334
    * @return {@link BalanceAccount }
335
    * @throws ApiException if fails to make API call
336
    */
337
    public BalanceAccount updateBalanceAccount(String id, BalanceAccountUpdateRequest balanceAccountUpdateRequest, RequestOptions requestOptions) throws ApiException, IOException {
338
        //Add path params
339
        Map<String, String> pathParams = new HashMap<>();
1✔
340
        if (id == null) {
1✔
341
            throw new IllegalArgumentException("Please provide the id path parameter");
×
342
        }
343
        pathParams.put("id", id);
1✔
344

345
        String requestBody = balanceAccountUpdateRequest.toJson();
1✔
346
        Resource resource = new Resource(this, this.baseURL + "/balanceAccounts/{id}", null);
1✔
347
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.PATCH, pathParams);
1✔
348
        return BalanceAccount.fromJson(jsonResult);
1✔
349
    }
350

351
    /**
352
    * Update a sweep
353
    *
354
    * @param balanceAccountId {@link String } The unique identifier of the balance account. (required)
355
    * @param sweepId {@link String } The unique identifier of the sweep. (required)
356
    * @param updateSweepConfigurationV2 {@link UpdateSweepConfigurationV2 }  (required)
357
    * @return {@link SweepConfigurationV2 }
358
    * @throws ApiException if fails to make API call
359
    */
360
    public SweepConfigurationV2 updateSweep(String balanceAccountId, String sweepId, UpdateSweepConfigurationV2 updateSweepConfigurationV2) throws ApiException, IOException {
361
        return updateSweep(balanceAccountId, sweepId, updateSweepConfigurationV2, null);
1✔
362
    }
363

364
    /**
365
    * Update a sweep
366
    *
367
    * @param balanceAccountId {@link String } The unique identifier of the balance account. (required)
368
    * @param sweepId {@link String } The unique identifier of the sweep. (required)
369
    * @param updateSweepConfigurationV2 {@link UpdateSweepConfigurationV2 }  (required)
370
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
371
    * @return {@link SweepConfigurationV2 }
372
    * @throws ApiException if fails to make API call
373
    */
374
    public SweepConfigurationV2 updateSweep(String balanceAccountId, String sweepId, UpdateSweepConfigurationV2 updateSweepConfigurationV2, RequestOptions requestOptions) throws ApiException, IOException {
375
        //Add path params
376
        Map<String, String> pathParams = new HashMap<>();
1✔
377
        if (balanceAccountId == null) {
1✔
378
            throw new IllegalArgumentException("Please provide the balanceAccountId path parameter");
×
379
        }
380
        pathParams.put("balanceAccountId", balanceAccountId);
1✔
381
        if (sweepId == null) {
1✔
NEW
382
            throw new IllegalArgumentException("Please provide the sweepId path parameter");
×
383
        }
384
        pathParams.put("sweepId", sweepId);
1✔
385

386
        String requestBody = updateSweepConfigurationV2.toJson();
1✔
387
        Resource resource = new Resource(this, this.baseURL + "/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", null);
1✔
388
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.PATCH, pathParams);
1✔
389
        return SweepConfigurationV2.fromJson(jsonResult);
1✔
390
    }
391
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc