3
3
package com.openlayer.api.client.okhttp
4
4
5
5
import com.fasterxml.jackson.databind.json.JsonMapper
6
- import com.google.common.collect.Multimap
6
+ import com.openlayer.api.client.OpenlayerClientAsync
7
+ import com.openlayer.api.client.OpenlayerClientAsyncImpl
8
+ import com.openlayer.api.core.ClientOptions
7
9
import java.net.Proxy
8
10
import java.time.Clock
9
11
import java.time.Duration
10
- import java.util.Optional
11
- import com.openlayer.api.core.ClientOptions
12
- import com.openlayer.api.core.http.HttpClient
13
- import com.openlayer.api.client.OpenlayerClientAsync
14
- import com.openlayer.api.client.OpenlayerClientAsyncImpl
15
12
16
13
class OpenlayerOkHttpClientAsync private constructor() {
17
14
18
15
companion object {
19
16
20
- @JvmStatic
21
- fun builder () = Builder ()
17
+ @JvmStatic fun builder () = Builder ()
22
18
23
- @JvmStatic
24
- fun fromEnv (): OpenlayerClientAsync = builder().fromEnv().build()
19
+ @JvmStatic fun fromEnv (): OpenlayerClientAsync = builder().fromEnv().build()
25
20
}
26
21
27
22
class Builder {
@@ -37,21 +32,15 @@ class OpenlayerOkHttpClientAsync private constructor() {
37
32
this .baseUrl = baseUrl
38
33
}
39
34
40
- fun jsonMapper (jsonMapper : JsonMapper ) = apply {
41
- clientOptions.jsonMapper(jsonMapper)
42
- }
35
+ fun jsonMapper (jsonMapper : JsonMapper ) = apply { clientOptions.jsonMapper(jsonMapper) }
43
36
44
- fun clock (clock : Clock ) = apply {
45
- clientOptions.clock(clock)
46
- }
37
+ fun clock (clock : Clock ) = apply { clientOptions.clock(clock) }
47
38
48
39
fun headers (headers : Map <String , Iterable <String >>) = apply {
49
40
clientOptions.headers(headers)
50
41
}
51
42
52
- fun putHeader (name : String , value : String ) = apply {
53
- clientOptions.putHeader(name, value)
54
- }
43
+ fun putHeader (name : String , value : String ) = apply { clientOptions.putHeader(name, value) }
55
44
56
45
fun putHeaders (name : String , values : Iterable <String >) = apply {
57
46
clientOptions.putHeaders(name, values)
@@ -61,42 +50,34 @@ class OpenlayerOkHttpClientAsync private constructor() {
61
50
clientOptions.putAllHeaders(headers)
62
51
}
63
52
64
- fun removeHeader (name : String ) = apply {
65
- clientOptions.removeHeader(name)
66
- }
53
+ fun removeHeader (name : String ) = apply { clientOptions.removeHeader(name) }
67
54
68
- fun timeout (timeout : Duration ) = apply {
69
- this .timeout = timeout
70
- }
55
+ fun timeout (timeout : Duration ) = apply { this .timeout = timeout }
71
56
72
- fun maxRetries (maxRetries : Int ) = apply {
73
- clientOptions.maxRetries(maxRetries)
74
- }
57
+ fun maxRetries (maxRetries : Int ) = apply { clientOptions.maxRetries(maxRetries) }
75
58
76
- fun proxy (proxy : Proxy ) = apply {
77
- this .proxy = proxy
78
- }
59
+ fun proxy (proxy : Proxy ) = apply { this .proxy = proxy }
79
60
80
61
fun responseValidation (responseValidation : Boolean ) = apply {
81
62
clientOptions.responseValidation(responseValidation)
82
63
}
83
64
84
- fun apiKey (apiKey : String? ) = apply {
85
- clientOptions.apiKey(apiKey)
86
- }
65
+ fun apiKey (apiKey : String? ) = apply { clientOptions.apiKey(apiKey) }
87
66
88
- fun fromEnv () = apply {
89
- clientOptions.fromEnv()
90
- }
67
+ fun fromEnv () = apply { clientOptions.fromEnv() }
91
68
92
69
fun build (): OpenlayerClientAsync {
93
- return OpenlayerClientAsyncImpl (clientOptions
94
- .httpClient(OkHttpClient .builder()
95
- .baseUrl(baseUrl)
96
- .timeout(timeout)
97
- .proxy(proxy)
98
- .build())
99
- .build())
70
+ return OpenlayerClientAsyncImpl (
71
+ clientOptions
72
+ .httpClient(
73
+ OkHttpClient .builder()
74
+ .baseUrl(baseUrl)
75
+ .timeout(timeout)
76
+ .proxy(proxy)
77
+ .build()
78
+ )
79
+ .build()
80
+ )
100
81
}
101
82
}
102
83
}
0 commit comments