mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-01-24 16:34:20 +01:00
Fix conversion of enum's in Kotlin
This commit is contained in:
@@ -375,7 +375,7 @@ fun asSendPaymentResponseList(arr: ReadableArray): List<SendPaymentResponse> {
|
||||
}
|
||||
|
||||
fun asNetwork(type: String): Network {
|
||||
return Network.valueOf(type.uppercase())
|
||||
return Network.valueOf(camelToUpperSnakeCase(type))
|
||||
}
|
||||
|
||||
fun asNetworkList(arr: ReadableArray): List<Network> {
|
||||
@@ -498,3 +498,8 @@ fun errUnexpectedType(typeName: String): String {
|
||||
fun errUnexpectedValue(fieldName: String): String {
|
||||
return "Unexpected value for optional field $fieldName"
|
||||
}
|
||||
|
||||
fun camelToUpperSnakeCase(str: String): String {
|
||||
val pattern = "(?<=.)[A-Z]".toRegex()
|
||||
return str.replace(pattern, "_$0").uppercase()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user