PumpHistoryEvent.swift 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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: PumpHistoryTempType?
  11. }
  12. enum PumpHistoryEventType: String, JSON {
  13. case bolus = "Bolus"
  14. case mealBulus = "Meal Bolus"
  15. case correctionBolus = "Correction Bolus"
  16. case snackBolus = "Snack Bolus"
  17. case bolusWizard = "BolusWizard"
  18. case tempBasal = "TempBasal"
  19. case tempBasalDuration = "TempBasalDuration"
  20. case pumpSuspend = "PumpSuspend"
  21. case pumpResume = "PumpResume"
  22. case rewind = "Rewind"
  23. case prime = "Prime"
  24. }
  25. enum PumpHistoryTempType: String, JSON {
  26. case absolute
  27. case percent
  28. }
  29. extension PumpHistoryEvent {
  30. private enum CodingKeys: String, CodingKey {
  31. case id
  32. case type = "_type"
  33. case timestamp
  34. case amount
  35. case duration
  36. case durationMin = "duration (min)"
  37. case rate
  38. case temp
  39. }
  40. }