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
+31-7Lines changed: 31 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,11 +44,24 @@ Config.environment = Environment.PRODUCTION // For production
44
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:
45
45
46
46
```kotlin
47
-
Api.sessionToken ="valid_session_token"
47
+
Api.applySessionToken("valid_session_token")
48
+
```
49
+
50
+
### Applying Ktor config
51
+
Ktor configuration can be applied using the `Api.withHttpClientConfig` method:
52
+
53
+
```kotlin
54
+
Api.withHttpClientConfig {
55
+
install(Logging) {
56
+
level =LogLevel.ALL
57
+
}
58
+
}
48
59
```
49
60
50
61
### Routers
51
-
Routers are used to encapsulate specific areas of the API. For example, the `VehiclesRouter` takes care of all Vehicle API interactions. Routers are attached to the `Api` object via extension properties.
62
+
Routers are used to encapsulate specific areas of the API. For example, the `VehiclesRouter` takes care of all Vehicle API interactions. Routers are attached to the `Api` object via extension properties.
63
+
64
+
For more information: https://ktor.io/docs/client-logging.html
52
65
53
66
#### Example usage of the `VehiclesRouter`:
54
67
@@ -64,11 +77,22 @@ val response: List<Vehicle> = api.vehicles.all("organisation-id", VehicleRequest
64
77
## Examples of Usage
65
78
66
79
```kotlin
67
-
Config.environment =Environment.STAGING
68
-
Api.sessionToken =""// Replace with an actual session token
69
-
70
80
runBlocking {
71
-
val response =Api.vehicles.all("123")
72
-
println(response.size)
81
+
Config.environment =Environment.STAGING
82
+
val authResponse =Api.auth.initiate()
83
+
Api.withHttpClientConfig {
84
+
install(Logging) {
85
+
level =LogLevel.ALL
86
+
}
87
+
}
88
+
89
+
val response =Api.auth.complete(authResponse.id, payload =LoginPayload(
0 commit comments