Skip to content

Commit 6daf285

Browse files
committed
chore(internal): rearrange client arguments (#97)
1 parent 5b476a8 commit 6daf285

29 files changed

Lines changed: 100 additions & 104 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ implementation("com.lithic.api:lithic-java:0.13.2")
4545
Use `LithicOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()`:
4646

4747
```java
48-
import com.lithic.api.client.LithicClient;
48+
import com.lithic.api.client.LithicOkHttpClient;
4949
import com.lithic.api.client.okhttp.LithicOkHttpClient;
5050

5151
LithicClient client = LithicOkHttpClient.builder()
52-
.apiKey("<your API Key>")
52+
.apiKey("My Lithic API Key")
5353
.build();
5454
```
5555

56-
Alternately, use `LithicOkHttpClient.fromEnv()` to read client arguments from environment variables:
56+
Alternately, set the environment with `LITHIC_API_KEY` or `LITHIC_WEBHOOK_SECRET`, and use `LithicOkHttpClient.fromEnv()` to read from the environment.
5757

5858
```java
5959
LithicClient client = LithicOkHttpClient.fromEnv();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class LithicOkHttpClient private constructor() {
3838

3939
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
4040

41-
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
42-
4341
fun headers(headers: Map<String, Iterable<String>>) = apply {
4442
clientOptions.headers(headers)
4543
}
@@ -66,6 +64,8 @@ class LithicOkHttpClient private constructor() {
6664
clientOptions.responseValidation(responseValidation)
6765
}
6866

67+
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
68+
6969
fun webhookSecret(webhookSecret: String?) = apply {
7070
clientOptions.webhookSecret(webhookSecret)
7171
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class LithicOkHttpClientAsync private constructor() {
3838

3939
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
4040

41-
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
42-
4341
fun headers(headers: Map<String, Iterable<String>>) = apply {
4442
clientOptions.headers(headers)
4543
}
@@ -66,6 +64,8 @@ class LithicOkHttpClientAsync private constructor() {
6664
clientOptions.responseValidation(responseValidation)
6765
}
6866

67+
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
68+
6969
fun webhookSecret(webhookSecret: String?) = apply {
7070
clientOptions.webhookSecret(webhookSecret)
7171
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ private constructor(
1616
@get:JvmName("clock") val clock: Clock,
1717
@get:JvmName("baseUrl") val baseUrl: String,
1818
@get:JvmName("apiKey") val apiKey: String,
19+
@get:JvmName("webhookSecret") val webhookSecret: String?,
1920
@get:JvmName("headers") val headers: ListMultimap<String, String>,
2021
@get:JvmName("responseValidation") val responseValidation: Boolean,
21-
@get:JvmName("webhookSecret") val webhookSecret: String?,
2222
) {
2323

2424
companion object {
@@ -112,9 +112,9 @@ private constructor(
112112
clock,
113113
baseUrl,
114114
apiKey!!,
115+
webhookSecret,
115116
headers.toUnmodifiable(),
116117
responseValidation,
117-
webhookSecret,
118118
)
119119
}
120120
}

lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ class ErrorHandlingTest {
4141

4242
private val JSON_MAPPER: JsonMapper = jsonMapper()
4343

44-
private val API_KEY: String = "apiKey"
45-
4644
private val LITHIC_ERROR: LithicError =
4745
LithicError.builder().putAdditionalProperty("key", JsonString.of("value")).build()
4846

@@ -52,9 +50,9 @@ class ErrorHandlingTest {
5250
fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) {
5351
client =
5452
LithicOkHttpClient.builder()
55-
.apiKey(API_KEY)
5653
.baseUrl(wmRuntimeInfo.getHttpBaseUrl())
57-
.webhookSecret("string")
54+
.apiKey("My Lithic API Key")
55+
.webhookSecret("My Webhook Secret")
5856
.build()
5957
}
6058

lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,15 @@ class ServiceParamsTest {
3232

3333
private val JSON_MAPPER: JsonMapper = jsonMapper()
3434

35-
private val API_KEY: String = "apiKey"
36-
3735
private lateinit var client: LithicClient
3836

3937
@BeforeEach
4038
fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) {
4139
client =
4240
LithicOkHttpClient.builder()
43-
.apiKey(API_KEY)
41+
.apiKey("My Lithic API Key")
42+
.webhookSecret("My Webhook Secret")
4443
.baseUrl(wmRuntimeInfo.getHttpBaseUrl())
45-
.webhookSecret("string")
4644
.build()
4745
}
4846

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AccountHolderServiceTest {
1616
val client =
1717
LithicOkHttpClient.builder()
1818
.baseUrl(TestServerExtension.BASE_URL)
19-
.apiKey("test-api-key")
19+
.apiKey("My Lithic API Key")
2020
.build()
2121
val accountHolderService = client.accountHolders()
2222
val accountHolder =
@@ -126,7 +126,7 @@ class AccountHolderServiceTest {
126126
val client =
127127
LithicOkHttpClient.builder()
128128
.baseUrl(TestServerExtension.BASE_URL)
129-
.apiKey("test-api-key")
129+
.apiKey("My Lithic API Key")
130130
.build()
131131
val accountHolderService = client.accountHolders()
132132
val accountHolder =
@@ -144,7 +144,7 @@ class AccountHolderServiceTest {
144144
val client =
145145
LithicOkHttpClient.builder()
146146
.baseUrl(TestServerExtension.BASE_URL)
147-
.apiKey("test-api-key")
147+
.apiKey("My Lithic API Key")
148148
.build()
149149
val accountHolderService = client.accountHolders()
150150
val accountHolderUpdateResponse =
@@ -165,7 +165,7 @@ class AccountHolderServiceTest {
165165
val client =
166166
LithicOkHttpClient.builder()
167167
.baseUrl(TestServerExtension.BASE_URL)
168-
.apiKey("test-api-key")
168+
.apiKey("My Lithic API Key")
169169
.build()
170170
val accountHolderService = client.accountHolders()
171171
val accountHolderListDocumentsResponse =
@@ -183,7 +183,7 @@ class AccountHolderServiceTest {
183183
val client =
184184
LithicOkHttpClient.builder()
185185
.baseUrl(TestServerExtension.BASE_URL)
186-
.apiKey("test-api-key")
186+
.apiKey("My Lithic API Key")
187187
.build()
188188
val accountHolderService = client.accountHolders()
189189
val accountHolder =
@@ -223,7 +223,7 @@ class AccountHolderServiceTest {
223223
val client =
224224
LithicOkHttpClient.builder()
225225
.baseUrl(TestServerExtension.BASE_URL)
226-
.apiKey("test-api-key")
226+
.apiKey("My Lithic API Key")
227227
.build()
228228
val accountHolderService = client.accountHolders()
229229
val accountHolderDocument =
@@ -242,7 +242,7 @@ class AccountHolderServiceTest {
242242
val client =
243243
LithicOkHttpClient.builder()
244244
.baseUrl(TestServerExtension.BASE_URL)
245-
.apiKey("test-api-key")
245+
.apiKey("My Lithic API Key")
246246
.build()
247247
val accountHolderService = client.accountHolders()
248248
val accountHolderDocument =

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class AccountServiceTest {
1818
val client =
1919
LithicOkHttpClient.builder()
2020
.baseUrl(TestServerExtension.BASE_URL)
21-
.apiKey("test-api-key")
21+
.apiKey("My Lithic API Key")
2222
.build()
2323
val accountService = client.accounts()
2424
val account =
@@ -37,7 +37,7 @@ class AccountServiceTest {
3737
val client =
3838
LithicOkHttpClient.builder()
3939
.baseUrl(TestServerExtension.BASE_URL)
40-
.apiKey("test-api-key")
40+
.apiKey("My Lithic API Key")
4141
.build()
4242
val accountService = client.accounts()
4343
val account =
@@ -69,7 +69,7 @@ class AccountServiceTest {
6969
val client =
7070
LithicOkHttpClient.builder()
7171
.baseUrl(TestServerExtension.BASE_URL)
72-
.apiKey("test-api-key")
72+
.apiKey("My Lithic API Key")
7373
.build()
7474
val accountService = client.accounts()
7575
val response = accountService.list(AccountListParams.builder().build())

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AggregateBalanceServiceTest {
1717
val client =
1818
LithicOkHttpClient.builder()
1919
.baseUrl(TestServerExtension.BASE_URL)
20-
.apiKey("test-api-key")
20+
.apiKey("My Lithic API Key")
2121
.build()
2222
val aggregateBalanceService = client.aggregateBalances()
2323
val response = aggregateBalanceService.list(AggregateBalanceListParams.builder().build())

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AuthRuleServiceTest {
1717
val client =
1818
LithicOkHttpClient.builder()
1919
.baseUrl(TestServerExtension.BASE_URL)
20-
.apiKey("test-api-key")
20+
.apiKey("My Lithic API Key")
2121
.build()
2222
val authRuleService = client.authRules()
2323
val authRule =
@@ -41,7 +41,7 @@ class AuthRuleServiceTest {
4141
val client =
4242
LithicOkHttpClient.builder()
4343
.baseUrl(TestServerExtension.BASE_URL)
44-
.apiKey("test-api-key")
44+
.apiKey("My Lithic API Key")
4545
.build()
4646
val authRuleService = client.authRules()
4747
val authRuleRetrieveResponse =
@@ -59,7 +59,7 @@ class AuthRuleServiceTest {
5959
val client =
6060
LithicOkHttpClient.builder()
6161
.baseUrl(TestServerExtension.BASE_URL)
62-
.apiKey("test-api-key")
62+
.apiKey("My Lithic API Key")
6363
.build()
6464
val authRuleService = client.authRules()
6565
val authRule =
@@ -81,7 +81,7 @@ class AuthRuleServiceTest {
8181
val client =
8282
LithicOkHttpClient.builder()
8383
.baseUrl(TestServerExtension.BASE_URL)
84-
.apiKey("test-api-key")
84+
.apiKey("My Lithic API Key")
8585
.build()
8686
val authRuleService = client.authRules()
8787
val response = authRuleService.list(AuthRuleListParams.builder().build())
@@ -94,7 +94,7 @@ class AuthRuleServiceTest {
9494
val client =
9595
LithicOkHttpClient.builder()
9696
.baseUrl(TestServerExtension.BASE_URL)
97-
.apiKey("test-api-key")
97+
.apiKey("My Lithic API Key")
9898
.build()
9999
val authRuleService = client.authRules()
100100
val authRule =
@@ -115,7 +115,7 @@ class AuthRuleServiceTest {
115115
val client =
116116
LithicOkHttpClient.builder()
117117
.baseUrl(TestServerExtension.BASE_URL)
118-
.apiKey("test-api-key")
118+
.apiKey("My Lithic API Key")
119119
.build()
120120
val authRuleService = client.authRules()
121121
val authRuleRemoveResponse =

0 commit comments

Comments
 (0)