diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d486cde74..87d60805f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.96.0" + ".": "0.96.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c76911aaa..e9cc8cb8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.96.1 (2025-07-18) + +Full Changelog: [v0.96.0...v0.96.1](https://github.com/lithic-com/lithic-java/compare/v0.96.0...v0.96.1) + +### Bug Fixes + +* **client:** ensure error handling always occurs ([037c1ff](https://github.com/lithic-com/lithic-java/commit/037c1ffd0e92cb6e86f9e434f96f9cff6a6393e2)) + + +### Chores + +* fix conflict ([83182ce](https://github.com/lithic-com/lithic-java/commit/83182ce0bcaf7edb9d5874e2496c3ea6314295a9)) +* **internal:** allow running specific example from cli ([59ee949](https://github.com/lithic-com/lithic-java/commit/59ee949248a1e53456df67804bbae9ccb2a258d3)) + ## 0.96.0 (2025-07-15) Full Changelog: [v0.95.0...v0.96.0](https://github.com/lithic-com/lithic-java/compare/v0.95.0...v0.96.0) diff --git a/README.md b/README.md index 53ba3ec55..5566ea841 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.96.0) -[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.96.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.96.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.96.1) +[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.96.1/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.96.1) @@ -13,7 +13,7 @@ The Lithic Java SDK is similar to the Lithic Kotlin SDK but with minor differenc -The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.96.0). +The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.96.1). @@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.lithic.com](https://docs.lithic ### Gradle ```kotlin -implementation("com.lithic.api:lithic-java:0.96.0") +implementation("com.lithic.api:lithic-java:0.96.1") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.lithic.api:lithic-java:0.96.0") com.lithic.api lithic-java - 0.96.0 + 0.96.1 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 147075849..64088c199 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.lithic.api" - version = "0.96.0" // x-release-please-version + version = "0.96.1" // x-release-please-version } subprojects { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt index 8d7d5bb73..fa05a6755 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.client import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.getPackageVersion +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -285,7 +285,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LithicClientAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val accounts: AccountServiceAsync.WithRawResponse by lazy { AccountServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -472,7 +473,7 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun networkPrograms(): NetworkProgramServiceAsync.WithRawResponse = networkPrograms private val apiStatusHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun apiStatus( params: ClientApiStatusParams, @@ -489,7 +490,7 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { apiStatusHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt index 859f2f678..28a889f85 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.client import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.getPackageVersion +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -267,7 +267,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LithicClient.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val accounts: AccountService.WithRawResponse by lazy { AccountServiceImpl.WithRawResponseImpl(clientOptions) @@ -453,7 +454,7 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun networkPrograms(): NetworkProgramService.WithRawResponse = networkPrograms private val apiStatusHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun apiStatus( params: ClientApiStatusParams, @@ -468,7 +469,7 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { apiStatusHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/core/handlers/ErrorHandler.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/core/handlers/ErrorHandler.kt index 6fda9991d..2dd9da026 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/core/handlers/ErrorHandler.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/core/handlers/ErrorHandler.kt @@ -19,7 +19,7 @@ import com.lithic.api.errors.UnexpectedStatusCodeException import com.lithic.api.errors.UnprocessableEntityException @JvmSynthetic -internal fun errorHandler(jsonMapper: JsonMapper): Handler { +internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { val handler = jsonHandler(jsonMapper) return object : Handler { @@ -33,52 +33,52 @@ internal fun errorHandler(jsonMapper: JsonMapper): Handler { } @JvmSynthetic -internal fun Handler.withErrorHandler(errorHandler: Handler): Handler = - object : Handler { - override fun handle(response: HttpResponse): T = +internal fun errorHandler(errorBodyHandler: Handler): Handler = + object : Handler { + override fun handle(response: HttpResponse): HttpResponse = when (val statusCode = response.statusCode()) { - in 200..299 -> this@withErrorHandler.handle(response) + in 200..299 -> response 400 -> throw BadRequestException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 401 -> throw UnauthorizedException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 403 -> throw PermissionDeniedException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 404 -> throw NotFoundException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 422 -> throw UnprocessableEntityException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 429 -> throw RateLimitException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() in 500..599 -> throw InternalServerException.builder() .statusCode(statusCode) .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() else -> throw UnexpectedStatusCodeException.builder() .statusCode(statusCode) .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountHolderServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountHolderServiceAsyncImpl.kt index 5960e0bc1..91b71340f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountHolderServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountHolderServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -118,7 +118,8 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AccountHolderServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -129,7 +130,6 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AccountHolderCreateParams, @@ -150,7 +150,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -163,7 +163,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: AccountHolderRetrieveParams, @@ -183,7 +183,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -197,7 +197,6 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: AccountHolderUpdateParams, @@ -218,7 +217,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -232,7 +231,6 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: AccountHolderListParams, @@ -249,7 +247,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -271,7 +269,6 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio private val listDocumentsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listDocuments( params: AccountHolderListDocumentsParams, @@ -291,7 +288,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listDocumentsHandler.handle(it) } .also { @@ -304,7 +301,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio } private val retrieveDocumentHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveDocument( params: AccountHolderRetrieveDocumentParams, @@ -330,7 +327,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveDocumentHandler.handle(it) } .also { @@ -343,7 +340,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio } private val simulateEnrollmentDocumentReviewHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun simulateEnrollmentDocumentReview( params: AccountHolderSimulateEnrollmentDocumentReviewParams, @@ -366,7 +363,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateEnrollmentDocumentReviewHandler.handle(it) } .also { @@ -381,7 +378,6 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio private val simulateEnrollmentReviewHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateEnrollmentReview( params: AccountHolderSimulateEnrollmentReviewParams, @@ -399,7 +395,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateEnrollmentReviewHandler.handle(it) } .also { @@ -412,7 +408,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio } private val uploadDocumentHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun uploadDocument( params: AccountHolderUploadDocumentParams, @@ -433,7 +429,7 @@ class AccountHolderServiceAsyncImpl internal constructor(private val clientOptio return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { uploadDocumentHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsyncImpl.kt index 699c54de2..fd5397a09 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -71,7 +71,8 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AccountServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -81,7 +82,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: AccountRetrieveParams, @@ -101,7 +102,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -113,8 +114,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun update( params: AccountUpdateParams, @@ -135,7 +135,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -149,7 +149,6 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: AccountListParams, @@ -166,7 +165,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -187,7 +186,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl } private val retrieveSpendLimitsHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveSpendLimits( params: AccountRetrieveSpendLimitsParams, @@ -207,7 +206,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveSpendLimitsHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AggregateBalanceServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AggregateBalanceServiceAsyncImpl.kt index a1c9ad5eb..e45199b7a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AggregateBalanceServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AggregateBalanceServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -44,7 +44,8 @@ internal constructor(private val clientOptions: ClientOptions) : AggregateBalanc class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AggregateBalanceServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,6 @@ internal constructor(private val clientOptions: ClientOptions) : AggregateBalanc private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: AggregateBalanceListParams, @@ -72,7 +72,7 @@ internal constructor(private val clientOptions: ClientOptions) : AggregateBalanc return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthStreamEnrollmentServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthStreamEnrollmentServiceAsyncImpl.kt index 22cd82340..6d5557a32 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthStreamEnrollmentServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthStreamEnrollmentServiceAsyncImpl.kt @@ -3,12 +3,11 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -57,7 +56,8 @@ internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrol class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrollmentServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -67,7 +67,7 @@ internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrol ) private val retrieveSecretHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveSecret( params: AuthStreamEnrollmentRetrieveSecretParams, @@ -84,7 +84,7 @@ internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrol return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveSecretHandler.handle(it) } .also { @@ -96,8 +96,7 @@ internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrol } } - private val rotateSecretHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val rotateSecretHandler: Handler = emptyHandler() override fun rotateSecret( params: AuthStreamEnrollmentRotateSecretParams, @@ -115,7 +114,9 @@ internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrol return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { rotateSecretHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { rotateSecretHandler.handle(it) } + } } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/BalanceServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/BalanceServiceAsyncImpl.kt index a15c8fe43..1e461f1c7 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/BalanceServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/BalanceServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -42,7 +42,8 @@ class BalanceServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BalanceServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class BalanceServiceAsyncImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: BalanceListParams, @@ -70,7 +70,7 @@ class BalanceServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/BookTransferServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/BookTransferServiceAsyncImpl.kt index 695e5727c..97990dec2 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/BookTransferServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/BookTransferServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -70,7 +70,8 @@ class BookTransferServiceAsyncImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BookTransferServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -81,7 +82,6 @@ class BookTransferServiceAsyncImpl internal constructor(private val clientOption private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: BookTransferCreateParams, @@ -99,7 +99,7 @@ class BookTransferServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -113,7 +113,6 @@ class BookTransferServiceAsyncImpl internal constructor(private val clientOption private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: BookTransferRetrieveParams, @@ -133,7 +132,7 @@ class BookTransferServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -147,7 +146,6 @@ class BookTransferServiceAsyncImpl internal constructor(private val clientOption private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: BookTransferListParams, @@ -164,7 +162,7 @@ class BookTransferServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -186,7 +184,6 @@ class BookTransferServiceAsyncImpl internal constructor(private val clientOption private val reverseHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun reverse( params: BookTransferReverseParams, @@ -207,7 +204,7 @@ class BookTransferServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { reverseHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardProgramServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardProgramServiceAsyncImpl.kt index eaf7baa7a..501be47ac 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardProgramServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardProgramServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -53,7 +53,8 @@ class CardProgramServiceAsyncImpl internal constructor(private val clientOptions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CardProgramServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -63,7 +64,7 @@ class CardProgramServiceAsyncImpl internal constructor(private val clientOptions ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: CardProgramRetrieveParams, @@ -83,7 +84,7 @@ class CardProgramServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -97,7 +98,6 @@ class CardProgramServiceAsyncImpl internal constructor(private val clientOptions private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CardProgramListParams, @@ -114,7 +114,7 @@ class CardProgramServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsyncImpl.kt index d66bf78bb..3facd014d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsyncImpl.kt @@ -3,15 +3,15 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler import com.lithic.api.core.handlers.stringHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -167,7 +167,8 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CardServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val aggregateBalances: AggregateBalanceServiceAsync.WithRawResponse by lazy { AggregateBalanceServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -197,8 +198,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun financialTransactions(): FinancialTransactionServiceAsync.WithRawResponse = financialTransactions - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun create( params: CardCreateParams, @@ -216,7 +216,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -228,8 +228,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: CardRetrieveParams, @@ -249,7 +248,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -261,8 +260,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun update( params: CardUpdateParams, @@ -283,7 +281,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -297,7 +295,6 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CardListParams, @@ -314,7 +311,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -335,7 +332,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val convertPhysicalHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun convertPhysical( params: CardConvertPhysicalParams, @@ -356,7 +353,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { convertPhysicalHandler.handle(it) } .also { @@ -368,7 +365,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val embedHandler: Handler = stringHandler().withErrorHandler(errorHandler) + private val embedHandler: Handler = stringHandler() override fun embed( params: CardEmbedParams, @@ -385,13 +382,14 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { embedHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { embedHandler.handle(it) } + } } } private val provisionHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun provision( params: CardProvisionParams, @@ -412,7 +410,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { provisionHandler.handle(it) } .also { @@ -424,8 +422,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val reissueHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val reissueHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun reissue( params: CardReissueParams, @@ -446,7 +443,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { reissueHandler.handle(it) } .also { @@ -458,8 +455,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val renewHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val renewHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun renew( params: CardRenewParams, @@ -480,7 +476,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { renewHandler.handle(it) } .also { @@ -493,7 +489,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val retrieveSpendLimitsHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveSpendLimits( params: CardRetrieveSpendLimitsParams, @@ -513,7 +509,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveSpendLimitsHandler.handle(it) } .also { @@ -525,8 +521,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val searchByPanHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val searchByPanHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun searchByPan( params: CardSearchByPanParams, @@ -544,7 +539,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { searchByPanHandler.handle(it) } .also { @@ -558,7 +553,6 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien private val webProvisionHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun webProvision( params: CardWebProvisionParams, @@ -579,7 +573,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { webProvisionHandler.handle(it) } .also { @@ -592,8 +586,9 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val embedHandler: Handler = stringHandler().withErrorHandler(errorHandler) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + private val embedHandler: Handler = stringHandler() override fun getEmbedHtml( params: CardGetEmbedHtmlParams, @@ -620,7 +615,7 @@ class CardServiceAsyncImpl internal constructor(private val clientOptions: Clien .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> - response.let { embedHandler.handle(it) } + errorHandler.handle(response).let { embedHandler.handle(it) } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/DigitalCardArtServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/DigitalCardArtServiceAsyncImpl.kt index 3dfc7c20c..eeccb78d7 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/DigitalCardArtServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/DigitalCardArtServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -55,7 +55,8 @@ internal constructor(private val clientOptions: ClientOptions) : DigitalCardArtS class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DigitalCardArtServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -65,7 +66,7 @@ internal constructor(private val clientOptions: ClientOptions) : DigitalCardArtS ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: DigitalCardArtRetrieveParams, @@ -85,7 +86,7 @@ internal constructor(private val clientOptions: ClientOptions) : DigitalCardArtS return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -99,7 +100,6 @@ internal constructor(private val clientOptions: ClientOptions) : DigitalCardArtS private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: DigitalCardArtListParams, @@ -116,7 +116,7 @@ internal constructor(private val clientOptions: ClientOptions) : DigitalCardArtS return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/DisputeServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/DisputeServiceAsyncImpl.kt index a7b0057ac..2150207e3 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/DisputeServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/DisputeServiceAsyncImpl.kt @@ -3,16 +3,16 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.MultipartField import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -117,7 +117,8 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DisputeServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -126,8 +127,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun create( params: DisputeCreateParams, @@ -145,7 +145,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -158,7 +158,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: DisputeRetrieveParams, @@ -178,7 +178,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -190,8 +190,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun update( params: DisputeUpdateParams, @@ -212,7 +211,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -226,7 +225,6 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: DisputeListParams, @@ -243,7 +241,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -263,8 +261,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun delete( params: DisputeDeleteParams, @@ -285,7 +282,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -298,7 +295,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl } private val deleteEvidenceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun deleteEvidence( params: DisputeDeleteEvidenceParams, @@ -325,7 +322,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteEvidenceHandler.handle(it) } .also { @@ -338,7 +335,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl } private val initiateEvidenceUploadHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun initiateEvidenceUpload( params: DisputeInitiateEvidenceUploadParams, @@ -359,7 +356,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { initiateEvidenceUploadHandler.handle(it) } .also { @@ -373,7 +370,6 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl private val listEvidencesHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listEvidences( params: DisputeListEvidencesParams, @@ -393,7 +389,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listEvidencesHandler.handle(it) } .also { @@ -414,7 +410,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl } private val retrieveEvidenceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveEvidence( params: DisputeRetrieveEvidenceParams, @@ -440,7 +436,7 @@ class DisputeServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveEvidenceHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/EventServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/EventServiceAsyncImpl.kt index 2420e02f1..f6f9e9a73 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/EventServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/EventServiceAsyncImpl.kt @@ -7,11 +7,12 @@ import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -81,7 +82,8 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EventServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val subscriptions: SubscriptionServiceAsync.WithRawResponse by lazy { SubscriptionServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -103,8 +105,7 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun eventSubscriptions(): EventSubscriptionServiceAsync.WithRawResponse = eventSubscriptions - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: EventRetrieveParams, @@ -124,7 +125,7 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -138,7 +139,6 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: EventListParams, @@ -155,7 +155,7 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -177,7 +177,6 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie private val listAttemptsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listAttempts( params: EventListAttemptsParams, @@ -197,7 +196,7 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listAttemptsHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncImpl.kt index e09aa9518..8d0e8a75c 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -103,7 +103,8 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ExternalBankAccountServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val microDeposits: MicroDepositServiceAsync.WithRawResponse by lazy { MicroDepositServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -120,7 +121,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ExternalBankAccountCreateParams, @@ -138,7 +138,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -152,7 +152,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ExternalBankAccountRetrieveParams, @@ -172,7 +171,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -186,7 +185,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: ExternalBankAccountUpdateParams, @@ -207,7 +205,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -221,7 +219,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: ExternalBankAccountListParams, @@ -238,7 +235,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -261,7 +258,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val retryMicroDepositsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retryMicroDeposits( params: ExternalBankAccountRetryMicroDepositsParams, @@ -287,7 +283,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retryMicroDepositsHandler.handle(it) } .also { @@ -301,7 +297,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val retryPrenoteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams, @@ -327,7 +322,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retryPrenoteHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalPaymentServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalPaymentServiceAsyncImpl.kt index 7e59fcfa4..f96884a22 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalPaymentServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalPaymentServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -96,7 +96,8 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPaymentServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -106,7 +107,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment ) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: ExternalPaymentCreateParams, @@ -124,7 +125,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -137,7 +138,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: ExternalPaymentRetrieveParams, @@ -157,7 +158,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -171,7 +172,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: ExternalPaymentListParams, @@ -188,7 +188,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -209,7 +209,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment } private val cancelHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun cancel( params: ExternalPaymentCancelParams, @@ -230,7 +230,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { cancelHandler.handle(it) } .also { @@ -243,7 +243,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment } private val releaseHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun release( params: ExternalPaymentReleaseParams, @@ -264,7 +264,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { releaseHandler.handle(it) } .also { @@ -277,7 +277,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment } private val reverseHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun reverse( params: ExternalPaymentReverseParams, @@ -298,7 +298,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { reverseHandler.handle(it) } .also { @@ -311,7 +311,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment } private val settleHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun settle( params: ExternalPaymentSettleParams, @@ -332,7 +332,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPayment return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { settleHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsyncImpl.kt index 72bde816b..ca57d2c0e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsyncImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -126,7 +125,8 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FinancialAccountServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val balances: BalanceServiceAsync.WithRawResponse by lazy { BalanceServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -169,7 +169,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun override fun loanTapes(): LoanTapeServiceAsync.WithRawResponse = loanTapes private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: FinancialAccountCreateParams, @@ -187,7 +187,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -200,7 +200,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: FinancialAccountRetrieveParams, @@ -220,7 +220,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -233,7 +233,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: FinancialAccountUpdateParams, @@ -254,7 +254,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -268,7 +268,6 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: FinancialAccountListParams, @@ -285,7 +284,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -305,8 +304,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun } } - private val registerAccountNumberHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val registerAccountNumberHandler: Handler = emptyHandler() override fun registerAccountNumber( params: FinancialAccountRegisterAccountNumberParams, @@ -332,12 +330,14 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { registerAccountNumberHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { registerAccountNumberHandler.handle(it) } + } } } private val updateStatusHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun updateStatus( params: FinancialAccountUpdateStatusParams, @@ -363,7 +363,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialAccoun return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateStatusHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsyncImpl.kt index 5d5b4e8bd..f3aa916e0 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -62,7 +62,8 @@ class FundingEventServiceAsyncImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FundingEventServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -73,7 +74,6 @@ class FundingEventServiceAsyncImpl internal constructor(private val clientOption private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: FundingEventRetrieveParams, @@ -93,7 +93,7 @@ class FundingEventServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -107,7 +107,6 @@ class FundingEventServiceAsyncImpl internal constructor(private val clientOption private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: FundingEventListParams, @@ -124,7 +123,7 @@ class FundingEventServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -146,7 +145,6 @@ class FundingEventServiceAsyncImpl internal constructor(private val clientOption private val retrieveDetailsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveDetails( params: FundingEventRetrieveDetailsParams, @@ -166,7 +164,7 @@ class FundingEventServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveDetailsHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ManagementOperationServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ManagementOperationServiceAsyncImpl.kt index 0b97d7101..32f391e50 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ManagementOperationServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ManagementOperationServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -75,7 +75,8 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ManagementOperationServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -86,7 +87,6 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ManagementOperationCreateParams, @@ -104,7 +104,7 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -118,7 +118,6 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ManagementOperationRetrieveParams, @@ -138,7 +137,7 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -152,7 +151,6 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: ManagementOperationListParams, @@ -169,7 +167,7 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -191,7 +189,6 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera private val reverseHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun reverse( params: ManagementOperationReverseParams, @@ -212,7 +209,7 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { reverseHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncImpl.kt index 4c9da290c..6bb94e1e7 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -55,7 +55,8 @@ internal constructor(private val clientOptions: ClientOptions) : NetworkProgramS class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : NetworkProgramServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -65,7 +66,7 @@ internal constructor(private val clientOptions: ClientOptions) : NetworkProgramS ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: NetworkProgramRetrieveParams, @@ -85,7 +86,7 @@ internal constructor(private val clientOptions: ClientOptions) : NetworkProgramS return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -99,7 +100,6 @@ internal constructor(private val clientOptions: ClientOptions) : NetworkProgramS private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: NetworkProgramListParams, @@ -116,7 +116,7 @@ internal constructor(private val clientOptions: ClientOptions) : NetworkProgramS return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsyncImpl.kt index 5d42fc894..4202c3781 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -108,7 +108,8 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : PaymentServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -119,7 +120,6 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: PaymentCreateParams, @@ -137,7 +137,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -150,7 +150,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: PaymentRetrieveParams, @@ -170,7 +170,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -184,7 +184,6 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: PaymentListParams, @@ -201,7 +200,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -223,7 +222,6 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val retryHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retry( params: PaymentRetryParams, @@ -244,7 +242,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retryHandler.handle(it) } .also { @@ -258,7 +256,6 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val simulateActionHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateAction( params: PaymentSimulateActionParams, @@ -279,7 +276,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateActionHandler.handle(it) } .also { @@ -293,7 +290,6 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val simulateReceiptHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateReceipt( params: PaymentSimulateReceiptParams, @@ -311,7 +307,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateReceiptHandler.handle(it) } .also { @@ -325,7 +321,6 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val simulateReleaseHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateRelease( params: PaymentSimulateReleaseParams, @@ -343,7 +338,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateReleaseHandler.handle(it) } .also { @@ -357,7 +352,6 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val simulateReturnHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateReturn( params: PaymentSimulateReturnParams, @@ -375,7 +369,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateReturnHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ResponderEndpointServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ResponderEndpointServiceAsyncImpl.kt index ab02a7b10..a4a6db72d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ResponderEndpointServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ResponderEndpointServiceAsyncImpl.kt @@ -3,12 +3,11 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -63,7 +62,8 @@ internal constructor(private val clientOptions: ClientOptions) : ResponderEndpoi class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ResponderEndpointServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -74,7 +74,6 @@ internal constructor(private val clientOptions: ClientOptions) : ResponderEndpoi private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ResponderEndpointCreateParams, @@ -92,7 +91,7 @@ internal constructor(private val clientOptions: ClientOptions) : ResponderEndpoi return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -104,7 +103,7 @@ internal constructor(private val clientOptions: ClientOptions) : ResponderEndpoi } } - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val deleteHandler: Handler = emptyHandler() override fun delete( params: ResponderEndpointDeleteParams, @@ -122,13 +121,14 @@ internal constructor(private val clientOptions: ClientOptions) : ResponderEndpoi return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { deleteHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } } } private val checkStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkStatus( params: ResponderEndpointCheckStatusParams, @@ -145,7 +145,7 @@ internal constructor(private val clientOptions: ClientOptions) : ResponderEndpoi return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { checkStatusHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationDecisioningServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationDecisioningServiceAsyncImpl.kt index 23f7783b4..1d723e946 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationDecisioningServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationDecisioningServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -57,7 +57,8 @@ internal constructor(private val clientOptions: ClientOptions) : class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TokenizationDecisioningServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -67,7 +68,7 @@ internal constructor(private val clientOptions: ClientOptions) : ) private val retrieveSecretHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveSecret( params: TokenizationDecisioningRetrieveSecretParams, @@ -84,7 +85,7 @@ internal constructor(private val clientOptions: ClientOptions) : return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveSecretHandler.handle(it) } .also { @@ -98,7 +99,6 @@ internal constructor(private val clientOptions: ClientOptions) : private val rotateSecretHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun rotateSecret( params: TokenizationDecisioningRotateSecretParams, @@ -116,7 +116,7 @@ internal constructor(private val clientOptions: ClientOptions) : return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { rotateSecretHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncImpl.kt index d30543fdf..1d0744cfb 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -114,7 +113,8 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TokenizationServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -125,7 +125,6 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: TokenizationRetrieveParams, @@ -145,7 +144,7 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -159,7 +158,6 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: TokenizationListParams, @@ -176,7 +174,7 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -196,7 +194,7 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption } } - private val activateHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val activateHandler: Handler = emptyHandler() override fun activate( params: TokenizationActivateParams, @@ -217,12 +215,13 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { activateHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { activateHandler.handle(it) } + } } } - private val deactivateHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val deactivateHandler: Handler = emptyHandler() override fun deactivate( params: TokenizationDeactivateParams, @@ -243,11 +242,13 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { deactivateHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { deactivateHandler.handle(it) } + } } } - private val pauseHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val pauseHandler: Handler = emptyHandler() override fun pause( params: TokenizationPauseParams, @@ -268,12 +269,13 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { pauseHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { pauseHandler.handle(it) } + } } } - private val resendActivationCodeHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val resendActivationCodeHandler: Handler = emptyHandler() override fun resendActivationCode( params: TokenizationResendActivationCodeParams, @@ -299,13 +301,14 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { resendActivationCodeHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { resendActivationCodeHandler.handle(it) } + } } } private val simulateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulate( params: TokenizationSimulateParams, @@ -323,7 +326,7 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateHandler.handle(it) } .also { @@ -335,7 +338,7 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption } } - private val unpauseHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val unpauseHandler: Handler = emptyHandler() override fun unpause( params: TokenizationUnpauseParams, @@ -356,13 +359,14 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { unpauseHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { unpauseHandler.handle(it) } + } } } private val updateDigitalCardArtHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams, @@ -388,7 +392,7 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateDigitalCardArtHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsyncImpl.kt index 137325281..75f5fc07e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsyncImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -146,7 +145,8 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TransactionServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val enhancedCommercialData: EnhancedCommercialDataServiceAsync.WithRawResponse by lazy { @@ -170,7 +170,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions override fun events(): EventServiceAsync.WithRawResponse = events private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: TransactionRetrieveParams, @@ -190,7 +190,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -204,7 +204,6 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: TransactionListParams, @@ -221,7 +220,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -241,8 +240,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions } } - private val expireAuthorizationHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val expireAuthorizationHandler: Handler = emptyHandler() override fun expireAuthorization( params: TransactionExpireAuthorizationParams, @@ -268,14 +266,15 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { expireAuthorizationHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { expireAuthorizationHandler.handle(it) } + } } } private val simulateAuthorizationHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateAuthorization( params: TransactionSimulateAuthorizationParams, @@ -293,7 +292,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateAuthorizationHandler.handle(it) } .also { @@ -308,7 +307,6 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions private val simulateAuthorizationAdviceHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateAuthorizationAdvice( params: TransactionSimulateAuthorizationAdviceParams, @@ -326,7 +324,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateAuthorizationAdviceHandler.handle(it) } .also { @@ -340,7 +338,6 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions private val simulateClearingHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateClearing( params: TransactionSimulateClearingParams, @@ -358,7 +355,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateClearingHandler.handle(it) } .also { @@ -373,7 +370,6 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions private val simulateCreditAuthorizationHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams, @@ -391,7 +387,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateCreditAuthorizationHandler.handle(it) } .also { @@ -405,7 +401,6 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions private val simulateReturnHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateReturn( params: TransactionSimulateReturnParams, @@ -423,7 +418,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateReturnHandler.handle(it) } .also { @@ -438,7 +433,6 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions private val simulateReturnReversalHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateReturnReversal( params: TransactionSimulateReturnReversalParams, @@ -456,7 +450,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateReturnReversalHandler.handle(it) } .also { @@ -470,7 +464,6 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions private val simulateVoidHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateVoid( params: TransactionSimulateVoidParams, @@ -488,7 +481,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateVoidHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransferServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransferServiceAsyncImpl.kt index 1b48831b1..a88781feb 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransferServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransferServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -43,7 +43,8 @@ class TransferServiceAsyncImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TransferServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,7 @@ class TransferServiceAsyncImpl internal constructor(private val clientOptions: C ) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) @Deprecated("deprecated") override fun create( @@ -72,7 +73,7 @@ class TransferServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt index b54448398..321e4871a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.async.authRules import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -135,7 +134,8 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : V2ServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val backtests: BacktestServiceAsync.WithRawResponse by lazy { BacktestServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -151,7 +151,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO override fun backtests(): BacktestServiceAsync.WithRawResponse = backtests private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: AuthRuleV2CreateParams, @@ -169,7 +169,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -182,7 +182,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: AuthRuleV2RetrieveParams, @@ -202,7 +202,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -215,7 +215,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: AuthRuleV2UpdateParams, @@ -236,7 +236,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -250,7 +250,6 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: AuthRuleV2ListParams, @@ -267,7 +266,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -287,7 +286,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO } } - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val deleteHandler: Handler = emptyHandler() override fun delete( params: AuthRuleV2DeleteParams, @@ -308,12 +307,14 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { deleteHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } } } private val applyHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) @Deprecated("deprecated") override fun apply( @@ -335,7 +336,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { applyHandler.handle(it) } .also { @@ -348,7 +349,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO } private val draftHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun draft( params: AuthRuleV2DraftParams, @@ -369,7 +370,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { draftHandler.handle(it) } .also { @@ -382,7 +383,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO } private val promoteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun promote( params: AuthRuleV2PromoteParams, @@ -403,7 +404,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { promoteHandler.handle(it) } .also { @@ -416,7 +417,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO } private val reportHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) @Deprecated("deprecated") override fun report( @@ -438,7 +439,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { reportHandler.handle(it) } .also { @@ -452,7 +453,6 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO private val retrieveReportHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveReport( params: AuthRuleV2RetrieveReportParams, @@ -472,7 +472,7 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveReportHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsyncImpl.kt index 7312d9518..552a3dff3 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.authRules.v2 import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -53,7 +53,8 @@ class BacktestServiceAsyncImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BacktestServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -64,7 +65,6 @@ class BacktestServiceAsyncImpl internal constructor(private val clientOptions: C private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AuthRuleV2BacktestCreateParams, @@ -85,7 +85,7 @@ class BacktestServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -98,7 +98,7 @@ class BacktestServiceAsyncImpl internal constructor(private val clientOptions: C } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: AuthRuleV2BacktestRetrieveParams, @@ -124,7 +124,7 @@ class BacktestServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/AggregateBalanceServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/AggregateBalanceServiceAsyncImpl.kt index 72085bbe2..aa8353643 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/AggregateBalanceServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/AggregateBalanceServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package com.lithic.api.services.async.cards import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -44,7 +44,8 @@ internal constructor(private val clientOptions: ClientOptions) : AggregateBalanc class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AggregateBalanceServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,6 @@ internal constructor(private val clientOptions: ClientOptions) : AggregateBalanc private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CardAggregateBalanceListParams, @@ -72,7 +72,7 @@ internal constructor(private val clientOptions: ClientOptions) : AggregateBalanc return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/BalanceServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/BalanceServiceAsyncImpl.kt index a0a56b90e..c885da023 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/BalanceServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/BalanceServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.cards import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -44,7 +44,8 @@ class BalanceServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BalanceServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,6 @@ class BalanceServiceAsyncImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CardBalanceListParams, @@ -75,7 +75,7 @@ class BalanceServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/FinancialTransactionServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/FinancialTransactionServiceAsyncImpl.kt index b4fd3fbed..ad98f4d89 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/FinancialTransactionServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/cards/FinancialTransactionServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.cards import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -58,7 +58,8 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FinancialTransactionServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -69,7 +70,6 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: CardFinancialTransactionRetrieveParams, @@ -98,7 +98,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -112,7 +112,6 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CardFinancialTransactionListParams, @@ -132,7 +131,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/creditProducts/ExtendedCreditServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/creditProducts/ExtendedCreditServiceAsyncImpl.kt index 0aeee7b19..bd27ffd50 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/creditProducts/ExtendedCreditServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/creditProducts/ExtendedCreditServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.creditProducts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -45,7 +45,8 @@ internal constructor(private val clientOptions: ClientOptions) : ExtendedCreditS class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ExtendedCreditServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExtendedCreditS ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: CreditProductExtendedCreditRetrieveParams, @@ -80,7 +81,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExtendedCreditS return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/creditProducts/PrimeRateServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/creditProducts/PrimeRateServiceAsyncImpl.kt index 64007ad14..a81d03cde 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/creditProducts/PrimeRateServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/creditProducts/PrimeRateServiceAsyncImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.async.creditProducts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -54,7 +53,8 @@ class PrimeRateServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : PrimeRateServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -63,7 +63,7 @@ class PrimeRateServiceAsyncImpl internal constructor(private val clientOptions: clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val createHandler: Handler = emptyHandler() override fun create( params: CreditProductPrimeRateCreateParams, @@ -84,13 +84,14 @@ class PrimeRateServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { createHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { createHandler.handle(it) } + } } } private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: CreditProductPrimeRateRetrieveParams, @@ -110,7 +111,7 @@ class PrimeRateServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/events/EventSubscriptionServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/events/EventSubscriptionServiceAsyncImpl.kt index b241614fe..148f93599 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/events/EventSubscriptionServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/events/EventSubscriptionServiceAsyncImpl.kt @@ -3,12 +3,11 @@ package com.lithic.api.services.async.events import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -45,7 +44,8 @@ internal constructor(private val clientOptions: ClientOptions) : EventSubscripti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EventSubscriptionServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +54,7 @@ internal constructor(private val clientOptions: ClientOptions) : EventSubscripti clientOptions.toBuilder().apply(modifier::accept).build() ) - private val resendHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val resendHandler: Handler = emptyHandler() override fun resend( params: EventEventSubscriptionResendParams, @@ -82,7 +82,9 @@ internal constructor(private val clientOptions: ClientOptions) : EventSubscripti return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { resendHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { resendHandler.handle(it) } + } } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/events/SubscriptionServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/events/SubscriptionServiceAsyncImpl.kt index 289ddff54..77ca3d372 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/events/SubscriptionServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/events/SubscriptionServiceAsyncImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.async.events import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -131,7 +130,8 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -141,7 +141,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption ) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: EventSubscriptionCreateParams, @@ -159,7 +159,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -172,7 +172,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: EventSubscriptionRetrieveParams, @@ -192,7 +192,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -205,7 +205,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: EventSubscriptionUpdateParams, @@ -226,7 +226,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -240,7 +240,6 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: EventSubscriptionListParams, @@ -257,7 +256,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -277,7 +276,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption } } - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val deleteHandler: Handler = emptyHandler() override fun delete( params: EventSubscriptionDeleteParams, @@ -298,13 +297,14 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { deleteHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } } } private val listAttemptsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listAttempts( params: EventSubscriptionListAttemptsParams, @@ -324,7 +324,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listAttemptsHandler.handle(it) } .also { @@ -344,7 +344,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption } } - private val recoverHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val recoverHandler: Handler = emptyHandler() override fun recover( params: EventSubscriptionRecoverParams, @@ -365,12 +365,13 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { recoverHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { recoverHandler.handle(it) } + } } } - private val replayMissingHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val replayMissingHandler: Handler = emptyHandler() override fun replayMissing( params: EventSubscriptionReplayMissingParams, @@ -396,13 +397,14 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { replayMissingHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { replayMissingHandler.handle(it) } + } } } private val retrieveSecretHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveSecret( params: EventSubscriptionRetrieveSecretParams, @@ -422,7 +424,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveSecretHandler.handle(it) } .also { @@ -434,8 +436,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption } } - private val rotateSecretHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val rotateSecretHandler: Handler = emptyHandler() override fun rotateSecret( params: EventSubscriptionRotateSecretParams, @@ -462,12 +463,13 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { rotateSecretHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { rotateSecretHandler.handle(it) } + } } } - private val sendSimulatedExampleHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val sendSimulatedExampleHandler: Handler = emptyHandler() override fun sendSimulatedExample( params: EventSubscriptionSendSimulatedExampleParams, @@ -494,7 +496,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { sendSimulatedExampleHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { sendSimulatedExampleHandler.handle(it) } + } } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/externalBankAccounts/MicroDepositServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/externalBankAccounts/MicroDepositServiceAsyncImpl.kt index 73885ed16..fdf5db060 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/externalBankAccounts/MicroDepositServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/externalBankAccounts/MicroDepositServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.externalBankAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -44,7 +44,8 @@ class MicroDepositServiceAsyncImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : MicroDepositServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,6 @@ class MicroDepositServiceAsyncImpl internal constructor(private val clientOption private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ExternalBankAccountMicroDepositCreateParams, @@ -81,7 +81,7 @@ class MicroDepositServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/BalanceServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/BalanceServiceAsyncImpl.kt index 5943bb7ea..dedf47ad3 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/BalanceServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/BalanceServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.financialAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -44,7 +44,8 @@ class BalanceServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BalanceServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,6 @@ class BalanceServiceAsyncImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: FinancialAccountBalanceListParams, @@ -75,7 +75,7 @@ class BalanceServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/CreditConfigurationServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/CreditConfigurationServiceAsyncImpl.kt index e390ebeff..288d42a75 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/CreditConfigurationServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/CreditConfigurationServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.financialAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -57,7 +57,8 @@ internal constructor(private val clientOptions: ClientOptions) : CreditConfigura class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditConfigurationServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -68,7 +69,6 @@ internal constructor(private val clientOptions: ClientOptions) : CreditConfigura private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: FinancialAccountCreditConfigurationRetrieveParams, @@ -93,7 +93,7 @@ internal constructor(private val clientOptions: ClientOptions) : CreditConfigura return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -107,7 +107,6 @@ internal constructor(private val clientOptions: ClientOptions) : CreditConfigura private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: FinancialAccountCreditConfigurationUpdateParams, @@ -133,7 +132,7 @@ internal constructor(private val clientOptions: ClientOptions) : CreditConfigura return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/FinancialTransactionServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/FinancialTransactionServiceAsyncImpl.kt index 460c51ea1..a3af1de90 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/FinancialTransactionServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/FinancialTransactionServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.financialAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -59,7 +59,8 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FinancialTransactionServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -70,7 +71,6 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: FinancialTransactionRetrieveParams, @@ -99,7 +99,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -113,7 +113,6 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: FinancialTransactionListParams, @@ -138,7 +137,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/LoanTapeServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/LoanTapeServiceAsyncImpl.kt index 7421b5a6b..b70a82e63 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/LoanTapeServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/LoanTapeServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.financialAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -53,7 +53,8 @@ class LoanTapeServiceAsyncImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LoanTapeServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -63,7 +64,7 @@ class LoanTapeServiceAsyncImpl internal constructor(private val clientOptions: C ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: FinancialAccountLoanTapeRetrieveParams, @@ -89,7 +90,7 @@ class LoanTapeServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -103,7 +104,6 @@ class LoanTapeServiceAsyncImpl internal constructor(private val clientOptions: C private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: FinancialAccountLoanTapeListParams, @@ -123,7 +123,7 @@ class LoanTapeServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/StatementServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/StatementServiceAsyncImpl.kt index 6d1221ac3..d38747edd 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/StatementServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/StatementServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.financialAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -59,7 +59,8 @@ class StatementServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : StatementServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val lineItems: LineItemServiceAsync.WithRawResponse by lazy { LineItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -75,7 +76,7 @@ class StatementServiceAsyncImpl internal constructor(private val clientOptions: override fun lineItems(): LineItemServiceAsync.WithRawResponse = lineItems private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: FinancialAccountStatementRetrieveParams, @@ -101,7 +102,7 @@ class StatementServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -114,7 +115,7 @@ class StatementServiceAsyncImpl internal constructor(private val clientOptions: } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: FinancialAccountStatementListParams, @@ -134,7 +135,7 @@ class StatementServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/statements/LineItemServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/statements/LineItemServiceAsyncImpl.kt index 2779b5304..5f5974550 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/statements/LineItemServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/statements/LineItemServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.financialAccounts.statements import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -45,7 +45,8 @@ class LineItemServiceAsyncImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LineItemServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,7 @@ class LineItemServiceAsyncImpl internal constructor(private val clientOptions: C ) private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: FinancialAccountStatementLineItemListParams, @@ -82,7 +83,7 @@ class LineItemServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/fraud/TransactionServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/fraud/TransactionServiceAsyncImpl.kt index 3437dcbf8..e1ec8f391 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/fraud/TransactionServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/fraud/TransactionServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.fraud import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -53,7 +53,8 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TransactionServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -64,7 +65,6 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: FraudTransactionRetrieveParams, @@ -84,7 +84,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -98,7 +98,6 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions private val reportHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun report( params: FraudTransactionReportParams, @@ -119,7 +118,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { reportHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/SettlementServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/SettlementServiceAsyncImpl.kt index 6c4166b30..c63eace36 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/SettlementServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/SettlementServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.reports import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -61,7 +61,8 @@ class SettlementServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SettlementServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val networkTotals: NetworkTotalServiceAsync.WithRawResponse by lazy { NetworkTotalServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -78,7 +79,6 @@ class SettlementServiceAsyncImpl internal constructor(private val clientOptions: private val listDetailsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listDetails( params: ReportSettlementListDetailsParams, @@ -98,7 +98,7 @@ class SettlementServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listDetailsHandler.handle(it) } .also { @@ -119,7 +119,7 @@ class SettlementServiceAsyncImpl internal constructor(private val clientOptions: } private val summaryHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun summary( params: ReportSettlementSummaryParams, @@ -139,7 +139,7 @@ class SettlementServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { summaryHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsyncImpl.kt index c5b6ea761..4ea419cce 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.reports.settlement import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -53,7 +53,8 @@ class NetworkTotalServiceAsyncImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : NetworkTotalServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -64,7 +65,6 @@ class NetworkTotalServiceAsyncImpl internal constructor(private val clientOption private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams, @@ -90,7 +90,7 @@ class NetworkTotalServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -104,7 +104,6 @@ class NetworkTotalServiceAsyncImpl internal constructor(private val clientOption private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: ReportSettlementNetworkTotalListParams, @@ -121,7 +120,7 @@ class NetworkTotalServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncImpl.kt index bdbd0316c..db24c9692 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.async.threeDS import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -65,7 +64,8 @@ internal constructor(private val clientOptions: ClientOptions) : AuthenticationS class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AuthenticationServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -76,7 +76,6 @@ internal constructor(private val clientOptions: ClientOptions) : AuthenticationS private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ThreeDSAuthenticationRetrieveParams, @@ -99,7 +98,7 @@ internal constructor(private val clientOptions: ClientOptions) : AuthenticationS return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -113,7 +112,6 @@ internal constructor(private val clientOptions: ClientOptions) : AuthenticationS private val simulateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulate( params: ThreeDSAuthenticationSimulateParams, @@ -131,7 +129,7 @@ internal constructor(private val clientOptions: ClientOptions) : AuthenticationS return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { simulateHandler.handle(it) } .also { @@ -143,8 +141,7 @@ internal constructor(private val clientOptions: ClientOptions) : AuthenticationS } } - private val simulateOtpEntryHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val simulateOtpEntryHandler: Handler = emptyHandler() override fun simulateOtpEntry( params: ThreeDSAuthenticationSimulateOtpEntryParams, @@ -162,7 +159,9 @@ internal constructor(private val clientOptions: ClientOptions) : AuthenticationS return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { simulateOtpEntryHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { simulateOtpEntryHandler.handle(it) } + } } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/DecisioningServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/DecisioningServiceAsyncImpl.kt index 5a1353b3d..0709f3255 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/DecisioningServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/DecisioningServiceAsyncImpl.kt @@ -3,12 +3,11 @@ package com.lithic.api.services.async.threeDS import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -60,7 +59,8 @@ class DecisioningServiceAsyncImpl internal constructor(private val clientOptions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DecisioningServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -69,8 +69,7 @@ class DecisioningServiceAsyncImpl internal constructor(private val clientOptions clientOptions.toBuilder().apply(modifier::accept).build() ) - private val challengeResponseHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val challengeResponseHandler: Handler = emptyHandler() override fun challengeResponse( params: ThreeDSDecisioningChallengeResponseParams, @@ -88,13 +87,14 @@ class DecisioningServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { challengeResponseHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { challengeResponseHandler.handle(it) } + } } } private val retrieveSecretHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveSecret( params: ThreeDSDecisioningRetrieveSecretParams, @@ -111,7 +111,7 @@ class DecisioningServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveSecretHandler.handle(it) } .also { @@ -123,8 +123,7 @@ class DecisioningServiceAsyncImpl internal constructor(private val clientOptions } } - private val rotateSecretHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val rotateSecretHandler: Handler = emptyHandler() override fun rotateSecret( params: ThreeDSDecisioningRotateSecretParams, @@ -142,7 +141,9 @@ class DecisioningServiceAsyncImpl internal constructor(private val clientOptions return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { response.use { rotateSecretHandler.handle(it) } } + errorHandler.handle(response).parseable { + response.use { rotateSecretHandler.handle(it) } + } } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/transactions/EnhancedCommercialDataServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/transactions/EnhancedCommercialDataServiceAsyncImpl.kt index 450c89430..3e059eb07 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/transactions/EnhancedCommercialDataServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/transactions/EnhancedCommercialDataServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.transactions import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -49,7 +49,8 @@ internal constructor(private val clientOptions: ClientOptions) : class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EnhancedCommercialDataServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -60,7 +61,6 @@ internal constructor(private val clientOptions: ClientOptions) : private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: TransactionEnhancedCommercialDataRetrieveParams, @@ -85,7 +85,7 @@ internal constructor(private val clientOptions: ClientOptions) : return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/transactions/events/EnhancedCommercialDataServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/transactions/events/EnhancedCommercialDataServiceAsyncImpl.kt index 66f982517..3f3f02c8d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/transactions/events/EnhancedCommercialDataServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/transactions/events/EnhancedCommercialDataServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.async.transactions.events import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -49,7 +49,8 @@ internal constructor(private val clientOptions: ClientOptions) : class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EnhancedCommercialDataServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -59,7 +60,7 @@ internal constructor(private val clientOptions: ClientOptions) : ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: TransactionEventEnhancedCommercialDataRetrieveParams, @@ -85,7 +86,7 @@ internal constructor(private val clientOptions: ClientOptions) : return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountHolderServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountHolderServiceImpl.kt index e23b81f54..332a98031 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountHolderServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountHolderServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -115,7 +115,8 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AccountHolderService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -126,7 +127,6 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AccountHolderCreateParams, @@ -145,7 +145,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C .applyDefaults(RequestOptions.from(clientOptions)) .applyDefaults(RequestOptions.builder().timeout(Duration.ofMinutes(5)).build()) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -157,7 +157,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: AccountHolderRetrieveParams, @@ -175,7 +175,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -188,7 +188,6 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: AccountHolderUpdateParams, @@ -207,7 +206,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -220,7 +219,6 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: AccountHolderListParams, @@ -235,7 +233,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -255,7 +253,6 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C private val listDocumentsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listDocuments( params: AccountHolderListDocumentsParams, @@ -273,7 +270,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listDocumentsHandler.handle(it) } .also { @@ -285,7 +282,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C } private val retrieveDocumentHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveDocument( params: AccountHolderRetrieveDocumentParams, @@ -309,7 +306,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveDocumentHandler.handle(it) } .also { @@ -321,7 +318,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C } private val simulateEnrollmentDocumentReviewHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun simulateEnrollmentDocumentReview( params: AccountHolderSimulateEnrollmentDocumentReviewParams, @@ -342,7 +339,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateEnrollmentDocumentReviewHandler.handle(it) } .also { @@ -356,7 +353,6 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C private val simulateEnrollmentReviewHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateEnrollmentReview( params: AccountHolderSimulateEnrollmentReviewParams, @@ -372,7 +368,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateEnrollmentReviewHandler.handle(it) } .also { @@ -384,7 +380,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C } private val uploadDocumentHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun uploadDocument( params: AccountHolderUploadDocumentParams, @@ -403,7 +399,7 @@ class AccountHolderServiceImpl internal constructor(private val clientOptions: C .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { uploadDocumentHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountServiceImpl.kt index b8080615c..17b172303 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -61,7 +61,8 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AccountService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -71,7 +72,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: AccountRetrieveParams, @@ -89,7 +90,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -100,8 +101,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun update( params: AccountUpdateParams, @@ -120,7 +120,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -133,7 +133,6 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: AccountListParams, @@ -148,7 +147,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -167,7 +166,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO } private val retrieveSpendLimitsHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveSpendLimits( params: AccountRetrieveSpendLimitsParams, @@ -185,7 +184,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveSpendLimitsHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AggregateBalanceServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AggregateBalanceServiceImpl.kt index 55b20f7aa..927e0a17f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AggregateBalanceServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AggregateBalanceServiceImpl.kt @@ -3,13 +3,13 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -41,7 +41,8 @@ class AggregateBalanceServiceImpl internal constructor(private val clientOptions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AggregateBalanceService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class AggregateBalanceServiceImpl internal constructor(private val clientOptions private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: AggregateBalanceListParams, @@ -67,7 +67,7 @@ class AggregateBalanceServiceImpl internal constructor(private val clientOptions .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthStreamEnrollmentServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthStreamEnrollmentServiceImpl.kt index 63a14fb56..c899af49e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthStreamEnrollmentServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthStreamEnrollmentServiceImpl.kt @@ -3,12 +3,11 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -54,7 +53,8 @@ internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrol class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrollmentService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -64,7 +64,7 @@ internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrol ) private val retrieveSecretHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveSecret( params: AuthStreamEnrollmentRetrieveSecretParams, @@ -79,7 +79,7 @@ internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrol .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveSecretHandler.handle(it) } .also { @@ -90,8 +90,7 @@ internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrol } } - private val rotateSecretHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val rotateSecretHandler: Handler = emptyHandler() override fun rotateSecret( params: AuthStreamEnrollmentRotateSecretParams, @@ -107,7 +106,9 @@ internal constructor(private val clientOptions: ClientOptions) : AuthStreamEnrol .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { rotateSecretHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { rotateSecretHandler.handle(it) } + } } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/BalanceServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/BalanceServiceImpl.kt index 517419684..343b09603 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/BalanceServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/BalanceServiceImpl.kt @@ -3,13 +3,13 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -38,7 +38,8 @@ class BalanceServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BalanceService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -49,7 +50,6 @@ class BalanceServiceImpl internal constructor(private val clientOptions: ClientO private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: BalanceListParams, @@ -64,7 +64,7 @@ class BalanceServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/BookTransferServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/BookTransferServiceImpl.kt index 7d66a133b..a44374271 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/BookTransferServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/BookTransferServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -69,7 +69,8 @@ class BookTransferServiceImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BookTransferService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -80,7 +81,6 @@ class BookTransferServiceImpl internal constructor(private val clientOptions: Cl private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: BookTransferCreateParams, @@ -96,7 +96,7 @@ class BookTransferServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -109,7 +109,6 @@ class BookTransferServiceImpl internal constructor(private val clientOptions: Cl private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: BookTransferRetrieveParams, @@ -127,7 +126,7 @@ class BookTransferServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -140,7 +139,6 @@ class BookTransferServiceImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: BookTransferListParams, @@ -155,7 +153,7 @@ class BookTransferServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -175,7 +173,6 @@ class BookTransferServiceImpl internal constructor(private val clientOptions: Cl private val reverseHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun reverse( params: BookTransferReverseParams, @@ -194,7 +191,7 @@ class BookTransferServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { reverseHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardProgramServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardProgramServiceImpl.kt index 8d8ac4199..f5b60de72 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardProgramServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardProgramServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -52,7 +52,8 @@ class CardProgramServiceImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CardProgramService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -62,7 +63,7 @@ class CardProgramServiceImpl internal constructor(private val clientOptions: Cli ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: CardProgramRetrieveParams, @@ -80,7 +81,7 @@ class CardProgramServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -93,7 +94,6 @@ class CardProgramServiceImpl internal constructor(private val clientOptions: Cli private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CardProgramListParams, @@ -108,7 +108,7 @@ class CardProgramServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardServiceImpl.kt index 41763d404..df3fbf94e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardServiceImpl.kt @@ -3,15 +3,15 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler import com.lithic.api.core.handlers.stringHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -141,7 +141,8 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CardService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val aggregateBalances: AggregateBalanceService.WithRawResponse by lazy { AggregateBalanceServiceImpl.WithRawResponseImpl(clientOptions) @@ -170,8 +171,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti override fun financialTransactions(): FinancialTransactionService.WithRawResponse = financialTransactions - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun create( params: CardCreateParams, @@ -187,7 +187,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -198,8 +198,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: CardRetrieveParams, @@ -217,7 +216,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -228,8 +227,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun update( params: CardUpdateParams, @@ -248,7 +246,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -261,7 +259,6 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CardListParams, @@ -276,7 +273,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -295,7 +292,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti } private val convertPhysicalHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun convertPhysical( params: CardConvertPhysicalParams, @@ -314,7 +311,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { convertPhysicalHandler.handle(it) } .also { @@ -325,7 +322,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val embedHandler: Handler = stringHandler().withErrorHandler(errorHandler) + private val embedHandler: Handler = stringHandler() override fun embed( params: CardEmbedParams, @@ -340,12 +337,13 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { embedHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { embedHandler.handle(it) } + } } private val provisionHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun provision( params: CardProvisionParams, @@ -364,7 +362,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { provisionHandler.handle(it) } .also { @@ -375,8 +373,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val reissueHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val reissueHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun reissue( params: CardReissueParams, @@ -395,7 +392,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { reissueHandler.handle(it) } .also { @@ -406,8 +403,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val renewHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val renewHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun renew( params: CardRenewParams, @@ -426,7 +422,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { renewHandler.handle(it) } .also { @@ -438,7 +434,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti } private val retrieveSpendLimitsHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveSpendLimits( params: CardRetrieveSpendLimitsParams, @@ -456,7 +452,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveSpendLimitsHandler.handle(it) } .also { @@ -467,8 +463,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val searchByPanHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val searchByPanHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun searchByPan( params: CardSearchByPanParams, @@ -484,7 +479,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { searchByPanHandler.handle(it) } .also { @@ -497,7 +492,6 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti private val webProvisionHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun webProvision( params: CardWebProvisionParams, @@ -516,7 +510,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { webProvisionHandler.handle(it) } .also { @@ -528,8 +522,9 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val embedHandler: Handler = stringHandler().withErrorHandler(errorHandler) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + private val embedHandler: Handler = stringHandler() override fun getEmbedHtml( params: CardGetEmbedHtmlParams, @@ -555,7 +550,7 @@ class CardServiceImpl internal constructor(private val clientOptions: ClientOpti .putHeader("Accept", "text/html") .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response.let { embedHandler.handle(it) } + errorHandler.handle(response).let { embedHandler.handle(it) } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/DigitalCardArtServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/DigitalCardArtServiceImpl.kt index a6df2c66f..858835959 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/DigitalCardArtServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/DigitalCardArtServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -52,7 +52,8 @@ class DigitalCardArtServiceImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DigitalCardArtService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -62,7 +63,7 @@ class DigitalCardArtServiceImpl internal constructor(private val clientOptions: ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: DigitalCardArtRetrieveParams, @@ -80,7 +81,7 @@ class DigitalCardArtServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -93,7 +94,6 @@ class DigitalCardArtServiceImpl internal constructor(private val clientOptions: private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: DigitalCardArtListParams, @@ -108,7 +108,7 @@ class DigitalCardArtServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/DisputeServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/DisputeServiceImpl.kt index ee859504a..47cb54392 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/DisputeServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/DisputeServiceImpl.kt @@ -3,16 +3,16 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.MultipartField import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -101,7 +101,8 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DisputeService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -110,8 +111,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun create( params: DisputeCreateParams, @@ -127,7 +127,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -139,7 +139,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: DisputeRetrieveParams, @@ -157,7 +157,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -168,8 +168,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun update( params: DisputeUpdateParams, @@ -188,7 +187,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -201,7 +200,6 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: DisputeListParams, @@ -216,7 +214,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -234,8 +232,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun delete( params: DisputeDeleteParams, @@ -254,7 +251,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -266,7 +263,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO } private val deleteEvidenceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun deleteEvidence( params: DisputeDeleteEvidenceParams, @@ -291,7 +288,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteEvidenceHandler.handle(it) } .also { @@ -303,7 +300,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO } private val initiateEvidenceUploadHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun initiateEvidenceUpload( params: DisputeInitiateEvidenceUploadParams, @@ -322,7 +319,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { initiateEvidenceUploadHandler.handle(it) } .also { @@ -335,7 +332,6 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO private val listEvidencesHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listEvidences( params: DisputeListEvidencesParams, @@ -353,7 +349,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listEvidencesHandler.handle(it) } .also { @@ -372,7 +368,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO } private val retrieveEvidenceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveEvidence( params: DisputeRetrieveEvidenceParams, @@ -396,7 +392,7 @@ class DisputeServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveEvidenceHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/EventServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/EventServiceImpl.kt index b09ac7aed..6d092ccb9 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/EventServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/EventServiceImpl.kt @@ -7,11 +7,12 @@ import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -74,7 +75,8 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EventService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val subscriptions: SubscriptionService.WithRawResponse by lazy { SubscriptionServiceImpl.WithRawResponseImpl(clientOptions) @@ -96,8 +98,7 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt override fun eventSubscriptions(): EventSubscriptionService.WithRawResponse = eventSubscriptions - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: EventRetrieveParams, @@ -115,7 +116,7 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -128,7 +129,6 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: EventListParams, @@ -143,7 +143,7 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -163,7 +163,6 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt private val listAttemptsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listAttempts( params: EventListAttemptsParams, @@ -181,7 +180,7 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listAttemptsHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceImpl.kt index 74ba81da5..4e560015f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -99,7 +99,8 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ExternalBankAccountService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val microDeposits: MicroDepositService.WithRawResponse by lazy { MicroDepositServiceImpl.WithRawResponseImpl(clientOptions) @@ -116,7 +117,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ExternalBankAccountCreateParams, @@ -132,7 +132,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -145,7 +145,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ExternalBankAccountRetrieveParams, @@ -163,7 +162,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -176,7 +175,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: ExternalBankAccountUpdateParams, @@ -195,7 +193,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -208,7 +206,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: ExternalBankAccountListParams, @@ -223,7 +220,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -244,7 +241,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val retryMicroDepositsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retryMicroDeposits( params: ExternalBankAccountRetryMicroDepositsParams, @@ -268,7 +264,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retryMicroDepositsHandler.handle(it) } .also { @@ -281,7 +277,6 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc private val retryPrenoteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams, @@ -305,7 +300,7 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retryPrenoteHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalPaymentServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalPaymentServiceImpl.kt index 8a1523f99..ec45330a7 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalPaymentServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalPaymentServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -93,7 +93,8 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPaymentService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -103,7 +104,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: ) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: ExternalPaymentCreateParams, @@ -119,7 +120,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -131,7 +132,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: ExternalPaymentRetrieveParams, @@ -149,7 +150,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -162,7 +163,6 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: ExternalPaymentListParams, @@ -177,7 +177,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -196,7 +196,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: } private val cancelHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun cancel( params: ExternalPaymentCancelParams, @@ -215,7 +215,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { cancelHandler.handle(it) } .also { @@ -227,7 +227,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: } private val releaseHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun release( params: ExternalPaymentReleaseParams, @@ -246,7 +246,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { releaseHandler.handle(it) } .also { @@ -258,7 +258,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: } private val reverseHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun reverse( params: ExternalPaymentReverseParams, @@ -277,7 +277,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { reverseHandler.handle(it) } .also { @@ -289,7 +289,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: } private val settleHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun settle( params: ExternalPaymentSettleParams, @@ -308,7 +308,7 @@ class ExternalPaymentServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { settleHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceImpl.kt index e2100ba91..7e23c4953 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -122,7 +121,8 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FinancialAccountService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val balances: BalanceService.WithRawResponse by lazy { BalanceServiceImpl.WithRawResponseImpl(clientOptions) @@ -164,7 +164,7 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions override fun loanTapes(): LoanTapeService.WithRawResponse = loanTapes private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: FinancialAccountCreateParams, @@ -180,7 +180,7 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -192,7 +192,7 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: FinancialAccountRetrieveParams, @@ -210,7 +210,7 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -222,7 +222,7 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: FinancialAccountUpdateParams, @@ -241,7 +241,7 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -254,7 +254,6 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: FinancialAccountListParams, @@ -269,7 +268,7 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -287,8 +286,7 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions } } - private val registerAccountNumberHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val registerAccountNumberHandler: Handler = emptyHandler() override fun registerAccountNumber( params: FinancialAccountRegisterAccountNumberParams, @@ -312,11 +310,13 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { registerAccountNumberHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { registerAccountNumberHandler.handle(it) } + } } private val updateStatusHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun updateStatus( params: FinancialAccountUpdateStatusParams, @@ -340,7 +340,7 @@ class FinancialAccountServiceImpl internal constructor(private val clientOptions .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateStatusHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventServiceImpl.kt index a55edd8bf..559b83c0f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -61,7 +61,8 @@ class FundingEventServiceImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FundingEventService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -72,7 +73,6 @@ class FundingEventServiceImpl internal constructor(private val clientOptions: Cl private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: FundingEventRetrieveParams, @@ -90,7 +90,7 @@ class FundingEventServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -103,7 +103,6 @@ class FundingEventServiceImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: FundingEventListParams, @@ -118,7 +117,7 @@ class FundingEventServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -138,7 +137,6 @@ class FundingEventServiceImpl internal constructor(private val clientOptions: Cl private val retrieveDetailsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveDetails( params: FundingEventRetrieveDetailsParams, @@ -156,7 +154,7 @@ class FundingEventServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveDetailsHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ManagementOperationServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ManagementOperationServiceImpl.kt index 998c2bb4c..709133767 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ManagementOperationServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ManagementOperationServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -71,7 +71,8 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ManagementOperationService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -82,7 +83,6 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ManagementOperationCreateParams, @@ -98,7 +98,7 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -111,7 +111,6 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ManagementOperationRetrieveParams, @@ -129,7 +128,7 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -142,7 +141,6 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: ManagementOperationListParams, @@ -157,7 +155,7 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -177,7 +175,6 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera private val reverseHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun reverse( params: ManagementOperationReverseParams, @@ -196,7 +193,7 @@ internal constructor(private val clientOptions: ClientOptions) : ManagementOpera .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { reverseHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceImpl.kt index ca3cc96e8..e2b936411 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -52,7 +52,8 @@ class NetworkProgramServiceImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : NetworkProgramService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -62,7 +63,7 @@ class NetworkProgramServiceImpl internal constructor(private val clientOptions: ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: NetworkProgramRetrieveParams, @@ -80,7 +81,7 @@ class NetworkProgramServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -93,7 +94,6 @@ class NetworkProgramServiceImpl internal constructor(private val clientOptions: private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: NetworkProgramListParams, @@ -108,7 +108,7 @@ class NetworkProgramServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentServiceImpl.kt index 7a5ad9395..54bc1ca65 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -101,7 +101,8 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : PaymentService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -112,7 +113,6 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: PaymentCreateParams, @@ -128,7 +128,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -140,7 +140,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: PaymentRetrieveParams, @@ -158,7 +158,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -171,7 +171,6 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: PaymentListParams, @@ -186,7 +185,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -206,7 +205,6 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val retryHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retry( params: PaymentRetryParams, @@ -225,7 +223,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retryHandler.handle(it) } .also { @@ -238,7 +236,6 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val simulateActionHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateAction( params: PaymentSimulateActionParams, @@ -257,7 +254,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateActionHandler.handle(it) } .also { @@ -270,7 +267,6 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val simulateReceiptHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateReceipt( params: PaymentSimulateReceiptParams, @@ -286,7 +282,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateReceiptHandler.handle(it) } .also { @@ -299,7 +295,6 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val simulateReleaseHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateRelease( params: PaymentSimulateReleaseParams, @@ -315,7 +310,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateReleaseHandler.handle(it) } .also { @@ -328,7 +323,6 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val simulateReturnHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateReturn( params: PaymentSimulateReturnParams, @@ -344,7 +338,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateReturnHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ResponderEndpointServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ResponderEndpointServiceImpl.kt index ae00cfeda..86fd94edb 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ResponderEndpointServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ResponderEndpointServiceImpl.kt @@ -3,12 +3,11 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -58,7 +57,8 @@ class ResponderEndpointServiceImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ResponderEndpointService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -69,7 +69,6 @@ class ResponderEndpointServiceImpl internal constructor(private val clientOption private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ResponderEndpointCreateParams, @@ -85,7 +84,7 @@ class ResponderEndpointServiceImpl internal constructor(private val clientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -96,7 +95,7 @@ class ResponderEndpointServiceImpl internal constructor(private val clientOption } } - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val deleteHandler: Handler = emptyHandler() override fun delete( params: ResponderEndpointDeleteParams, @@ -112,12 +111,13 @@ class ResponderEndpointServiceImpl internal constructor(private val clientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { deleteHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } } private val checkStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkStatus( params: ResponderEndpointCheckStatusParams, @@ -132,7 +132,7 @@ class ResponderEndpointServiceImpl internal constructor(private val clientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { checkStatusHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationDecisioningServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationDecisioningServiceImpl.kt index fc2e303c4..88357b457 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationDecisioningServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationDecisioningServiceImpl.kt @@ -3,13 +3,13 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -54,7 +54,8 @@ internal constructor(private val clientOptions: ClientOptions) : TokenizationDec class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TokenizationDecisioningService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -64,7 +65,7 @@ internal constructor(private val clientOptions: ClientOptions) : TokenizationDec ) private val retrieveSecretHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieveSecret( params: TokenizationDecisioningRetrieveSecretParams, @@ -79,7 +80,7 @@ internal constructor(private val clientOptions: ClientOptions) : TokenizationDec .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveSecretHandler.handle(it) } .also { @@ -92,7 +93,6 @@ internal constructor(private val clientOptions: ClientOptions) : TokenizationDec private val rotateSecretHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun rotateSecret( params: TokenizationDecisioningRotateSecretParams, @@ -108,7 +108,7 @@ internal constructor(private val clientOptions: ClientOptions) : TokenizationDec .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { rotateSecretHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationServiceImpl.kt index c171298d2..bc9c44520 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationServiceImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -106,7 +105,8 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TokenizationService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -117,7 +117,6 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: TokenizationRetrieveParams, @@ -135,7 +134,7 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -148,7 +147,6 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: TokenizationListParams, @@ -163,7 +161,7 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -181,7 +179,7 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl } } - private val activateHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val activateHandler: Handler = emptyHandler() override fun activate( params: TokenizationActivateParams, @@ -200,11 +198,12 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { activateHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { activateHandler.handle(it) } + } } - private val deactivateHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val deactivateHandler: Handler = emptyHandler() override fun deactivate( params: TokenizationDeactivateParams, @@ -223,10 +222,12 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { deactivateHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { deactivateHandler.handle(it) } + } } - private val pauseHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val pauseHandler: Handler = emptyHandler() override fun pause( params: TokenizationPauseParams, @@ -245,11 +246,12 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { pauseHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { pauseHandler.handle(it) } + } } - private val resendActivationCodeHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val resendActivationCodeHandler: Handler = emptyHandler() override fun resendActivationCode( params: TokenizationResendActivationCodeParams, @@ -273,12 +275,13 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { resendActivationCodeHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { resendActivationCodeHandler.handle(it) } + } } private val simulateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulate( params: TokenizationSimulateParams, @@ -294,7 +297,7 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateHandler.handle(it) } .also { @@ -305,7 +308,7 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl } } - private val unpauseHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val unpauseHandler: Handler = emptyHandler() override fun unpause( params: TokenizationUnpauseParams, @@ -324,12 +327,13 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { unpauseHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { unpauseHandler.handle(it) } + } } private val updateDigitalCardArtHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams, @@ -353,7 +357,7 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateDigitalCardArtHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionServiceImpl.kt index 6179d6ca0..76f3e2a6f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionServiceImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -141,7 +140,8 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TransactionService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val enhancedCommercialData: EnhancedCommercialDataService.WithRawResponse by lazy { EnhancedCommercialDataServiceImpl.WithRawResponseImpl(clientOptions) @@ -164,7 +164,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli override fun events(): EventService.WithRawResponse = events private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: TransactionRetrieveParams, @@ -182,7 +182,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -195,7 +195,6 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: TransactionListParams, @@ -210,7 +209,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -228,8 +227,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli } } - private val expireAuthorizationHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val expireAuthorizationHandler: Handler = emptyHandler() override fun expireAuthorization( params: TransactionExpireAuthorizationParams, @@ -253,13 +251,14 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { expireAuthorizationHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { expireAuthorizationHandler.handle(it) } + } } private val simulateAuthorizationHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateAuthorization( params: TransactionSimulateAuthorizationParams, @@ -275,7 +274,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateAuthorizationHandler.handle(it) } .also { @@ -289,7 +288,6 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli private val simulateAuthorizationAdviceHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateAuthorizationAdvice( params: TransactionSimulateAuthorizationAdviceParams, @@ -305,7 +303,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateAuthorizationAdviceHandler.handle(it) } .also { @@ -318,7 +316,6 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli private val simulateClearingHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateClearing( params: TransactionSimulateClearingParams, @@ -334,7 +331,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateClearingHandler.handle(it) } .also { @@ -348,7 +345,6 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli private val simulateCreditAuthorizationHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams, @@ -364,7 +360,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateCreditAuthorizationHandler.handle(it) } .also { @@ -377,7 +373,6 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli private val simulateReturnHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateReturn( params: TransactionSimulateReturnParams, @@ -393,7 +388,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateReturnHandler.handle(it) } .also { @@ -407,7 +402,6 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli private val simulateReturnReversalHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateReturnReversal( params: TransactionSimulateReturnReversalParams, @@ -423,7 +417,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateReturnReversalHandler.handle(it) } .also { @@ -436,7 +430,6 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli private val simulateVoidHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulateVoid( params: TransactionSimulateVoidParams, @@ -452,7 +445,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateVoidHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransferServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransferServiceImpl.kt index 9716e0b04..9c02f9154 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransferServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransferServiceImpl.kt @@ -3,13 +3,13 @@ package com.lithic.api.services.blocking import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -39,7 +39,8 @@ class TransferServiceImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TransferService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -49,7 +50,7 @@ class TransferServiceImpl internal constructor(private val clientOptions: Client ) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) @Deprecated("deprecated") override fun create( @@ -66,7 +67,7 @@ class TransferServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt index 4dbc8f7b9..40b509bef 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.blocking.authRules import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -131,7 +130,8 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : V2Service.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val backtests: BacktestService.WithRawResponse by lazy { BacktestServiceImpl.WithRawResponseImpl(clientOptions) @@ -147,7 +147,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption override fun backtests(): BacktestService.WithRawResponse = backtests private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: AuthRuleV2CreateParams, @@ -163,7 +163,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -175,7 +175,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: AuthRuleV2RetrieveParams, @@ -193,7 +193,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -205,7 +205,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: AuthRuleV2UpdateParams, @@ -224,7 +224,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -237,7 +237,6 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: AuthRuleV2ListParams, @@ -252,7 +251,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -270,7 +269,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption } } - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val deleteHandler: Handler = emptyHandler() override fun delete( params: AuthRuleV2DeleteParams, @@ -289,11 +288,13 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { deleteHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } } private val applyHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) @Deprecated("deprecated") override fun apply( @@ -313,7 +314,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { applyHandler.handle(it) } .also { @@ -325,7 +326,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption } private val draftHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun draft( params: AuthRuleV2DraftParams, @@ -344,7 +345,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { draftHandler.handle(it) } .also { @@ -356,7 +357,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption } private val promoteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun promote( params: AuthRuleV2PromoteParams, @@ -375,7 +376,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { promoteHandler.handle(it) } .also { @@ -387,7 +388,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption } private val reportHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) @Deprecated("deprecated") override fun report( @@ -407,7 +408,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { reportHandler.handle(it) } .also { @@ -420,7 +421,6 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption private val retrieveReportHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveReport( params: AuthRuleV2RetrieveReportParams, @@ -438,7 +438,7 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveReportHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceImpl.kt index d7ae8ccf9..3f818fa69 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.authRules.v2 import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -52,7 +52,8 @@ class BacktestServiceImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BacktestService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -63,7 +64,6 @@ class BacktestServiceImpl internal constructor(private val clientOptions: Client private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AuthRuleV2BacktestCreateParams, @@ -82,7 +82,7 @@ class BacktestServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -94,7 +94,7 @@ class BacktestServiceImpl internal constructor(private val clientOptions: Client } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: AuthRuleV2BacktestRetrieveParams, @@ -118,7 +118,7 @@ class BacktestServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceServiceImpl.kt index 12ccf8f03..7835fdcc0 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceServiceImpl.kt @@ -3,13 +3,13 @@ package com.lithic.api.services.blocking.cards import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -41,7 +41,8 @@ class AggregateBalanceServiceImpl internal constructor(private val clientOptions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AggregateBalanceService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class AggregateBalanceServiceImpl internal constructor(private val clientOptions private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CardAggregateBalanceListParams, @@ -67,7 +67,7 @@ class AggregateBalanceServiceImpl internal constructor(private val clientOptions .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/BalanceServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/BalanceServiceImpl.kt index 1cbe6c326..760d3ef6b 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/BalanceServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/BalanceServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.cards import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -43,7 +43,8 @@ class BalanceServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BalanceService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +55,6 @@ class BalanceServiceImpl internal constructor(private val clientOptions: ClientO private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CardBalanceListParams, @@ -72,7 +72,7 @@ class BalanceServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionServiceImpl.kt index eadc86b2e..3cbe4eaac 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.cards import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -54,7 +54,8 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FinancialTransactionService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -65,7 +66,6 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: CardFinancialTransactionRetrieveParams, @@ -92,7 +92,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -105,7 +105,6 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CardFinancialTransactionListParams, @@ -123,7 +122,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/creditProducts/ExtendedCreditServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/creditProducts/ExtendedCreditServiceImpl.kt index 6853cf704..24055399a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/creditProducts/ExtendedCreditServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/creditProducts/ExtendedCreditServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.creditProducts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -42,7 +42,8 @@ class ExtendedCreditServiceImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ExtendedCreditService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,7 @@ class ExtendedCreditServiceImpl internal constructor(private val clientOptions: ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: CreditProductExtendedCreditRetrieveParams, @@ -75,7 +76,7 @@ class ExtendedCreditServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/creditProducts/PrimeRateServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/creditProducts/PrimeRateServiceImpl.kt index 190d70cad..3603514f6 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/creditProducts/PrimeRateServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/creditProducts/PrimeRateServiceImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.blocking.creditProducts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -54,7 +53,8 @@ class PrimeRateServiceImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : PrimeRateService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -63,7 +63,7 @@ class PrimeRateServiceImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val createHandler: Handler = emptyHandler() override fun create( params: CreditProductPrimeRateCreateParams, @@ -82,12 +82,13 @@ class PrimeRateServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { createHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { createHandler.handle(it) } + } } private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: CreditProductPrimeRateRetrieveParams, @@ -105,7 +106,7 @@ class PrimeRateServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/events/EventSubscriptionServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/events/EventSubscriptionServiceImpl.kt index 7d17ab89c..c8435cc5f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/events/EventSubscriptionServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/events/EventSubscriptionServiceImpl.kt @@ -3,12 +3,11 @@ package com.lithic.api.services.blocking.events import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -43,7 +42,8 @@ class EventSubscriptionServiceImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EventSubscriptionService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +52,7 @@ class EventSubscriptionServiceImpl internal constructor(private val clientOption clientOptions.toBuilder().apply(modifier::accept).build() ) - private val resendHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val resendHandler: Handler = emptyHandler() override fun resend( params: EventEventSubscriptionResendParams, @@ -78,7 +78,9 @@ class EventSubscriptionServiceImpl internal constructor(private val clientOption .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { resendHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { resendHandler.handle(it) } + } } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/events/SubscriptionServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/events/SubscriptionServiceImpl.kt index 7143397ec..2c1237094 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/events/SubscriptionServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/events/SubscriptionServiceImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.blocking.events import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -129,7 +128,8 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -139,7 +139,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl ) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: EventSubscriptionCreateParams, @@ -155,7 +155,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -167,7 +167,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: EventSubscriptionRetrieveParams, @@ -185,7 +185,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -197,7 +197,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: EventSubscriptionUpdateParams, @@ -216,7 +216,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -229,7 +229,6 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: EventSubscriptionListParams, @@ -244,7 +243,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -262,7 +261,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl } } - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val deleteHandler: Handler = emptyHandler() override fun delete( params: EventSubscriptionDeleteParams, @@ -281,12 +280,13 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { deleteHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } } private val listAttemptsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listAttempts( params: EventSubscriptionListAttemptsParams, @@ -304,7 +304,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listAttemptsHandler.handle(it) } .also { @@ -322,7 +322,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl } } - private val recoverHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val recoverHandler: Handler = emptyHandler() override fun recover( params: EventSubscriptionRecoverParams, @@ -341,11 +341,12 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { recoverHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { recoverHandler.handle(it) } + } } - private val replayMissingHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val replayMissingHandler: Handler = emptyHandler() override fun replayMissing( params: EventSubscriptionReplayMissingParams, @@ -369,12 +370,13 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { replayMissingHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { replayMissingHandler.handle(it) } + } } private val retrieveSecretHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveSecret( params: EventSubscriptionRetrieveSecretParams, @@ -392,7 +394,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveSecretHandler.handle(it) } .also { @@ -403,8 +405,7 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl } } - private val rotateSecretHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val rotateSecretHandler: Handler = emptyHandler() override fun rotateSecret( params: EventSubscriptionRotateSecretParams, @@ -429,11 +430,12 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { rotateSecretHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { rotateSecretHandler.handle(it) } + } } - private val sendSimulatedExampleHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val sendSimulatedExampleHandler: Handler = emptyHandler() override fun sendSimulatedExample( params: EventSubscriptionSendSimulatedExampleParams, @@ -458,7 +460,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { sendSimulatedExampleHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { sendSimulatedExampleHandler.handle(it) } + } } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/externalBankAccounts/MicroDepositServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/externalBankAccounts/MicroDepositServiceImpl.kt index b6845004b..4ee1687ef 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/externalBankAccounts/MicroDepositServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/externalBankAccounts/MicroDepositServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.externalBankAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -43,7 +43,8 @@ class MicroDepositServiceImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : MicroDepositService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +55,6 @@ class MicroDepositServiceImpl internal constructor(private val clientOptions: Cl private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ExternalBankAccountMicroDepositCreateParams, @@ -78,7 +78,7 @@ class MicroDepositServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/BalanceServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/BalanceServiceImpl.kt index e723c776c..9b2b4334a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/BalanceServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/BalanceServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.financialAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -43,7 +43,8 @@ class BalanceServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BalanceService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +55,6 @@ class BalanceServiceImpl internal constructor(private val clientOptions: ClientO private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: FinancialAccountBalanceListParams, @@ -72,7 +72,7 @@ class BalanceServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/CreditConfigurationServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/CreditConfigurationServiceImpl.kt index d8695d7b4..61ec43821 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/CreditConfigurationServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/CreditConfigurationServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.financialAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -53,7 +53,8 @@ internal constructor(private val clientOptions: ClientOptions) : CreditConfigura class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditConfigurationService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -64,7 +65,6 @@ internal constructor(private val clientOptions: ClientOptions) : CreditConfigura private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: FinancialAccountCreditConfigurationRetrieveParams, @@ -87,7 +87,7 @@ internal constructor(private val clientOptions: ClientOptions) : CreditConfigura .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -100,7 +100,6 @@ internal constructor(private val clientOptions: ClientOptions) : CreditConfigura private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: FinancialAccountCreditConfigurationUpdateParams, @@ -124,7 +123,7 @@ internal constructor(private val clientOptions: ClientOptions) : CreditConfigura .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/FinancialTransactionServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/FinancialTransactionServiceImpl.kt index 3ecd608b2..e0ba1a35a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/FinancialTransactionServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/FinancialTransactionServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.financialAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -55,7 +55,8 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FinancialTransactionService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -66,7 +67,6 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: FinancialTransactionRetrieveParams, @@ -93,7 +93,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -106,7 +106,6 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: FinancialTransactionListParams, @@ -129,7 +128,7 @@ internal constructor(private val clientOptions: ClientOptions) : FinancialTransa .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/LoanTapeServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/LoanTapeServiceImpl.kt index 7ece2cfbd..b13c052b8 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/LoanTapeServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/LoanTapeServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.financialAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -52,7 +52,8 @@ class LoanTapeServiceImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LoanTapeService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -62,7 +63,7 @@ class LoanTapeServiceImpl internal constructor(private val clientOptions: Client ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: FinancialAccountLoanTapeRetrieveParams, @@ -86,7 +87,7 @@ class LoanTapeServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -99,7 +100,6 @@ class LoanTapeServiceImpl internal constructor(private val clientOptions: Client private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: FinancialAccountLoanTapeListParams, @@ -117,7 +117,7 @@ class LoanTapeServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementServiceImpl.kt index ee5b46be5..c5b1c50aa 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.financialAccounts import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -58,7 +58,8 @@ class StatementServiceImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : StatementService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val lineItems: LineItemService.WithRawResponse by lazy { LineItemServiceImpl.WithRawResponseImpl(clientOptions) @@ -74,7 +75,7 @@ class StatementServiceImpl internal constructor(private val clientOptions: Clien override fun lineItems(): LineItemService.WithRawResponse = lineItems private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: FinancialAccountStatementRetrieveParams, @@ -98,7 +99,7 @@ class StatementServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -110,7 +111,7 @@ class StatementServiceImpl internal constructor(private val clientOptions: Clien } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: FinancialAccountStatementListParams, @@ -128,7 +129,7 @@ class StatementServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemServiceImpl.kt index 2f5bbd08d..396b77f6b 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.financialAccounts.statements import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -44,7 +44,8 @@ class LineItemServiceImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LineItemService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +55,7 @@ class LineItemServiceImpl internal constructor(private val clientOptions: Client ) private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: FinancialAccountStatementLineItemListParams, @@ -79,7 +80,7 @@ class LineItemServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/fraud/TransactionServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/fraud/TransactionServiceImpl.kt index adaef4739..39a4ac5b0 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/fraud/TransactionServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/fraud/TransactionServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.fraud import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.json @@ -52,7 +52,8 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TransactionService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -63,7 +64,6 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: FraudTransactionRetrieveParams, @@ -81,7 +81,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -94,7 +94,6 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli private val reportHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun report( params: FraudTransactionReportParams, @@ -113,7 +112,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { reportHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/SettlementServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/SettlementServiceImpl.kt index dd24f3429..e71fd4cd3 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/SettlementServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/SettlementServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.reports import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -60,7 +60,8 @@ class SettlementServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SettlementService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val networkTotals: NetworkTotalService.WithRawResponse by lazy { NetworkTotalServiceImpl.WithRawResponseImpl(clientOptions) @@ -77,7 +78,6 @@ class SettlementServiceImpl internal constructor(private val clientOptions: Clie private val listDetailsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listDetails( params: ReportSettlementListDetailsParams, @@ -95,7 +95,7 @@ class SettlementServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listDetailsHandler.handle(it) } .also { @@ -114,7 +114,7 @@ class SettlementServiceImpl internal constructor(private val clientOptions: Clie } private val summaryHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun summary( params: ReportSettlementSummaryParams, @@ -132,7 +132,7 @@ class SettlementServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { summaryHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalServiceImpl.kt index 440a618fe..4fac7e5d9 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.reports.settlement import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -52,7 +52,8 @@ class NetworkTotalServiceImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : NetworkTotalService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -63,7 +64,6 @@ class NetworkTotalServiceImpl internal constructor(private val clientOptions: Cl private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams, @@ -87,7 +87,7 @@ class NetworkTotalServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -100,7 +100,6 @@ class NetworkTotalServiceImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: ReportSettlementNetworkTotalListParams, @@ -115,7 +114,7 @@ class NetworkTotalServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceImpl.kt index ef3f7b3e0..7a166c579 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceImpl.kt @@ -3,13 +3,12 @@ package com.lithic.api.services.blocking.threeDS import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -63,7 +62,8 @@ class AuthenticationServiceImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AuthenticationService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -74,7 +74,6 @@ class AuthenticationServiceImpl internal constructor(private val clientOptions: private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ThreeDSAuthenticationRetrieveParams, @@ -95,7 +94,7 @@ class AuthenticationServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -108,7 +107,6 @@ class AuthenticationServiceImpl internal constructor(private val clientOptions: private val simulateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun simulate( params: ThreeDSAuthenticationSimulateParams, @@ -124,7 +122,7 @@ class AuthenticationServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { simulateHandler.handle(it) } .also { @@ -135,8 +133,7 @@ class AuthenticationServiceImpl internal constructor(private val clientOptions: } } - private val simulateOtpEntryHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val simulateOtpEntryHandler: Handler = emptyHandler() override fun simulateOtpEntry( params: ThreeDSAuthenticationSimulateOtpEntryParams, @@ -152,7 +149,9 @@ class AuthenticationServiceImpl internal constructor(private val clientOptions: .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { simulateOtpEntryHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { simulateOtpEntryHandler.handle(it) } + } } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/DecisioningServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/DecisioningServiceImpl.kt index 427dda73c..635f6c1ad 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/DecisioningServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/DecisioningServiceImpl.kt @@ -3,12 +3,11 @@ package com.lithic.api.services.blocking.threeDS import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest import com.lithic.api.core.http.HttpResponse @@ -61,7 +60,8 @@ class DecisioningServiceImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DecisioningService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -70,8 +70,7 @@ class DecisioningServiceImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) - private val challengeResponseHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val challengeResponseHandler: Handler = emptyHandler() override fun challengeResponse( params: ThreeDSDecisioningChallengeResponseParams, @@ -87,12 +86,13 @@ class DecisioningServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { challengeResponseHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { challengeResponseHandler.handle(it) } + } } private val retrieveSecretHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveSecret( params: ThreeDSDecisioningRetrieveSecretParams, @@ -107,7 +107,7 @@ class DecisioningServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveSecretHandler.handle(it) } .also { @@ -118,8 +118,7 @@ class DecisioningServiceImpl internal constructor(private val clientOptions: Cli } } - private val rotateSecretHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + private val rotateSecretHandler: Handler = emptyHandler() override fun rotateSecret( params: ThreeDSDecisioningRotateSecretParams, @@ -135,7 +134,9 @@ class DecisioningServiceImpl internal constructor(private val clientOptions: Cli .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { rotateSecretHandler.handle(it) } } + return errorHandler.handle(response).parseable { + response.use { rotateSecretHandler.handle(it) } + } } } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/transactions/EnhancedCommercialDataServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/transactions/EnhancedCommercialDataServiceImpl.kt index 781edb1bc..262160ac0 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/transactions/EnhancedCommercialDataServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/transactions/EnhancedCommercialDataServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.transactions import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -44,7 +44,8 @@ internal constructor(private val clientOptions: ClientOptions) : EnhancedCommerc class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EnhancedCommercialDataService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,6 @@ internal constructor(private val clientOptions: ClientOptions) : EnhancedCommerc private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: TransactionEnhancedCommercialDataRetrieveParams, @@ -78,7 +78,7 @@ internal constructor(private val clientOptions: ClientOptions) : EnhancedCommerc .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/transactions/events/EnhancedCommercialDataServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/transactions/events/EnhancedCommercialDataServiceImpl.kt index b7fa3dab6..dfffce742 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/transactions/events/EnhancedCommercialDataServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/transactions/events/EnhancedCommercialDataServiceImpl.kt @@ -3,14 +3,14 @@ package com.lithic.api.services.blocking.transactions.events import com.lithic.api.core.ClientOptions -import com.lithic.api.core.JsonValue import com.lithic.api.core.RequestOptions import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler import com.lithic.api.core.handlers.errorHandler import com.lithic.api.core.handlers.jsonHandler -import com.lithic.api.core.handlers.withErrorHandler import com.lithic.api.core.http.HttpMethod import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable @@ -44,7 +44,8 @@ internal constructor(private val clientOptions: ClientOptions) : EnhancedCommerc class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EnhancedCommercialDataService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +55,7 @@ internal constructor(private val clientOptions: ClientOptions) : EnhancedCommerc ) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: TransactionEventEnhancedCommercialDataRetrieveParams, @@ -78,7 +79,7 @@ internal constructor(private val clientOptions: ClientOptions) : EnhancedCommerc .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt index 736bd21f9..ef6fd511e 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt @@ -117,6 +117,62 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Test + fun cardsCreate400WithRawResponse() { + val cardService = client.cards().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + cardService.create( + CardCreateParams.builder() + .type(CardCreateParams.Type.VIRTUAL) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expMonth("06") + .expYear("2027") + .memo("New Card") + .pin("pin") + .productId("1") + .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") + .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) + .shippingAddress( + ShippingAddress.builder() + .address1("5 Broad Street") + .city("NEW YORK") + .country("USA") + .firstName("Michael") + .lastName("Bluth") + .postalCode("10001-1809") + .state("NY") + .address2("Unit 25A") + .email("johnny@appleseed.com") + .line2Text("The Bluth Company") + .phoneNumber("+15555555555") + .build() + ) + .shippingMethod(CardCreateParams.ShippingMethod._2_DAY) + .spendLimit(1000L) + .spendLimitDuration(SpendLimitDuration.TRANSACTION) + .state(CardCreateParams.State.OPEN) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun cardsCreate401() { val cardService = client.cards() @@ -173,6 +229,62 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Test + fun cardsCreate401WithRawResponse() { + val cardService = client.cards().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + cardService.create( + CardCreateParams.builder() + .type(CardCreateParams.Type.VIRTUAL) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expMonth("06") + .expYear("2027") + .memo("New Card") + .pin("pin") + .productId("1") + .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") + .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) + .shippingAddress( + ShippingAddress.builder() + .address1("5 Broad Street") + .city("NEW YORK") + .country("USA") + .firstName("Michael") + .lastName("Bluth") + .postalCode("10001-1809") + .state("NY") + .address2("Unit 25A") + .email("johnny@appleseed.com") + .line2Text("The Bluth Company") + .phoneNumber("+15555555555") + .build() + ) + .shippingMethod(CardCreateParams.ShippingMethod._2_DAY) + .spendLimit(1000L) + .spendLimitDuration(SpendLimitDuration.TRANSACTION) + .state(CardCreateParams.State.OPEN) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun cardsCreate403() { val cardService = client.cards() @@ -229,6 +341,62 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Test + fun cardsCreate403WithRawResponse() { + val cardService = client.cards().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + cardService.create( + CardCreateParams.builder() + .type(CardCreateParams.Type.VIRTUAL) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expMonth("06") + .expYear("2027") + .memo("New Card") + .pin("pin") + .productId("1") + .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") + .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) + .shippingAddress( + ShippingAddress.builder() + .address1("5 Broad Street") + .city("NEW YORK") + .country("USA") + .firstName("Michael") + .lastName("Bluth") + .postalCode("10001-1809") + .state("NY") + .address2("Unit 25A") + .email("johnny@appleseed.com") + .line2Text("The Bluth Company") + .phoneNumber("+15555555555") + .build() + ) + .shippingMethod(CardCreateParams.ShippingMethod._2_DAY) + .spendLimit(1000L) + .spendLimitDuration(SpendLimitDuration.TRANSACTION) + .state(CardCreateParams.State.OPEN) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun cardsCreate404() { val cardService = client.cards() @@ -285,6 +453,62 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Test + fun cardsCreate404WithRawResponse() { + val cardService = client.cards().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + cardService.create( + CardCreateParams.builder() + .type(CardCreateParams.Type.VIRTUAL) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expMonth("06") + .expYear("2027") + .memo("New Card") + .pin("pin") + .productId("1") + .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") + .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) + .shippingAddress( + ShippingAddress.builder() + .address1("5 Broad Street") + .city("NEW YORK") + .country("USA") + .firstName("Michael") + .lastName("Bluth") + .postalCode("10001-1809") + .state("NY") + .address2("Unit 25A") + .email("johnny@appleseed.com") + .line2Text("The Bluth Company") + .phoneNumber("+15555555555") + .build() + ) + .shippingMethod(CardCreateParams.ShippingMethod._2_DAY) + .spendLimit(1000L) + .spendLimitDuration(SpendLimitDuration.TRANSACTION) + .state(CardCreateParams.State.OPEN) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun cardsCreate422() { val cardService = client.cards() @@ -341,6 +565,62 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Test + fun cardsCreate422WithRawResponse() { + val cardService = client.cards().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + cardService.create( + CardCreateParams.builder() + .type(CardCreateParams.Type.VIRTUAL) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expMonth("06") + .expYear("2027") + .memo("New Card") + .pin("pin") + .productId("1") + .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") + .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) + .shippingAddress( + ShippingAddress.builder() + .address1("5 Broad Street") + .city("NEW YORK") + .country("USA") + .firstName("Michael") + .lastName("Bluth") + .postalCode("10001-1809") + .state("NY") + .address2("Unit 25A") + .email("johnny@appleseed.com") + .line2Text("The Bluth Company") + .phoneNumber("+15555555555") + .build() + ) + .shippingMethod(CardCreateParams.ShippingMethod._2_DAY) + .spendLimit(1000L) + .spendLimitDuration(SpendLimitDuration.TRANSACTION) + .state(CardCreateParams.State.OPEN) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun cardsCreate429() { val cardService = client.cards() @@ -397,6 +677,62 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Test + fun cardsCreate429WithRawResponse() { + val cardService = client.cards().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + cardService.create( + CardCreateParams.builder() + .type(CardCreateParams.Type.VIRTUAL) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expMonth("06") + .expYear("2027") + .memo("New Card") + .pin("pin") + .productId("1") + .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") + .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) + .shippingAddress( + ShippingAddress.builder() + .address1("5 Broad Street") + .city("NEW YORK") + .country("USA") + .firstName("Michael") + .lastName("Bluth") + .postalCode("10001-1809") + .state("NY") + .address2("Unit 25A") + .email("johnny@appleseed.com") + .line2Text("The Bluth Company") + .phoneNumber("+15555555555") + .build() + ) + .shippingMethod(CardCreateParams.ShippingMethod._2_DAY) + .spendLimit(1000L) + .spendLimitDuration(SpendLimitDuration.TRANSACTION) + .state(CardCreateParams.State.OPEN) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun cardsCreate500() { val cardService = client.cards() @@ -453,6 +789,62 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Test + fun cardsCreate500WithRawResponse() { + val cardService = client.cards().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + cardService.create( + CardCreateParams.builder() + .type(CardCreateParams.Type.VIRTUAL) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expMonth("06") + .expYear("2027") + .memo("New Card") + .pin("pin") + .productId("1") + .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") + .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) + .shippingAddress( + ShippingAddress.builder() + .address1("5 Broad Street") + .city("NEW YORK") + .country("USA") + .firstName("Michael") + .lastName("Bluth") + .postalCode("10001-1809") + .state("NY") + .address2("Unit 25A") + .email("johnny@appleseed.com") + .line2Text("The Bluth Company") + .phoneNumber("+15555555555") + .build() + ) + .shippingMethod(CardCreateParams.ShippingMethod._2_DAY) + .spendLimit(1000L) + .spendLimitDuration(SpendLimitDuration.TRANSACTION) + .state(CardCreateParams.State.OPEN) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun cardsCreate999() { val cardService = client.cards() @@ -509,6 +901,62 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Test + fun cardsCreate999WithRawResponse() { + val cardService = client.cards().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + cardService.create( + CardCreateParams.builder() + .type(CardCreateParams.Type.VIRTUAL) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expMonth("06") + .expYear("2027") + .memo("New Card") + .pin("pin") + .productId("1") + .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") + .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) + .shippingAddress( + ShippingAddress.builder() + .address1("5 Broad Street") + .city("NEW YORK") + .country("USA") + .firstName("Michael") + .lastName("Bluth") + .postalCode("10001-1809") + .state("NY") + .address2("Unit 25A") + .email("johnny@appleseed.com") + .line2Text("The Bluth Company") + .phoneNumber("+15555555555") + .build() + ) + .shippingMethod(CardCreateParams.ShippingMethod._2_DAY) + .spendLimit(1000L) + .spendLimitDuration(SpendLimitDuration.TRANSACTION) + .state(CardCreateParams.State.OPEN) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun cardsCreateInvalidJsonBody() { val cardService = client.cards() diff --git a/lithic-java-example/build.gradle.kts b/lithic-java-example/build.gradle.kts index 04cd9e76d..810bfa9f9 100644 --- a/lithic-java-example/build.gradle.kts +++ b/lithic-java-example/build.gradle.kts @@ -17,5 +17,12 @@ tasks.withType().configureEach { } application { - mainClass = "com.lithic.api.example.Main" + // Use `./gradlew :lithic-java-example:run` to run `Main` + // Use `./gradlew :lithic-java-example:run -Dexample=Something` to run `SomethingExample` + mainClass = "com.lithic.api.example.${ + if (project.hasProperty("example")) + "${project.property("example")}Example" + else + "Main" + }" }