Grund: Compose-app med login mot gym-API:t, VS Code-task och CI-release
Some checks failed
release / build-release (push) Failing after 1m42s
Some checks failed
release / build-release (push) Failing after 1m42s
- Kotlin + Jetpack Compose + Material 3, minSdk 31 (Android 12) - GraphQL-klient (OkHttp) med login/refresh/validate/logout som webben - Tokenlagring i DataStore, auto-refresh av JWT - Signering via gitignorerad signing/ lokalt och Actions-secrets i CI - VS Code build-task -> build/FitnessDroid.apk - Gitea Actions: bygger APK på Pi5 (arm64, aapt2-override) och publicerar rullande latest-release Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kf4MAbZ3c3B4Xy5XfuGsCP
This commit is contained in:
31
app/src/main/java/eu/brassepc/fitnessdroid/data/GymApi.kt
Normal file
31
app/src/main/java/eu/brassepc/fitnessdroid/data/GymApi.kt
Normal file
@@ -0,0 +1,31 @@
|
||||
package eu.brassepc.fitnessdroid.data
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.decodeFromJsonElement
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
|
||||
@Serializable
|
||||
data class Profile(
|
||||
val username: String,
|
||||
val displayName: String? = null,
|
||||
val email: String? = null,
|
||||
val bodyWeightKg: Double? = null,
|
||||
)
|
||||
|
||||
/** Autentiserade anrop mot gym-API:t. Query-strängarna speglar gymTrackerApi.js. */
|
||||
class GymApi(
|
||||
private val client: GraphQlClient,
|
||||
private val auth: AuthRepository,
|
||||
) {
|
||||
suspend fun myProfile(): Profile {
|
||||
val data = client.execute(MY_PROFILE, token = auth.bearerToken())
|
||||
val profile = data["myProfile"]?.jsonObject
|
||||
?: throw GraphQlException(listOf("Kunde inte hämta profilen"))
|
||||
return client.json.decodeFromJsonElement(profile)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MY_PROFILE =
|
||||
"query{myProfile{username displayName email bodyWeightKg}}"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user