Skip to content

Commit 1835a3b

Browse files
feat(client): add convenience overloads for some methods
1 parent 47a39c4 commit 1835a3b

File tree

4 files changed

+76
-16
lines changed

4 files changed

+76
-16
lines changed

lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/DecisioningServiceAsync.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.lithic.api.core.ClientOptions
66
import com.lithic.api.core.RequestOptions
77
import com.lithic.api.core.http.HttpResponse
88
import com.lithic.api.core.http.HttpResponseFor
9+
import com.lithic.api.models.ChallengeResponse
910
import com.lithic.api.models.DecisioningRetrieveSecretResponse
1011
import com.lithic.api.models.ThreeDSDecisioningChallengeResponseParams
1112
import com.lithic.api.models.ThreeDSDecisioningRetrieveSecretParams
@@ -43,6 +44,22 @@ interface DecisioningServiceAsync {
4344
requestOptions: RequestOptions = RequestOptions.none(),
4445
): CompletableFuture<Void?>
4546

47+
/** @see challengeResponse */
48+
fun challengeResponse(
49+
challengeResponse: ChallengeResponse,
50+
requestOptions: RequestOptions = RequestOptions.none(),
51+
): CompletableFuture<Void?> =
52+
challengeResponse(
53+
ThreeDSDecisioningChallengeResponseParams.builder()
54+
.challengeResponse(challengeResponse)
55+
.build(),
56+
requestOptions,
57+
)
58+
59+
/** @see challengeResponse */
60+
fun challengeResponse(challengeResponse: ChallengeResponse): CompletableFuture<Void?> =
61+
challengeResponse(challengeResponse, RequestOptions.none())
62+
4663
/**
4764
* Retrieve the 3DS Decisioning HMAC secret key. If one does not exist for your program yet,
4865
* calling this endpoint will create one for you. The headers (which you can use to verify 3DS
@@ -127,6 +144,24 @@ interface DecisioningServiceAsync {
127144
requestOptions: RequestOptions = RequestOptions.none(),
128145
): CompletableFuture<HttpResponse>
129146

147+
/** @see challengeResponse */
148+
fun challengeResponse(
149+
challengeResponse: ChallengeResponse,
150+
requestOptions: RequestOptions = RequestOptions.none(),
151+
): CompletableFuture<HttpResponse> =
152+
challengeResponse(
153+
ThreeDSDecisioningChallengeResponseParams.builder()
154+
.challengeResponse(challengeResponse)
155+
.build(),
156+
requestOptions,
157+
)
158+
159+
/** @see challengeResponse */
160+
fun challengeResponse(
161+
challengeResponse: ChallengeResponse
162+
): CompletableFuture<HttpResponse> =
163+
challengeResponse(challengeResponse, RequestOptions.none())
164+
130165
/**
131166
* Returns a raw HTTP response for `get /v1/three_ds_decisioning/secret`, but is otherwise
132167
* the same as [DecisioningServiceAsync.retrieveSecret].

lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/DecisioningService.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.lithic.api.core.ClientOptions
77
import com.lithic.api.core.RequestOptions
88
import com.lithic.api.core.http.HttpResponse
99
import com.lithic.api.core.http.HttpResponseFor
10+
import com.lithic.api.models.ChallengeResponse
1011
import com.lithic.api.models.DecisioningRetrieveSecretResponse
1112
import com.lithic.api.models.ThreeDSDecisioningChallengeResponseParams
1213
import com.lithic.api.models.ThreeDSDecisioningRetrieveSecretParams
@@ -42,6 +43,22 @@ interface DecisioningService {
4243
requestOptions: RequestOptions = RequestOptions.none(),
4344
)
4445

46+
/** @see challengeResponse */
47+
fun challengeResponse(
48+
challengeResponse: ChallengeResponse,
49+
requestOptions: RequestOptions = RequestOptions.none(),
50+
) =
51+
challengeResponse(
52+
ThreeDSDecisioningChallengeResponseParams.builder()
53+
.challengeResponse(challengeResponse)
54+
.build(),
55+
requestOptions,
56+
)
57+
58+
/** @see challengeResponse */
59+
fun challengeResponse(challengeResponse: ChallengeResponse) =
60+
challengeResponse(challengeResponse, RequestOptions.none())
61+
4562
/**
4663
* Retrieve the 3DS Decisioning HMAC secret key. If one does not exist for your program yet,
4764
* calling this endpoint will create one for you. The headers (which you can use to verify 3DS
@@ -122,6 +139,24 @@ interface DecisioningService {
122139
requestOptions: RequestOptions = RequestOptions.none(),
123140
): HttpResponse
124141

142+
/** @see challengeResponse */
143+
@MustBeClosed
144+
fun challengeResponse(
145+
challengeResponse: ChallengeResponse,
146+
requestOptions: RequestOptions = RequestOptions.none(),
147+
): HttpResponse =
148+
challengeResponse(
149+
ThreeDSDecisioningChallengeResponseParams.builder()
150+
.challengeResponse(challengeResponse)
151+
.build(),
152+
requestOptions,
153+
)
154+
155+
/** @see challengeResponse */
156+
@MustBeClosed
157+
fun challengeResponse(challengeResponse: ChallengeResponse): HttpResponse =
158+
challengeResponse(challengeResponse, RequestOptions.none())
159+
125160
/**
126161
* Returns a raw HTTP response for `get /v1/three_ds_decisioning/secret`, but is otherwise
127162
* the same as [DecisioningService.retrieveSecret].

lithic-java-core/src/test/kotlin/com/lithic/api/services/async/threeDS/DecisioningServiceAsyncTest.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.lithic.api.TestServerExtension
66
import com.lithic.api.client.okhttp.LithicOkHttpClientAsync
77
import com.lithic.api.models.ChallengeResponse
88
import com.lithic.api.models.ChallengeResult
9-
import com.lithic.api.models.ThreeDSDecisioningChallengeResponseParams
109
import org.junit.jupiter.api.Test
1110
import org.junit.jupiter.api.extension.ExtendWith
1211

@@ -24,13 +23,9 @@ internal class DecisioningServiceAsyncTest {
2423

2524
val future =
2625
decisioningServiceAsync.challengeResponse(
27-
ThreeDSDecisioningChallengeResponseParams.builder()
28-
.challengeResponse(
29-
ChallengeResponse.builder()
30-
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
31-
.challengeResponse(ChallengeResult.APPROVE)
32-
.build()
33-
)
26+
ChallengeResponse.builder()
27+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
28+
.challengeResponse(ChallengeResult.APPROVE)
3429
.build()
3530
)
3631

lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/threeDS/DecisioningServiceTest.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.lithic.api.TestServerExtension
66
import com.lithic.api.client.okhttp.LithicOkHttpClient
77
import com.lithic.api.models.ChallengeResponse
88
import com.lithic.api.models.ChallengeResult
9-
import com.lithic.api.models.ThreeDSDecisioningChallengeResponseParams
109
import org.junit.jupiter.api.Test
1110
import org.junit.jupiter.api.extension.ExtendWith
1211

@@ -23,13 +22,9 @@ internal class DecisioningServiceTest {
2322
val decisioningService = client.threeDS().decisioning()
2423

2524
decisioningService.challengeResponse(
26-
ThreeDSDecisioningChallengeResponseParams.builder()
27-
.challengeResponse(
28-
ChallengeResponse.builder()
29-
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
30-
.challengeResponse(ChallengeResult.APPROVE)
31-
.build()
32-
)
25+
ChallengeResponse.builder()
26+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
27+
.challengeResponse(ChallengeResult.APPROVE)
3328
.build()
3429
)
3530
}

0 commit comments

Comments
 (0)