PumpHistoryEvent.swift 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. }
  27. enum TempType: String, JSON {
  28. case absolute
  29. case percent
  30. }
  31. extension PumpHistoryEvent {
  32. private enum CodingKeys: String, CodingKey {
  33. case id
  34. case type = "_type"
  35. case timestamp
  36. case amount
  37. case duration
  38. case durationMin = "duration (min)"
  39. case rate
  40. case temp
  41. case carbInput = "carb_input"
  42. }
  43. }