[O] Separate register function

This commit is contained in:
Azalea 2024-03-27 22:42:05 -04:00
parent ad13875137
commit b7d2a97f05
2 changed files with 110 additions and 101 deletions

View File

@ -1,5 +1,7 @@
package ext
import io.ktor.client.request.*
import io.ktor.client.statement.*
import kotlin.random.Random
import kotlin.random.nextInt
@ -17,4 +19,16 @@ catch (e: Exception) {
}
fun String.jsonMap(): Map<String, Any?> = json()
fun String.jsonArray(): List<Map<String, Any?>> = json()
fun String.jsonArray(): List<Map<String, Any?>> = json()
suspend fun registerUser(): Long {
val resp = HTTP.post(HOST.ensureEndingSlash() + "api/v2/frontier/register-card") {
parameter("ftk", FTK)
parameter("accessCode", ACCESS_CODE)
}.bodyAsText()
val userId = (resp.jsonMap()["id"] as Number).toLong()
println("User ID: $userId")
return userId
}

File diff suppressed because one or more lines are too long