|
|
@ -20,12 +20,15 @@ import java.time.Instant |
|
|
|
import java.time.LocalDate |
|
|
|
import java.time.ZoneId |
|
|
|
import java.util.* |
|
|
|
import kotlin.math.roundToInt |
|
|
|
|
|
|
|
class Indigo2( |
|
|
|
private val indigoHost: String, |
|
|
|
private val oidcTokenEndpoint: String, |
|
|
|
private val oidcClientId: String, |
|
|
|
private val oidcClientSecret: String, |
|
|
|
private val autoClaim: Boolean, |
|
|
|
private val calorieScale: Double = 1.0, |
|
|
|
) : ExportTarget { |
|
|
|
private val om = jacksonObjectMapper().apply { |
|
|
|
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) |
|
|
@ -67,7 +70,7 @@ class Indigo2( |
|
|
|
"kind" to "ExerciseBike", |
|
|
|
"measurements" to tm(chunks.first()), |
|
|
|
), |
|
|
|
"claimed" to true, |
|
|
|
"claimed" to autoClaim, |
|
|
|
"date" to workout.date.toString(), |
|
|
|
"tags" to listOfNotNull( |
|
|
|
tag("ykonsole:Version", "2"), |
|
|
@ -161,7 +164,7 @@ class Indigo2( |
|
|
|
if (ws.time.seconds > 0) mapOf( |
|
|
|
"seconds" to ws.time.toInt(), |
|
|
|
"meters" to ws.distance?.toInt(), |
|
|
|
"calories" to ws.calories?.toInt(), |
|
|
|
"calories" to ws.calories?.toInt()?.let { (it * calorieScale).roundToInt() }, |
|
|
|
"resistance" to ws.level?.toInt(), |
|
|
|
"rpmSpeed" to ws.rpmSpeed?.toInt(), |
|
|
|
"pulse" to ws.pulse?.toInt(), |
|
|
|