CarbsEntry.swift 829 B

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