File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Network/src/main/kotlin/com/infomaniak/core/network Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -19,17 +19,34 @@ package com.infomaniak.core.network
1919
2020/* *
2121 * ## Usage
22+ *
23+ * ### Use in a url:
2224 * ```
2325 * val host = ApiEnvironment.current.host
2426 * val someUrl = "https://whatever.$host/something/gentle-endpoint"
2527 * ```
28+ *
29+ * ### Change the host:
30+ *
31+ * You can either temporarily change the initial value of `current` in this file,
32+ * or you can, in the first `init` block of the [android.app.Application] class of
33+ * the host app, change its value, as below.
34+ * **WARNING:** Never change the value later.
35+ *
36+ * ```
37+ * class App : Application {
38+ * init {
39+ * ApiEnvironment.current = ApiEnvironment.Custom("whatever.dev.infomaniak.ch")
40+ * }
41+ * }
42+ * ```
2643 */
27- sealed class ApiEnvironment (val host : String ) {
44+ sealed class ApiEnvironment (open val host : String ) {
2845 data object Prod : ApiEnvironment (" infomaniak.com" )
2946 data object PreProd : ApiEnvironment (" preprod.dev.infomaniak.ch" )
30- data object Custom : ApiEnvironment (" " )
47+ data class Custom ( override val host : String ) : ApiEnvironment(host )
3148
3249 companion object {
33- val current: ApiEnvironment = Prod
50+ var current: ApiEnvironment = Prod
3451 }
3552}
You can’t perform that action at this time.
0 commit comments