Skip to content

Commit e3b4bfb

Browse files
committed
Updates
1 parent 22674a0 commit e3b4bfb

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.zerion.kmm.api.exceptions
2+
3+
sealed class ZerionApiException(message: String? = null, cause: Throwable? = null) : Exception(message, cause) {
4+
5+
class MalformedParametersException(message: String? = null, cause: Throwable? = null) :
6+
ZerionApiException("Parameters are malformed: $message", cause)
7+
8+
class UnauthorizedException(message: String? = null, cause: Throwable? = null) :
9+
ZerionApiException("Unauthorized request: $message", cause)
10+
11+
class TooManyRequestsException(message: String? = null, cause: Throwable? = null) :
12+
ZerionApiException("Too many requests: $message", cause)
13+
14+
class GeneralException(message: String? = null, cause: Throwable? = null) :
15+
ZerionApiException("General API error: $message", cause)
16+
17+
class ZerionInitializationException(message: String? = null, cause: Throwable? = null) :
18+
ZerionApiException("SDK initialization failed: $message", cause)
19+
20+
class ZerionAuthorizationException(message: String? = null, cause: Throwable? = null) :
21+
ZerionApiException("SDK authorization failed: $message", cause)
22+
23+
companion object {
24+
fun fromHttpCode(code: Int, message: String? = null, cause: Throwable? = null): ZerionApiException {
25+
return when (code) {
26+
400 -> MalformedParametersException(message, cause)
27+
401 -> UnauthorizedException(message, cause)
28+
429 -> TooManyRequestsException(message, cause)
29+
else -> GeneralException(message, cause)
30+
}
31+
}
32+
}
33+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.zerion.kmm.api.models
2+
3+
enum class PositionFilter(val apiValue: String) {
4+
ONLY_SIMPLE("only_simple"),
5+
ONLY_COMPLEX("only_complex"),
6+
NO_FILTER("no_filter")
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.zerion.kmm.api.models
2+
3+
enum class PositionType(val apiValue: String) {
4+
WALLET("wallet"),
5+
DEPOSIT("deposit"),
6+
LOAN("loan"),
7+
LOCKED("locked"),
8+
STAKED("staked"),
9+
REWARD("reward"),
10+
AIRDROP("airdrop"),
11+
MARGIN("margin")
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.zerion.kmm.api.models
2+
3+
enum class SortType(val apiValue: String) {
4+
VALUE_ASCENDING("value"),
5+
VALUE_DESCENDING("-value")
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.zerion.kmm.api.models
2+
3+
enum class TrashFilter(val apiValue: String) {
4+
ONLY_TRASH("only_trash"),
5+
ONLY_NON_TRASH("only_non_trash"),
6+
NO_FILTER("no_filter")
7+
}

0 commit comments

Comments
 (0)