PumpHistoryEvent.swift 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import Foundation
  2. struct PumpHistoryEvent: JSON, Equatable {
  3. let id: String
  4. let type: EventType
  5. let timestamp: Date
  6. let amount: Decimal?
  7. let duration: Int?
  8. let durationMin: Int?
  9. let rate: Decimal?
  10. let temp: TempType?
  11. let carbInput: Int?
  12. }
  13. enum EventType: String, JSON {
  14. case bolus = "Bolus"
  15. case mealBulus = "Meal Bolus"
  16. case correctionBolus = "Correction Bolus"
  17. case snackBolus = "Snack Bolus"
  18. case bolusWizard = "BolusWizard"
  19. case tempBasal = "TempBasal"
  20. case tempBasalDuration = "TempBasalDuration"
  21. case pumpSuspend = "PumpSuspend"
  22. case pumpResume = "PumpResume"
  23. case rewind = "Rewind"
  24. case prime = "Prime"
  25. case journalCarbs = "JournalEntryMealMarker"
  26. case nsTempBasal = "Temp Basal"
  27. case nsCarbCorrection = "Carb Correction"
  28. case nsTempTarget = "Temporary Target"
  29. }
  30. enum TempType: String, JSON {
  31. case absolute
  32. case percent
  33. }
  34. extension PumpHistoryEvent {
  35. private enum CodingKeys: String, CodingKey {
  36. case id
  37. case type = "_type"
  38. case timestamp
  39. case amount
  40. case duration
  41. case durationMin = "duration (min)"
  42. case rate
  43. case temp
  44. case carbInput = "carb_input"
  45. }
  46. }