Suggestion.swift 1009 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. let predictions: Predictions?
  13. }
  14. struct Predictions: JSON {
  15. let iob: [Int]?
  16. let zt: [Int]?
  17. let cob: [Int]?
  18. let uam: [Int]?
  19. }
  20. extension Suggestion {
  21. private enum CodingKeys: String, CodingKey {
  22. case reason
  23. case units
  24. case insulinReq
  25. case eventualBG
  26. case sensitivityRatio
  27. case rate
  28. case duration
  29. case iob = "IOB"
  30. case cob = "COB"
  31. case predictions = "predBGs"
  32. }
  33. }
  34. extension Predictions {
  35. private enum CodingKeys: String, CodingKey {
  36. case iob = "IOB"
  37. case zt = "ZT"
  38. case cob = "COB"
  39. case uam = "UAM"
  40. }
  41. }
  42. protocol SuggestionObserver {
  43. func suggestionDidUpdate(_ suggestion: Suggestion)
  44. }