33package com.withorb.api.services.async
44
55import com.withorb.api.core.ClientOptions
6- import com.withorb.api.core.JsonValue
76import com.withorb.api.core.RequestOptions
87import com.withorb.api.core.checkRequired
8+ import com.withorb.api.core.handlers.errorBodyHandler
99import com.withorb.api.core.handlers.errorHandler
1010import com.withorb.api.core.handlers.jsonHandler
11- import com.withorb.api.core.handlers.withErrorHandler
1211import com.withorb.api.core.http.HttpMethod
1312import com.withorb.api.core.http.HttpRequest
13+ import com.withorb.api.core.http.HttpResponse
1414import com.withorb.api.core.http.HttpResponse.Handler
1515import com.withorb.api.core.http.HttpResponseFor
1616import com.withorb.api.core.http.json
@@ -102,7 +102,8 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
102102 class WithRawResponseImpl internal constructor(private val clientOptions : ClientOptions ) :
103103 AlertServiceAsync .WithRawResponse {
104104
105- private val errorHandler: Handler <JsonValue > = errorHandler(clientOptions.jsonMapper)
105+ private val errorHandler: Handler <HttpResponse > =
106+ errorHandler(errorBodyHandler(clientOptions.jsonMapper))
106107
107108 override fun withOptions (
108109 modifier : Consumer <ClientOptions .Builder >
@@ -111,8 +112,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
111112 clientOptions.toBuilder().apply (modifier::accept).build()
112113 )
113114
114- private val retrieveHandler: Handler <Alert > =
115- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
115+ private val retrieveHandler: Handler <Alert > = jsonHandler<Alert >(clientOptions.jsonMapper)
116116
117117 override fun retrieve (
118118 params : AlertRetrieveParams ,
@@ -132,7 +132,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
132132 return request
133133 .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
134134 .thenApply { response ->
135- response.parseable {
135+ errorHandler.handle( response) .parseable {
136136 response
137137 .use { retrieveHandler.handle(it) }
138138 .also {
@@ -144,8 +144,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
144144 }
145145 }
146146
147- private val updateHandler: Handler <Alert > =
148- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
147+ private val updateHandler: Handler <Alert > = jsonHandler<Alert >(clientOptions.jsonMapper)
149148
150149 override fun update (
151150 params : AlertUpdateParams ,
@@ -166,7 +165,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
166165 return request
167166 .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
168167 .thenApply { response ->
169- response.parseable {
168+ errorHandler.handle( response) .parseable {
170169 response
171170 .use { updateHandler.handle(it) }
172171 .also {
@@ -180,7 +179,6 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
180179
181180 private val listHandler: Handler <AlertListPageResponse > =
182181 jsonHandler<AlertListPageResponse >(clientOptions.jsonMapper)
183- .withErrorHandler(errorHandler)
184182
185183 override fun list (
186184 params : AlertListParams ,
@@ -197,7 +195,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
197195 return request
198196 .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
199197 .thenApply { response ->
200- response.parseable {
198+ errorHandler.handle( response) .parseable {
201199 response
202200 .use { listHandler.handle(it) }
203201 .also {
@@ -218,7 +216,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
218216 }
219217
220218 private val createForCustomerHandler: Handler <Alert > =
221- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
219+ jsonHandler<Alert >(clientOptions.jsonMapper)
222220
223221 override fun createForCustomer (
224222 params : AlertCreateForCustomerParams ,
@@ -239,7 +237,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
239237 return request
240238 .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
241239 .thenApply { response ->
242- response.parseable {
240+ errorHandler.handle( response) .parseable {
243241 response
244242 .use { createForCustomerHandler.handle(it) }
245243 .also {
@@ -252,7 +250,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
252250 }
253251
254252 private val createForExternalCustomerHandler: Handler <Alert > =
255- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
253+ jsonHandler<Alert >(clientOptions.jsonMapper)
256254
257255 override fun createForExternalCustomer (
258256 params : AlertCreateForExternalCustomerParams ,
@@ -273,7 +271,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
273271 return request
274272 .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
275273 .thenApply { response ->
276- response.parseable {
274+ errorHandler.handle( response) .parseable {
277275 response
278276 .use { createForExternalCustomerHandler.handle(it) }
279277 .also {
@@ -286,7 +284,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
286284 }
287285
288286 private val createForSubscriptionHandler: Handler <Alert > =
289- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
287+ jsonHandler<Alert >(clientOptions.jsonMapper)
290288
291289 override fun createForSubscription (
292290 params : AlertCreateForSubscriptionParams ,
@@ -307,7 +305,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
307305 return request
308306 .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
309307 .thenApply { response ->
310- response.parseable {
308+ errorHandler.handle( response) .parseable {
311309 response
312310 .use { createForSubscriptionHandler.handle(it) }
313311 .also {
@@ -319,8 +317,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
319317 }
320318 }
321319
322- private val disableHandler: Handler <Alert > =
323- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
320+ private val disableHandler: Handler <Alert > = jsonHandler<Alert >(clientOptions.jsonMapper)
324321
325322 override fun disable (
326323 params : AlertDisableParams ,
@@ -341,7 +338,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
341338 return request
342339 .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
343340 .thenApply { response ->
344- response.parseable {
341+ errorHandler.handle( response) .parseable {
345342 response
346343 .use { disableHandler.handle(it) }
347344 .also {
@@ -353,8 +350,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
353350 }
354351 }
355352
356- private val enableHandler: Handler <Alert > =
357- jsonHandler<Alert >(clientOptions.jsonMapper).withErrorHandler(errorHandler)
353+ private val enableHandler: Handler <Alert > = jsonHandler<Alert >(clientOptions.jsonMapper)
358354
359355 override fun enable (
360356 params : AlertEnableParams ,
@@ -375,7 +371,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
375371 return request
376372 .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
377373 .thenApply { response ->
378- response.parseable {
374+ errorHandler.handle( response) .parseable {
379375 response
380376 .use { enableHandler.handle(it) }
381377 .also {
0 commit comments