3
3
package com.withorb.api.services.async
4
4
5
5
import com.withorb.api.core.ClientOptions
6
- import com.withorb.api.core.JsonValue
7
6
import com.withorb.api.core.RequestOptions
8
7
import com.withorb.api.core.checkRequired
8
+ import com.withorb.api.core.handlers.errorBodyHandler
9
9
import com.withorb.api.core.handlers.errorHandler
10
10
import com.withorb.api.core.handlers.jsonHandler
11
- import com.withorb.api.core.handlers.withErrorHandler
12
11
import com.withorb.api.core.http.HttpMethod
13
12
import com.withorb.api.core.http.HttpRequest
13
+ import com.withorb.api.core.http.HttpResponse
14
14
import com.withorb.api.core.http.HttpResponse.Handler
15
15
import com.withorb.api.core.http.HttpResponseFor
16
16
import com.withorb.api.core.http.json
@@ -93,7 +93,8 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
93
93
class WithRawResponseImpl internal constructor(private val clientOptions : ClientOptions ) :
94
94
AlertServiceAsync .WithRawResponse {
95
95
96
- private val errorHandler: Handler <JsonValue > = errorHandler(clientOptions.jsonMapper)
96
+ private val errorHandler: Handler <HttpResponse > =
97
+ errorHandler(errorBodyHandler(clientOptions.jsonMapper))
97
98
98
99
override fun withOptions (
99
100
modifier : (ClientOptions .Builder ) -> Unit
@@ -102,8 +103,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
102
103
clientOptions.toBuilder().apply (modifier).build()
103
104
)
104
105
105
- private val retrieveHandler: Handler <Alert > =
106
- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
106
+ private val retrieveHandler: Handler <Alert > = jsonHandler<Alert >(clientOptions.jsonMapper)
107
107
108
108
override suspend fun retrieve (
109
109
params : AlertRetrieveParams ,
@@ -121,7 +121,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
121
121
.prepareAsync(clientOptions, params)
122
122
val requestOptions = requestOptions.applyDefaults(RequestOptions .from(clientOptions))
123
123
val response = clientOptions.httpClient.executeAsync(request, requestOptions)
124
- return response.parseable {
124
+ return errorHandler.handle( response) .parseable {
125
125
response
126
126
.use { retrieveHandler.handle(it) }
127
127
.also {
@@ -132,8 +132,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
132
132
}
133
133
}
134
134
135
- private val updateHandler: Handler <Alert > =
136
- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
135
+ private val updateHandler: Handler <Alert > = jsonHandler<Alert >(clientOptions.jsonMapper)
137
136
138
137
override suspend fun update (
139
138
params : AlertUpdateParams ,
@@ -152,7 +151,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
152
151
.prepareAsync(clientOptions, params)
153
152
val requestOptions = requestOptions.applyDefaults(RequestOptions .from(clientOptions))
154
153
val response = clientOptions.httpClient.executeAsync(request, requestOptions)
155
- return response.parseable {
154
+ return errorHandler.handle( response) .parseable {
156
155
response
157
156
.use { updateHandler.handle(it) }
158
157
.also {
@@ -165,7 +164,6 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
165
164
166
165
private val listHandler: Handler <AlertListPageResponse > =
167
166
jsonHandler<AlertListPageResponse >(clientOptions.jsonMapper)
168
- .withErrorHandler(errorHandler)
169
167
170
168
override suspend fun list (
171
169
params : AlertListParams ,
@@ -180,7 +178,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
180
178
.prepareAsync(clientOptions, params)
181
179
val requestOptions = requestOptions.applyDefaults(RequestOptions .from(clientOptions))
182
180
val response = clientOptions.httpClient.executeAsync(request, requestOptions)
183
- return response.parseable {
181
+ return errorHandler.handle( response) .parseable {
184
182
response
185
183
.use { listHandler.handle(it) }
186
184
.also {
@@ -199,7 +197,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
199
197
}
200
198
201
199
private val createForCustomerHandler: Handler <Alert > =
202
- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
200
+ jsonHandler<Alert >(clientOptions.jsonMapper)
203
201
204
202
override suspend fun createForCustomer (
205
203
params : AlertCreateForCustomerParams ,
@@ -218,7 +216,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
218
216
.prepareAsync(clientOptions, params)
219
217
val requestOptions = requestOptions.applyDefaults(RequestOptions .from(clientOptions))
220
218
val response = clientOptions.httpClient.executeAsync(request, requestOptions)
221
- return response.parseable {
219
+ return errorHandler.handle( response) .parseable {
222
220
response
223
221
.use { createForCustomerHandler.handle(it) }
224
222
.also {
@@ -230,7 +228,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
230
228
}
231
229
232
230
private val createForExternalCustomerHandler: Handler <Alert > =
233
- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
231
+ jsonHandler<Alert >(clientOptions.jsonMapper)
234
232
235
233
override suspend fun createForExternalCustomer (
236
234
params : AlertCreateForExternalCustomerParams ,
@@ -249,7 +247,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
249
247
.prepareAsync(clientOptions, params)
250
248
val requestOptions = requestOptions.applyDefaults(RequestOptions .from(clientOptions))
251
249
val response = clientOptions.httpClient.executeAsync(request, requestOptions)
252
- return response.parseable {
250
+ return errorHandler.handle( response) .parseable {
253
251
response
254
252
.use { createForExternalCustomerHandler.handle(it) }
255
253
.also {
@@ -261,7 +259,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
261
259
}
262
260
263
261
private val createForSubscriptionHandler: Handler <Alert > =
264
- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
262
+ jsonHandler<Alert >(clientOptions.jsonMapper)
265
263
266
264
override suspend fun createForSubscription (
267
265
params : AlertCreateForSubscriptionParams ,
@@ -280,7 +278,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
280
278
.prepareAsync(clientOptions, params)
281
279
val requestOptions = requestOptions.applyDefaults(RequestOptions .from(clientOptions))
282
280
val response = clientOptions.httpClient.executeAsync(request, requestOptions)
283
- return response.parseable {
281
+ return errorHandler.handle( response) .parseable {
284
282
response
285
283
.use { createForSubscriptionHandler.handle(it) }
286
284
.also {
@@ -291,8 +289,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
291
289
}
292
290
}
293
291
294
- private val disableHandler: Handler <Alert > =
295
- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
292
+ private val disableHandler: Handler <Alert > = jsonHandler<Alert >(clientOptions.jsonMapper)
296
293
297
294
override suspend fun disable (
298
295
params : AlertDisableParams ,
@@ -311,7 +308,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
311
308
.prepareAsync(clientOptions, params)
312
309
val requestOptions = requestOptions.applyDefaults(RequestOptions .from(clientOptions))
313
310
val response = clientOptions.httpClient.executeAsync(request, requestOptions)
314
- return response.parseable {
311
+ return errorHandler.handle( response) .parseable {
315
312
response
316
313
.use { disableHandler.handle(it) }
317
314
.also {
@@ -322,8 +319,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
322
319
}
323
320
}
324
321
325
- private val enableHandler: Handler <Alert > =
326
- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
322
+ private val enableHandler: Handler <Alert > = jsonHandler<Alert >(clientOptions.jsonMapper)
327
323
328
324
override suspend fun enable (
329
325
params : AlertEnableParams ,
@@ -342,7 +338,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
342
338
.prepareAsync(clientOptions, params)
343
339
val requestOptions = requestOptions.applyDefaults(RequestOptions .from(clientOptions))
344
340
val response = clientOptions.httpClient.executeAsync(request, requestOptions)
345
- return response.parseable {
341
+ return errorHandler.handle( response) .parseable {
346
342
response
347
343
.use { enableHandler.handle(it) }
348
344
.also {
0 commit comments