Skip to content

Commit ead6b82

Browse files
feat(api): dispute upload custom method
feat(api): dispute upload custom method
1 parent fb72f88 commit ead6b82

25 files changed

Lines changed: 1165 additions & 2 deletions

lithic-java-client-okhttp/src/main/kotlin/com/lithic/api/client/okhttp/LithicOkHttpClient.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ class LithicOkHttpClient private constructor() {
2525

2626
fun sandbox() = apply { baseUrl(ClientOptions.SANDBOX_URL) }
2727

28-
fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl }
28+
fun baseUrl(baseUrl: String) = apply {
29+
clientOptions.baseUrl(baseUrl)
30+
this.baseUrl = baseUrl
31+
}
2932

3033
fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) }
3134

lithic-java-client-okhttp/src/main/kotlin/com/lithic/api/client/okhttp/LithicOkHttpClientAsync.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ class LithicOkHttpClientAsync private constructor() {
2525

2626
fun sandbox() = apply { baseUrl(ClientOptions.SANDBOX_URL) }
2727

28-
fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl }
28+
fun baseUrl(baseUrl: String) = apply {
29+
clientOptions.baseUrl(baseUrl)
30+
this.baseUrl = baseUrl
31+
}
2932

3033
fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) }
3134

lithic-java-client-okhttp/src/main/kotlin/com/lithic/api/client/okhttp/OkHttpClient.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
8787
}
8888

8989
private fun HttpRequest.toUrl(): String {
90+
url?.let {
91+
return it
92+
}
93+
9094
val builder = baseUrl.newBuilder()
9195
pathSegments.forEach(builder::addPathSegment)
9296
queryParams.forEach(builder::addQueryParameter)

lithic-java-core/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ dependencies {
1111
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.1")
1212
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.1")
1313
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.1")
14+
implementation("org.apache.httpcomponents.core5:httpcore5:5.2.1")
15+
implementation("org.apache.httpcomponents.client5:httpclient5:5.2.1")
1416

1517
testImplementation(kotlin("test"))
1618
testImplementation(project(":lithic-java-client-okhttp"))

lithic-java-core/src/main/kotlin/com/lithic/api/core/ClientOptions.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ private constructor(
1212
@get:JvmName("httpClient") val httpClient: HttpClient,
1313
@get:JvmName("jsonMapper") val jsonMapper: JsonMapper,
1414
@get:JvmName("clock") val clock: Clock,
15+
@get:JvmName("baseUrl") val baseUrl: String,
16+
@get:JvmName("apiKey") val apiKey: String,
1517
@get:JvmName("headers") val headers: ListMultimap<String, String>,
1618
@get:JvmName("responseValidation") val responseValidation: Boolean,
1719
@get:JvmName("webhookSecret") val webhookSecret: String?,
@@ -33,6 +35,7 @@ private constructor(
3335
private var httpClient: HttpClient? = null
3436
private var jsonMapper: JsonMapper? = null
3537
private var clock: Clock = Clock.systemUTC()
38+
private var baseUrl: String = PRODUCTION_URL
3639
private var headers: MutableMap<String, MutableList<String>> = mutableMapOf()
3740
private var responseValidation: Boolean = false
3841
private var maxRetries: Int = 2
@@ -43,6 +46,8 @@ private constructor(
4346

4447
fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper }
4548

49+
fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl }
50+
4651
fun clock(clock: Clock) = apply { this.clock = clock }
4752

4853
fun headers(headers: Map<String, Iterable<String>>) = apply {
@@ -102,6 +107,8 @@ private constructor(
102107
.build(),
103108
jsonMapper ?: jsonMapper(),
104109
clock,
110+
baseUrl,
111+
apiKey!!,
105112
headers.toUnmodifiable(),
106113
responseValidation,
107114
webhookSecret,

lithic-java-core/src/main/kotlin/com/lithic/api/core/http/HttpRequest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.lithic.api.core.toUnmodifiable
99
class HttpRequest
1010
private constructor(
1111
@get:JvmName("method") val method: HttpMethod,
12+
@get:JvmName("url") val url: String?,
1213
@get:JvmName("pathSegments") val pathSegments: List<String>,
1314
@get:JvmName("queryParams") val queryParams: ListMultimap<String, String>,
1415
@get:JvmName("headers") val headers: ListMultimap<String, String>,
@@ -25,6 +26,7 @@ private constructor(
2526
class Builder {
2627

2728
private var method: HttpMethod? = null
29+
private var url: String? = null
2830
private var pathSegments: MutableList<String> = ArrayList()
2931
private var queryParams: ListMultimap<String, String> = ArrayListMultimap.create()
3032
private var body: HttpRequestBody? = null
@@ -33,6 +35,8 @@ private constructor(
3335

3436
fun method(method: HttpMethod) = apply { this.method = method }
3537

38+
fun url(url: String) = apply { this.url = url }
39+
3640
fun addPathSegment(pathSegment: String) = apply { this.pathSegments.add(pathSegment) }
3741

3842
fun addPathSegments(vararg pathSegments: String) = apply {
@@ -78,6 +82,7 @@ private constructor(
7882
fun build(): HttpRequest =
7983
HttpRequest(
8084
checkNotNull(method) { "`method` is required but was not set" },
85+
url,
8186
pathSegments.toUnmodifiable(),
8287
queryParams.toUnmodifiable(),
8388
headers,

0 commit comments

Comments
 (0)