• 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

0.0
/src/main/java/com/adyen/service/management/WebhooksMerchantLevelApi.java
1
/*
2
 * Management API
3
 *
4
 * The version of the OpenAPI document: 3
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.management;
13

14
import com.adyen.Client;
15
import com.adyen.Service;
16
import com.adyen.constants.ApiConstants;
17
import com.adyen.model.management.CreateMerchantWebhookRequest;
18
import com.adyen.model.management.GenerateHmacKeyResponse;
19
import com.adyen.model.management.ListWebhooksResponse;
20
import com.adyen.model.management.RestServiceError;
21
import com.adyen.model.management.TestWebhookRequest;
22
import com.adyen.model.management.TestWebhookResponse;
23
import com.adyen.model.management.UpdateMerchantWebhookRequest;
24
import com.adyen.model.management.Webhook;
25
import com.adyen.model.RequestOptions;
26
import com.adyen.service.exception.ApiException;
27
import com.adyen.service.resource.Resource;
28

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

33
public class WebhooksMerchantLevelApi extends Service {
34

35
    public static final String API_VERSION = "3";
36

37
    protected String baseURL;
38

39
    /**
40
    *  constructor in {@link com.adyen.service.management package}.
41
    * @param client {@link Client } (required)
42
    */
43
    public WebhooksMerchantLevelApi(Client client) {
44
        super(client);
×
45
        this.baseURL = createBaseURL("https://management-test.adyen.com/v3");
×
46
    }
×
47

48
    /**
49
    *  constructor in {@link com.adyen.service.management package}.
50
    * 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.
51
    * @param client {@link Client } (required)
52
    * @param baseURL {@link String } (required)
53
    */
54
    public WebhooksMerchantLevelApi(Client client, String baseURL) {
55
        super(client);
×
56
        this.baseURL = baseURL;
×
57
    }
×
58

59
    /**
60
    * Generate an HMAC key
61
    *
62
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
63
    * @param webhookId {@link String }  (required)
64
    * @return {@link GenerateHmacKeyResponse }
65
    * @throws ApiException if fails to make API call
66
    */
67
    public GenerateHmacKeyResponse generateHmacKey(String merchantId, String webhookId) throws ApiException, IOException {
NEW
68
        return generateHmacKey(merchantId, webhookId, null);
×
69
    }
70

71
    /**
72
    * Generate an HMAC key
73
    *
74
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
75
    * @param webhookId {@link String }  (required)
76
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
77
    * @return {@link GenerateHmacKeyResponse }
78
    * @throws ApiException if fails to make API call
79
    */
80
    public GenerateHmacKeyResponse generateHmacKey(String merchantId, String webhookId, RequestOptions requestOptions) throws ApiException, IOException {
81
        //Add path params
82
        Map<String, String> pathParams = new HashMap<>();
×
83
        if (merchantId == null) {
×
84
            throw new IllegalArgumentException("Please provide the merchantId path parameter");
×
85
        }
86
        pathParams.put("merchantId", merchantId);
×
87
        if (webhookId == null) {
×
88
            throw new IllegalArgumentException("Please provide the webhookId path parameter");
×
89
        }
90
        pathParams.put("webhookId", webhookId);
×
91

92
        String requestBody = null;
×
NEW
93
        Resource resource = new Resource(this, this.baseURL + "/merchants/{merchantId}/webhooks/{webhookId}/generateHmac", null);
×
NEW
94
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, pathParams);
×
NEW
95
        return GenerateHmacKeyResponse.fromJson(jsonResult);
×
96
    }
97

98
    /**
99
    * Get a webhook
100
    *
101
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
102
    * @param webhookId {@link String } Unique identifier of the webhook configuration. (required)
103
    * @return {@link Webhook }
104
    * @throws ApiException if fails to make API call
105
    */
106
    public Webhook getWebhook(String merchantId, String webhookId) throws ApiException, IOException {
NEW
107
        return getWebhook(merchantId, webhookId, null);
×
108
    }
109

110
    /**
111
    * Get a webhook
112
    *
113
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
114
    * @param webhookId {@link String } Unique identifier of the webhook configuration. (required)
115
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
116
    * @return {@link Webhook }
117
    * @throws ApiException if fails to make API call
118
    */
119
    public Webhook getWebhook(String merchantId, String webhookId, RequestOptions requestOptions) throws ApiException, IOException {
120
        //Add path params
121
        Map<String, String> pathParams = new HashMap<>();
×
122
        if (merchantId == null) {
×
123
            throw new IllegalArgumentException("Please provide the merchantId path parameter");
×
124
        }
125
        pathParams.put("merchantId", merchantId);
×
NEW
126
        if (webhookId == null) {
×
NEW
127
            throw new IllegalArgumentException("Please provide the webhookId path parameter");
×
128
        }
NEW
129
        pathParams.put("webhookId", webhookId);
×
130

131
        String requestBody = null;
×
NEW
132
        Resource resource = new Resource(this, this.baseURL + "/merchants/{merchantId}/webhooks/{webhookId}", null);
×
NEW
133
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.GET, pathParams);
×
NEW
134
        return Webhook.fromJson(jsonResult);
×
135
    }
136

137
    /**
138
    * List all webhooks
139
    *
140
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
141
    * @return {@link ListWebhooksResponse }
142
    * @throws ApiException if fails to make API call
143
    */
144
    public ListWebhooksResponse listAllWebhooks(String merchantId) throws ApiException, IOException {
NEW
145
        return listAllWebhooks(merchantId, null,  null,  null);
×
146
    }
147

148
    /**
149
    * List all webhooks
150
    *
151
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
152
    * @param pageNumber {@link Integer } Query: The number of the page to fetch. (optional)
153
    * @param pageSize {@link Integer } Query: The number of items to have on a page, maximum 100. The default is 10 items on a page. (optional)
154
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
155
    * @return {@link ListWebhooksResponse }
156
    * @throws ApiException if fails to make API call
157
    */
158
    public ListWebhooksResponse listAllWebhooks(String merchantId, Integer pageNumber, Integer pageSize, RequestOptions requestOptions) throws ApiException, IOException {
159
        //Add path params
160
        Map<String, String> pathParams = new HashMap<>();
×
161
        if (merchantId == null) {
×
162
            throw new IllegalArgumentException("Please provide the merchantId path parameter");
×
163
        }
164
        pathParams.put("merchantId", merchantId);
×
165
        //Add query params
NEW
166
        Map<String, String> queryParams = new HashMap<>();
×
NEW
167
        if (pageNumber != null) {
×
NEW
168
        queryParams.put("pageNumber", pageNumber.toString());
×
169
        }
NEW
170
        if (pageSize != null) {
×
NEW
171
        queryParams.put("pageSize", pageSize.toString());
×
172
        }
173

174
        String requestBody = null;
×
NEW
175
        Resource resource = new Resource(this, this.baseURL + "/merchants/{merchantId}/webhooks", null);
×
NEW
176
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.GET, pathParams, queryParams);
×
NEW
177
        return ListWebhooksResponse.fromJson(jsonResult);
×
178
    }
179

180
    /**
181
    * Remove a webhook
182
    *
183
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
184
    * @param webhookId {@link String } Unique identifier of the webhook configuration. (required)
185
    * @throws ApiException if fails to make API call
186
    */
187
    public void removeWebhook(String merchantId, String webhookId) throws ApiException, IOException {
NEW
188
        removeWebhook(merchantId, webhookId, null);
×
189
    }
×
190

191
    /**
192
    * Remove a webhook
193
    *
194
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
195
    * @param webhookId {@link String } Unique identifier of the webhook configuration. (required)
196
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
197
    * @throws ApiException if fails to make API call
198
    */
199
    public void removeWebhook(String merchantId, String webhookId, RequestOptions requestOptions) throws ApiException, IOException {
200
        //Add path params
201
        Map<String, String> pathParams = new HashMap<>();
×
202
        if (merchantId == null) {
×
203
            throw new IllegalArgumentException("Please provide the merchantId path parameter");
×
204
        }
205
        pathParams.put("merchantId", merchantId);
×
206
        if (webhookId == null) {
×
207
            throw new IllegalArgumentException("Please provide the webhookId path parameter");
×
208
        }
209
        pathParams.put("webhookId", webhookId);
×
210

NEW
211
        String requestBody = null;
×
212
        Resource resource = new Resource(this, this.baseURL + "/merchants/{merchantId}/webhooks/{webhookId}", null);
×
NEW
213
        resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.DELETE, pathParams);
×
214
    }
×
215

216
    /**
217
    * Set up a webhook
218
    *
219
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
220
    * @param createMerchantWebhookRequest {@link CreateMerchantWebhookRequest }  (required)
221
    * @return {@link Webhook }
222
    * @throws ApiException if fails to make API call
223
    */
224
    public Webhook setUpWebhook(String merchantId, CreateMerchantWebhookRequest createMerchantWebhookRequest) throws ApiException, IOException {
225
        return setUpWebhook(merchantId, createMerchantWebhookRequest, null);
×
226
    }
227

228
    /**
229
    * Set up a webhook
230
    *
231
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
232
    * @param createMerchantWebhookRequest {@link CreateMerchantWebhookRequest }  (required)
233
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
234
    * @return {@link Webhook }
235
    * @throws ApiException if fails to make API call
236
    */
237
    public Webhook setUpWebhook(String merchantId, CreateMerchantWebhookRequest createMerchantWebhookRequest, RequestOptions requestOptions) throws ApiException, IOException {
238
        //Add path params
239
        Map<String, String> pathParams = new HashMap<>();
×
240
        if (merchantId == null) {
×
241
            throw new IllegalArgumentException("Please provide the merchantId path parameter");
×
242
        }
243
        pathParams.put("merchantId", merchantId);
×
244

245
        String requestBody = createMerchantWebhookRequest.toJson();
×
246
        Resource resource = new Resource(this, this.baseURL + "/merchants/{merchantId}/webhooks", null);
×
247
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, pathParams);
×
248
        return Webhook.fromJson(jsonResult);
×
249
    }
250

251
    /**
252
    * Test a webhook
253
    *
254
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
255
    * @param webhookId {@link String } Unique identifier of the webhook configuration. (required)
256
    * @param testWebhookRequest {@link TestWebhookRequest }  (required)
257
    * @return {@link TestWebhookResponse }
258
    * @throws ApiException if fails to make API call
259
    */
260
    public TestWebhookResponse testWebhook(String merchantId, String webhookId, TestWebhookRequest testWebhookRequest) throws ApiException, IOException {
NEW
261
        return testWebhook(merchantId, webhookId, testWebhookRequest, null);
×
262
    }
263

264
    /**
265
    * Test a webhook
266
    *
267
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
268
    * @param webhookId {@link String } Unique identifier of the webhook configuration. (required)
269
    * @param testWebhookRequest {@link TestWebhookRequest }  (required)
270
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
271
    * @return {@link TestWebhookResponse }
272
    * @throws ApiException if fails to make API call
273
    */
274
    public TestWebhookResponse testWebhook(String merchantId, String webhookId, TestWebhookRequest testWebhookRequest, RequestOptions requestOptions) throws ApiException, IOException {
275
        //Add path params
276
        Map<String, String> pathParams = new HashMap<>();
×
277
        if (merchantId == null) {
×
278
            throw new IllegalArgumentException("Please provide the merchantId path parameter");
×
279
        }
280
        pathParams.put("merchantId", merchantId);
×
281
        if (webhookId == null) {
×
282
            throw new IllegalArgumentException("Please provide the webhookId path parameter");
×
283
        }
284
        pathParams.put("webhookId", webhookId);
×
285

NEW
286
        String requestBody = testWebhookRequest.toJson();
×
NEW
287
        Resource resource = new Resource(this, this.baseURL + "/merchants/{merchantId}/webhooks/{webhookId}/test", null);
×
288
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, pathParams);
×
NEW
289
        return TestWebhookResponse.fromJson(jsonResult);
×
290
    }
291

292
    /**
293
    * Update a webhook
294
    *
295
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
296
    * @param webhookId {@link String } Unique identifier of the webhook configuration. (required)
297
    * @param updateMerchantWebhookRequest {@link UpdateMerchantWebhookRequest }  (required)
298
    * @return {@link Webhook }
299
    * @throws ApiException if fails to make API call
300
    */
301
    public Webhook updateWebhook(String merchantId, String webhookId, UpdateMerchantWebhookRequest updateMerchantWebhookRequest) throws ApiException, IOException {
NEW
302
        return updateWebhook(merchantId, webhookId, updateMerchantWebhookRequest, null);
×
303
    }
304

305
    /**
306
    * Update a webhook
307
    *
308
    * @param merchantId {@link String } The unique identifier of the merchant account. (required)
309
    * @param webhookId {@link String } Unique identifier of the webhook configuration. (required)
310
    * @param updateMerchantWebhookRequest {@link UpdateMerchantWebhookRequest }  (required)
311
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
312
    * @return {@link Webhook }
313
    * @throws ApiException if fails to make API call
314
    */
315
    public Webhook updateWebhook(String merchantId, String webhookId, UpdateMerchantWebhookRequest updateMerchantWebhookRequest, RequestOptions requestOptions) throws ApiException, IOException {
316
        //Add path params
317
        Map<String, String> pathParams = new HashMap<>();
×
318
        if (merchantId == null) {
×
319
            throw new IllegalArgumentException("Please provide the merchantId path parameter");
×
320
        }
321
        pathParams.put("merchantId", merchantId);
×
322
        if (webhookId == null) {
×
323
            throw new IllegalArgumentException("Please provide the webhookId path parameter");
×
324
        }
325
        pathParams.put("webhookId", webhookId);
×
326

NEW
327
        String requestBody = updateMerchantWebhookRequest.toJson();
×
NEW
328
        Resource resource = new Resource(this, this.baseURL + "/merchants/{merchantId}/webhooks/{webhookId}", null);
×
NEW
329
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.PATCH, pathParams);
×
NEW
330
        return Webhook.fromJson(jsonResult);
×
331
    }
332
}
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