TempTarget.swift 747 B

12345678910111213141516171819202122232425262728293031323334
  1. import Foundation
  2. struct TempTarget: JSON, Identifiable, Equatable {
  3. var id = UUID().uuidString
  4. let name: String?
  5. var createdAt: Date
  6. let targetTop: Decimal
  7. let targetBottom: Decimal
  8. let duration: Decimal
  9. let enteredBy: String?
  10. let reason: String?
  11. static let manual = "freeaps-x"
  12. static let custom = "Temp target"
  13. static let cancel = "Cancel"
  14. var displayName: String {
  15. name ?? reason ?? TempTarget.custom
  16. }
  17. }
  18. extension TempTarget {
  19. private enum CodingKeys: String, CodingKey {
  20. case id = "_id"
  21. case name
  22. case createdAt = "created_at"
  23. case targetTop
  24. case targetBottom
  25. case duration
  26. case enteredBy
  27. case reason
  28. }
  29. }