CarbsEntry.swift 879 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import Foundation
  2. struct CarbsEntry: JSON, Equatable, Hashable {
  3. let id: String?
  4. let createdAt: Date
  5. let actualDate: Date?
  6. let carbs: Decimal
  7. let fat: Decimal?
  8. let protein: Decimal?
  9. let note: String?
  10. let enteredBy: String?
  11. let isFPU: Bool?
  12. let fpuID: String?
  13. static let manual = "Open-iAPS"
  14. static let appleHealth = "applehealth"
  15. static func == (lhs: CarbsEntry, rhs: CarbsEntry) -> Bool {
  16. lhs.createdAt == rhs.createdAt
  17. }
  18. func hash(into hasher: inout Hasher) {
  19. hasher.combine(createdAt)
  20. }
  21. }
  22. extension CarbsEntry {
  23. private enum CodingKeys: String, CodingKey {
  24. case id = "_id"
  25. case createdAt = "created_at"
  26. case actualDate
  27. case carbs
  28. case fat
  29. case protein
  30. case note
  31. case enteredBy
  32. case isFPU
  33. case fpuID
  34. }
  35. }