From 8c6157b8f6219bd826543393a9cc570bab7b23bb Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 23 Sep 2023 15:27:42 +0200 Subject: [PATCH] NSC: better select matching records when switching between v1 and v3 plugin --- .../nightscout/plugins/sync/nsShared/NSClientFragment.kt | 1 + .../extensions/BolusCalculatorResultExtension.kt | 9 +++++++-- .../plugins/sync/nsclient/extensions/BolusExtension.kt | 9 +++++++-- .../plugins/sync/nsclient/extensions/CarbsExtension.kt | 9 +++++++-- .../extensions/EffectiveProfileSwitchExtension.kt | 9 +++++++-- .../sync/nsclient/extensions/ExtendedBolusExtension.kt | 9 +++++++-- .../plugins/sync/nsclient/extensions/FoodExtension.kt | 4 +++- .../sync/nsclient/extensions/OfflineEventExtension.kt | 9 +++++++-- .../sync/nsclient/extensions/ProfileSwitchExtension.kt | 9 +++++++-- .../sync/nsclient/extensions/TemporaryBasalExtension.kt | 9 +++++++-- .../sync/nsclient/extensions/TemporaryTargetExtension.kt | 9 +++++++-- .../sync/nsclient/extensions/TherapyEventExtension.kt | 9 +++++++-- 12 files changed, 74 insertions(+), 21 deletions(-) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/NSClientFragment.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/NSClientFragment.kt index a522c6c990..b55683efdc 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/NSClientFragment.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/NSClientFragment.kt @@ -233,6 +233,7 @@ class NSClientFragment : DaggerFragment(), MenuProvider, PluginFragment { } private fun updateLog() { + _binding?.recyclerview?.recycledViewPool?.clear() _binding?.recyclerview?.swapAdapter(RecyclerViewAdapter(nsClientPlugin?.listLog ?: arrayListOf()), true) } diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/BolusCalculatorResultExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/BolusCalculatorResultExtension.kt index 27a773f481..b0162160a7 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/BolusCalculatorResultExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/BolusCalculatorResultExtension.kt @@ -21,9 +21,14 @@ fun BolusCalculatorResult.toJson(isAdd: Boolean, dateUtil: DateUtil, profileUtil .also { if (isAdd && interfaceIDs.nightscoutId != null) it.put("_id", interfaceIDs.nightscoutId) } fun BolusCalculatorResult.Companion.fromJson(jsonObject: JSONObject): BolusCalculatorResult? { - val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null + val timestamp = + JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) + ?: JsonHelper.safeGetLongAllowNull(jsonObject, "date", null) + ?: return null val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val bcrString = JsonHelper.safeGetStringAllowNull(jsonObject, "bolusCalculatorResult", null) ?: return null if (timestamp == 0L) return null diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/BolusExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/BolusExtension.kt index 6031659b9e..8096660dd6 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/BolusExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/BolusExtension.kt @@ -26,12 +26,17 @@ fun Bolus.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject = } fun Bolus.Companion.fromJson(jsonObject: JSONObject): Bolus? { - val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null + val timestamp = + JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) + ?: JsonHelper.safeGetLongAllowNull(jsonObject, "date", null) + ?: return null val amount = JsonHelper.safeGetDoubleAllowNull(jsonObject, "insulin") ?: return null val type = Bolus.Type.fromString(JsonHelper.safeGetString(jsonObject, "type")) val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) val notes = JsonHelper.safeGetStringAllowNull(jsonObject, "notes", null) - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val pumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "pumpId", null) val pumpType = InterfaceIDs.PumpType.fromString(JsonHelper.safeGetStringAllowNull(jsonObject, "pumpType", null)) val pumpSerial = JsonHelper.safeGetStringAllowNull(jsonObject, "pumpSerial", null) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/CarbsExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/CarbsExtension.kt index b03e4bf85f..f9646f2d64 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/CarbsExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/CarbsExtension.kt @@ -23,12 +23,17 @@ fun Carbs.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject = } fun Carbs.Companion.fromJson(jsonObject: JSONObject): Carbs? { - val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null + val timestamp = + JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) + ?: JsonHelper.safeGetLongAllowNull(jsonObject, "date", null) + ?: return null val duration = JsonHelper.safeGetLong(jsonObject, "duration") val amount = JsonHelper.safeGetDoubleAllowNull(jsonObject, "carbs") ?: return null val notes = JsonHelper.safeGetStringAllowNull(jsonObject, "notes", null) val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val pumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "pumpId", null) val pumpType = InterfaceIDs.PumpType.fromString(JsonHelper.safeGetStringAllowNull(jsonObject, "pumpType", null)) val pumpSerial = JsonHelper.safeGetStringAllowNull(jsonObject, "pumpSerial", null) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/EffectiveProfileSwitchExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/EffectiveProfileSwitchExtension.kt index 11a8f2bc1a..30e85dd4a5 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/EffectiveProfileSwitchExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/EffectiveProfileSwitchExtension.kt @@ -31,13 +31,18 @@ fun EffectiveProfileSwitch.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObjec } fun EffectiveProfileSwitch.Companion.fromJson(jsonObject: JSONObject, dateUtil: DateUtil): EffectiveProfileSwitch? { - val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null + val timestamp = + JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) + ?: JsonHelper.safeGetLongAllowNull(jsonObject, "date", null) + ?: return null val originalTimeshift = JsonHelper.safeGetLong(jsonObject, "originalTimeshift") val originalDuration = JsonHelper.safeGetLong(jsonObject, "originalDuration") val originalEnd = JsonHelper.safeGetLong(jsonObject, "originalEnd") val originalPercentage = JsonHelper.safeGetInt(jsonObject, "originalPercentage", 100) val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val originalProfileName = JsonHelper.safeGetStringAllowNull(jsonObject, "originalProfileName", null) ?: return null val originalCustomizedName = JsonHelper.safeGetStringAllowNull(jsonObject, "originalCustomizedName", null) ?: return null val profileJson = JsonHelper.safeGetStringAllowNull(jsonObject, "profileJson", null) ?: return null diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/ExtendedBolusExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/ExtendedBolusExtension.kt index 073602a355..50dca0e290 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/ExtendedBolusExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/ExtendedBolusExtension.kt @@ -40,7 +40,10 @@ fun ExtendedBolus.toRealJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject = } fun ExtendedBolus.Companion.extendedBolusFromJson(jsonObject: JSONObject): ExtendedBolus? { - val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null + val timestamp = + JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) + ?: JsonHelper.safeGetLongAllowNull(jsonObject, "date", null) + ?: return null if (JsonHelper.safeGetIntAllowNull(jsonObject, "splitNow") != 0) return null if (JsonHelper.safeGetIntAllowNull(jsonObject, "splitExt") != 100) return null val amount = JsonHelper.safeGetDoubleAllowNull(jsonObject, "enteredinsulin") ?: return null @@ -48,7 +51,9 @@ fun ExtendedBolus.Companion.extendedBolusFromJson(jsonObject: JSONObject): Exten val durationInMilliseconds = JsonHelper.safeGetLongAllowNull(jsonObject, "durationInMilliseconds") val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) val isEmulatingTempBasal = JsonHelper.safeGetBoolean(jsonObject, "isEmulatingTempBasal", false) - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val pumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "pumpId", null) val endPumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "endId", null) val pumpType = InterfaceIDs.PumpType.fromString(JsonHelper.safeGetStringAllowNull(jsonObject, "pumpType", null)) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/FoodExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/FoodExtension.kt index d832b96c5a..c6d2c557da 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/FoodExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/FoodExtension.kt @@ -16,7 +16,9 @@ fun Food.Companion.fromJson(jsonObject: JSONObject): Food? { val energy = JsonHelper.safeGetIntAllowNull(jsonObject, "energy") val protein = JsonHelper.safeGetIntAllowNull(jsonObject, "protein") val fat = JsonHelper.safeGetIntAllowNull(jsonObject, "fat") - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) val food = Food( diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/OfflineEventExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/OfflineEventExtension.kt index 9b30daa022..716754fc56 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/OfflineEventExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/OfflineEventExtension.kt @@ -37,11 +37,16 @@ fun OfflineEvent.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject = } */ fun OfflineEvent.Companion.fromJson(jsonObject: JSONObject): OfflineEvent? { - val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null + val timestamp = + JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) + ?: JsonHelper.safeGetLongAllowNull(jsonObject, "date", null) + ?: return null val duration = JsonHelper.safeGetLong(jsonObject, "duration") val durationInMilliseconds = JsonHelper.safeGetLongAllowNull(jsonObject, "durationInMilliseconds") val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val pumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "pumpId", null) val pumpType = InterfaceIDs.PumpType.fromString(JsonHelper.safeGetStringAllowNull(jsonObject, "pumpType", null)) val pumpSerial = JsonHelper.safeGetStringAllowNull(jsonObject, "pumpSerial", null) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/ProfileSwitchExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/ProfileSwitchExtension.kt index 476ae32cdc..a9b52ba326 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/ProfileSwitchExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/ProfileSwitchExtension.kt @@ -52,13 +52,18 @@ fun ProfileSwitch.toJson(isAdd: Boolean, dateUtil: DateUtil, decimalFormatter: D } */ fun ProfileSwitch.Companion.fromJson(jsonObject: JSONObject, dateUtil: DateUtil, activePlugin: ActivePlugin): ProfileSwitch? { - val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null + val timestamp = + JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) + ?: JsonHelper.safeGetLongAllowNull(jsonObject, "date", null) + ?: return null val duration = JsonHelper.safeGetLong(jsonObject, "duration") val originalDuration = JsonHelper.safeGetLongAllowNull(jsonObject, "originalDuration") val timeshift = JsonHelper.safeGetLong(jsonObject, "timeshift") val percentage = JsonHelper.safeGetInt(jsonObject, "percentage", 100) val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val profileName = JsonHelper.safeGetStringAllowNull(jsonObject, "profile", null) ?: return null val originalProfileName = JsonHelper.safeGetStringAllowNull(jsonObject, "originalProfileName", null) val profileJson = JsonHelper.safeGetStringAllowNull(jsonObject, "profileJson", null) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TemporaryBasalExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TemporaryBasalExtension.kt index 6f52a7a7ba..87039e66c1 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TemporaryBasalExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TemporaryBasalExtension.kt @@ -33,14 +33,19 @@ fun TemporaryBasal.toJson(isAdd: Boolean, profile: Profile?, dateUtil: DateUtil) } fun TemporaryBasal.Companion.temporaryBasalFromJson(jsonObject: JSONObject): TemporaryBasal? { - val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null + val timestamp = + JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) + ?: JsonHelper.safeGetLongAllowNull(jsonObject, "date", null) + ?: return null val percent = JsonHelper.safeGetDoubleAllowNull(jsonObject, "percent") val absolute = JsonHelper.safeGetDoubleAllowNull(jsonObject, "absolute") val duration = JsonHelper.safeGetLongAllowNull(jsonObject, "duration") ?: return null val durationInMilliseconds = JsonHelper.safeGetLongAllowNull(jsonObject, "durationInMilliseconds") val type = fromString(JsonHelper.safeGetString(jsonObject, "type")) val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val pumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "pumpId", null) val endPumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "endId", null) val pumpType = InterfaceIDs.PumpType.fromString(JsonHelper.safeGetStringAllowNull(jsonObject, "pumpType", null)) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TemporaryTargetExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TemporaryTargetExtension.kt index 564b11cd97..5295853f95 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TemporaryTargetExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TemporaryTargetExtension.kt @@ -11,7 +11,10 @@ import org.json.JSONObject fun TemporaryTarget.Companion.fromJson(jsonObject: JSONObject, profileUtil: ProfileUtil): TemporaryTarget? { val units = GlucoseUnit.fromText(JsonHelper.safeGetString(jsonObject, "units", GlucoseUnit.MGDL.asText)) - val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null + val timestamp = + JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) + ?: JsonHelper.safeGetLongAllowNull(jsonObject, "date", null) + ?: return null val duration = JsonHelper.safeGetLongAllowNull(jsonObject, "duration", null) ?: return null val durationInMilliseconds = JsonHelper.safeGetLongAllowNull(jsonObject, "durationInMilliseconds") var low = JsonHelper.safeGetDouble(jsonObject, "targetBottom") @@ -22,7 +25,9 @@ fun TemporaryTarget.Companion.fromJson(jsonObject: JSONObject, profileUtil: Prof ?: return null else "" // this string can be localized from NS, it will not work in this case CUSTOM will be used val reason = TemporaryTarget.Reason.fromString(reasonString) - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) if (timestamp == 0L) return null diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TherapyEventExtension.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TherapyEventExtension.kt index dbc63b6121..a75c474b27 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TherapyEventExtension.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/TherapyEventExtension.kt @@ -23,7 +23,10 @@ fun therapyEventFromNsMbg(mbg: NSMbg) = fun TherapyEvent.Companion.fromJson(jsonObject: JSONObject): TherapyEvent? { val glucoseUnit = if (JsonHelper.safeGetString(jsonObject, "units", GlucoseUnit.MGDL.asText) == GlucoseUnit.MGDL.asText) TherapyEvent.GlucoseUnit.MGDL else TherapyEvent.GlucoseUnit.MMOL - val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null + val timestamp = + JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) + ?: JsonHelper.safeGetLongAllowNull(jsonObject, "date", null) + ?: return null val type = TherapyEvent.Type.fromString(JsonHelper.safeGetString(jsonObject, "eventType", TherapyEvent.Type.NONE.text)) val duration = JsonHelper.safeGetLong(jsonObject, "duration") val durationInMilliseconds = JsonHelper.safeGetLongAllowNull(jsonObject, "durationInMilliseconds") @@ -31,7 +34,9 @@ fun TherapyEvent.Companion.fromJson(jsonObject: JSONObject): TherapyEvent? { val glucoseType = TherapyEvent.MeterType.fromString(JsonHelper.safeGetString(jsonObject, "glucoseType")) val enteredBy = JsonHelper.safeGetStringAllowNull(jsonObject, "enteredBy", null) val note = JsonHelper.safeGetStringAllowNull(jsonObject, "notes", null) - val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null + val id = JsonHelper.safeGetStringAllowNull(jsonObject, "identifier", null) + ?: JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) + ?: return null val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) if (timestamp == 0L) return null