PumpHistoryEvent.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import Foundation
  2. struct PumpHistoryEvent: JSON {
  3. let id: String
  4. let type: PumpHistoryEventType
  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 PumpHistoryEventType: 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. }
  29. enum TempType: String, JSON {
  30. case absolute
  31. case percent
  32. }
  33. extension PumpHistoryEvent {
  34. private enum CodingKeys: String, CodingKey {
  35. case id
  36. case type = "_type"
  37. case timestamp
  38. case amount
  39. case duration
  40. case durationMin = "duration (min)"
  41. case rate
  42. case temp
  43. case carbInput = "carb_input"
  44. }
  45. }