| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import Foundation
- struct PumpHistoryEvent: JSON, Equatable {
- let id: String
- let type: EventType
- let timestamp: Date
- let amount: Decimal?
- let duration: Int?
- let durationMin: Int?
- let rate: Decimal?
- let temp: TempType?
- let carbInput: Int?
- let note: String?
- init(
- id: String,
- type: EventType,
- timestamp: Date,
- amount: Decimal? = nil,
- duration: Int? = nil,
- durationMin: Int? = nil,
- rate: Decimal? = nil,
- temp: TempType? = nil,
- carbInput: Int? = nil,
- note: String? = nil
- ) {
- self.id = id
- self.type = type
- self.timestamp = timestamp
- self.amount = amount
- self.duration = duration
- self.durationMin = durationMin
- self.rate = rate
- self.temp = temp
- self.carbInput = carbInput
- self.note = note
- }
- }
- enum EventType: String, JSON {
- case bolus = "Bolus"
- case mealBulus = "Meal Bolus"
- case correctionBolus = "Correction Bolus"
- case snackBolus = "Snack Bolus"
- case bolusWizard = "BolusWizard"
- case tempBasal = "TempBasal"
- case tempBasalDuration = "TempBasalDuration"
- case pumpSuspend = "PumpSuspend"
- case pumpResume = "PumpResume"
- case rewind = "Rewind"
- case prime = "Prime"
- case journalCarbs = "JournalEntryMealMarker"
- case nsTempBasal = "Temp Basal"
- case nsCarbCorrection = "Carb Correction"
- case nsTempTarget = "Temporary Target"
- case nsSiteChange = "Site Change"
- case nsSensorChange = "Sensor Start"
- }
- enum TempType: String, JSON {
- case absolute
- case percent
- }
- extension PumpHistoryEvent {
- private enum CodingKeys: String, CodingKey {
- case id
- case type = "_type"
- case timestamp
- case amount
- case duration
- case durationMin = "duration (min)"
- case rate
- case temp
- case carbInput = "carb_input"
- case note
- }
- }
|