Suggestion.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import Foundation
  2. struct Suggestion: JSON {
  3. let reason: String
  4. let units: Decimal?
  5. let insulinReq: Decimal?
  6. let eventualBG: Int?
  7. let sensitivityRatio: Decimal?
  8. let rate: Decimal?
  9. let duration: Int?
  10. let iob: Decimal?
  11. let cob: Decimal?
  12. var predictions: Predictions?
  13. let deliverAt: Date?
  14. let carbsReq: Decimal?
  15. let temp: TempType?
  16. let bg: Int?
  17. let tick: String?
  18. let reservoir: Decimal?
  19. var timestamp: Date?
  20. var recieved: Bool?
  21. }
  22. struct Predictions: JSON {
  23. let iob: [Int]?
  24. let zt: [Int]?
  25. let cob: [Int]?
  26. let uam: [Int]?
  27. }
  28. extension Suggestion {
  29. private enum CodingKeys: String, CodingKey {
  30. case reason
  31. case units
  32. case insulinReq
  33. case eventualBG
  34. case sensitivityRatio
  35. case rate
  36. case duration
  37. case iob = "IOB"
  38. case cob = "COB"
  39. case predictions = "predBGs"
  40. case deliverAt
  41. case carbsReq
  42. case temp
  43. case bg
  44. case tick
  45. case reservoir
  46. case timestamp
  47. case recieved
  48. }
  49. }
  50. extension Predictions {
  51. private enum CodingKeys: String, CodingKey {
  52. case iob = "IOB"
  53. case zt = "ZT"
  54. case cob = "COB"
  55. case uam = "UAM"
  56. }
  57. }
  58. protocol SuggestionObserver {
  59. func suggestionDidUpdate(_ suggestion: Suggestion)
  60. }