You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,17 +41,18 @@ Config.environment = Environment.PRODUCTION // For production
41
41
```
42
42
43
43
### API object
44
-
Interaction with the APIs is done via the `Api`singleton. The Api singleton provides access to a configured Ktor client for interaction with the Api. A session token can also be applied:
44
+
Interaction with the APIs is done via the `Api`class. The Api class provides access to a configured Ktor client for interaction with the Api. A session token can also be applied:
45
45
46
46
```kotlin
47
-
Api.applySessionToken("valid_session_token")
47
+
val api =Api()
48
+
api.applySessionToken("valid_session_token")
48
49
```
49
50
50
51
### Applying Ktor config
51
52
Ktor configuration can be applied using the `Api.withHttpClientConfig` method:
52
53
53
54
```kotlin
54
-
Api.withHttpClientConfig {
55
+
api.withHttpClientConfig {
55
56
install(Logging) {
56
57
level =LogLevel.ALL
57
58
}
@@ -78,20 +79,21 @@ val response: List<Vehicle> = Api.vehicles.all("organisation-id", VehicleRequest
78
79
```kotlin
79
80
runBlocking {
80
81
Config.environment =Environment.STAGING
81
-
val authResponse =Api.auth.initiate()
82
-
Api.withHttpClientConfig {
82
+
val api =Api()
83
+
val authResponse = api.auth.initiate()
84
+
api.withHttpClientConfig {
83
85
install(Logging) {
84
86
level =LogLevel.ALL
85
87
}
86
88
}
87
89
88
-
val response =Api.auth.complete(authResponse.id, payload =LoginPayload(
90
+
val response =api.auth.complete(authResponse.id, payload =LoginPayload(
0 commit comments