diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusExtension.kt index c5eabb4f84..0caebb824d 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/BolusExtension.kt @@ -18,12 +18,7 @@ fun NSBolus.toBolus(): Bolus = ) fun NSBolus.BolusType?.toBolusType(): Bolus.Type = - when (this) { - NSBolus.BolusType.NORMAL -> Bolus.Type.NORMAL - NSBolus.BolusType.SMB -> Bolus.Type.SMB - NSBolus.BolusType.PRIMING -> Bolus.Type.PRIMING - null -> Bolus.Type.NORMAL - } + Bolus.Type.fromString(this?.name) fun Bolus.toNSBolus(): NSBolus = NSBolus( @@ -43,9 +38,4 @@ fun Bolus.toNSBolus(): NSBolus = ) fun Bolus.Type?.toBolusType(): NSBolus.BolusType = - when (this) { - Bolus.Type.NORMAL -> NSBolus.BolusType.NORMAL - Bolus.Type.SMB -> NSBolus.BolusType.SMB - Bolus.Type.PRIMING -> NSBolus.BolusType.PRIMING - null -> NSBolus.BolusType.NORMAL - } \ No newline at end of file + NSBolus.BolusType.fromString(this?.name) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/OfflineEventExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/OfflineEventExtension.kt index 0c1bd0151c..642ea88c48 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/OfflineEventExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/OfflineEventExtension.kt @@ -15,11 +15,4 @@ fun NSOfflineEvent.toOfflineEvent(): OfflineEvent = ) fun NSOfflineEvent.Reason?.toReason(): OfflineEvent.Reason = - when (this) { - NSOfflineEvent.Reason.DISCONNECT_PUMP -> OfflineEvent.Reason.DISCONNECT_PUMP - NSOfflineEvent.Reason.SUSPEND -> OfflineEvent.Reason.SUSPEND - NSOfflineEvent.Reason.DISABLE_LOOP -> OfflineEvent.Reason.DISABLE_LOOP - NSOfflineEvent.Reason.SUPER_BOLUS -> OfflineEvent.Reason.SUPER_BOLUS - NSOfflineEvent.Reason.OTHER -> OfflineEvent.Reason.OTHER - null -> OfflineEvent.Reason.OTHER - } \ No newline at end of file + OfflineEvent.Reason.fromString(this?.name) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryBasalExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryBasalExtension.kt index 141c00d347..ba30872293 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryBasalExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryBasalExtension.kt @@ -20,14 +20,7 @@ fun NSTemporaryBasal.toTemporaryBasal(): TemporaryBasal = ) fun NSTemporaryBasal.Type?.toType(): TemporaryBasal.Type = - when (this) { - NSTemporaryBasal.Type.NORMAL -> TemporaryBasal.Type.NORMAL - NSTemporaryBasal.Type.EMULATED_PUMP_SUSPEND -> TemporaryBasal.Type.EMULATED_PUMP_SUSPEND - NSTemporaryBasal.Type.PUMP_SUSPEND -> TemporaryBasal.Type.PUMP_SUSPEND - NSTemporaryBasal.Type.SUPERBOLUS -> TemporaryBasal.Type.SUPERBOLUS - NSTemporaryBasal.Type.FAKE_EXTENDED -> TemporaryBasal.Type.FAKE_EXTENDED - null -> TemporaryBasal.Type.NORMAL - } + TemporaryBasal.Type.fromString(this?.name) fun TemporaryBasal.toNSTemporaryBasal(profile: Profile): NSTemporaryBasal = NSTemporaryBasal( @@ -49,11 +42,4 @@ fun TemporaryBasal.toNSTemporaryBasal(profile: Profile): NSTemporaryBasal = ) fun TemporaryBasal.Type?.toType(): NSTemporaryBasal.Type = - when (this) { - TemporaryBasal.Type.NORMAL -> NSTemporaryBasal.Type.NORMAL - TemporaryBasal.Type.EMULATED_PUMP_SUSPEND -> NSTemporaryBasal.Type.EMULATED_PUMP_SUSPEND - TemporaryBasal.Type.PUMP_SUSPEND -> NSTemporaryBasal.Type.PUMP_SUSPEND - TemporaryBasal.Type.SUPERBOLUS -> NSTemporaryBasal.Type.SUPERBOLUS - TemporaryBasal.Type.FAKE_EXTENDED -> NSTemporaryBasal.Type.FAKE_EXTENDED - null -> NSTemporaryBasal.Type.NORMAL - } \ No newline at end of file + NSTemporaryBasal.Type.fromString(this?.name) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryTargetExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryTargetExtension.kt index e0791865b2..d349211b02 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryTargetExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/extensions/TemporaryTargetExtension.kt @@ -19,15 +19,7 @@ fun NSTemporaryTarget.toTemporaryTarget(): TemporaryTarget = ) fun NSTemporaryTarget.Reason?.toReason(): TemporaryTarget.Reason = - when (this) { - NSTemporaryTarget.Reason.CUSTOM -> TemporaryTarget.Reason.CUSTOM - NSTemporaryTarget.Reason.HYPOGLYCEMIA -> TemporaryTarget.Reason.HYPOGLYCEMIA - NSTemporaryTarget.Reason.ACTIVITY -> TemporaryTarget.Reason.ACTIVITY - NSTemporaryTarget.Reason.EATING_SOON -> TemporaryTarget.Reason.EATING_SOON - NSTemporaryTarget.Reason.AUTOMATION -> TemporaryTarget.Reason.AUTOMATION - NSTemporaryTarget.Reason.WEAR -> TemporaryTarget.Reason.WEAR - null -> TemporaryTarget.Reason.CUSTOM - } + TemporaryTarget.Reason.fromString(this?.text) fun TemporaryTarget.toNSTemporaryTarget(): NSTemporaryTarget = NSTemporaryTarget( @@ -48,12 +40,4 @@ fun TemporaryTarget.toNSTemporaryTarget(): NSTemporaryTarget = ) fun TemporaryTarget.Reason?.toReason(): NSTemporaryTarget.Reason = - when (this) { - TemporaryTarget.Reason.CUSTOM -> NSTemporaryTarget.Reason.CUSTOM - TemporaryTarget.Reason.HYPOGLYCEMIA -> NSTemporaryTarget.Reason.HYPOGLYCEMIA - TemporaryTarget.Reason.ACTIVITY -> NSTemporaryTarget.Reason.ACTIVITY - TemporaryTarget.Reason.EATING_SOON -> NSTemporaryTarget.Reason.EATING_SOON - TemporaryTarget.Reason.AUTOMATION -> NSTemporaryTarget.Reason.AUTOMATION - TemporaryTarget.Reason.WEAR -> NSTemporaryTarget.Reason.WEAR - null -> NSTemporaryTarget.Reason.CUSTOM - } \ No newline at end of file + NSTemporaryTarget.Reason.fromString(this?.text)