-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
111 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.ioki.lokalise.api | ||
|
||
import com.ioki.lokalise.api.models.Error | ||
|
||
sealed interface Result<out T> { | ||
data class Success<T>(val data: T) : Result<T> | ||
data class Failure(val error: Error) : Result<Nothing> | ||
} |
15 changes: 15 additions & 0 deletions
15
src/commonMain/kotlin/com/ioki/lokalise/api/models/Error.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.ioki.lokalise.api.models | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
internal data class ErrorWrapper( | ||
val error: Error, | ||
) | ||
|
||
@Serializable | ||
data class Error( | ||
@SerialName("message") val message: String, | ||
@SerialName("code") val code: Int | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/commonTest/kotlin/com/ioki/lokalise/api/stubs/ErrorJson.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.ioki.lokalise.api.stubs | ||
|
||
val errorJson = """ | ||
{ | ||
"error":{ | ||
"message": "Not Found", | ||
"code": 404 | ||
} | ||
} | ||
""".trimIndent() |