@@ -20,6 +20,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
2020 public let resourceID : Int64
2121 public let startDate : Date
2222 public let statusKey : String
23+ public let attendanceStatusKey : String
2324 public let localTimezone : String
2425 public let currency : String
2526 public let orderInfo : BookingOrderInfo ?
@@ -28,6 +29,11 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
2829 return BookingStatus ( rawValue: statusKey) ?? . unknown
2930 }
3031
32+ /// periphery: ignore - will be used in UI in upcoming PRs
33+ public var attendanceStatus : BookingAttendanceStatus {
34+ return BookingAttendanceStatus ( rawValue: attendanceStatusKey) ?? . unknown
35+ }
36+
3137 /// Booking struct initializer.
3238 ///
3339 public init ( siteID: Int64 ,
@@ -46,6 +52,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
4652 resourceID: Int64 ,
4753 startDate: Date ,
4854 statusKey: String ,
55+ attendanceStatusKey: String ,
4956 localTimezone: String ,
5057 currency: String ,
5158 orderInfo: BookingOrderInfo ? ) {
@@ -65,6 +72,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
6572 self . resourceID = resourceID
6673 self . startDate = startDate
6774 self . statusKey = statusKey
75+ self . attendanceStatusKey = attendanceStatusKey
6876 self . localTimezone = localTimezone
6977 self . currency = currency
7078 self . orderInfo = orderInfo
@@ -99,6 +107,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
99107 let resourceID = try container. decode ( Int64 . self, forKey: . resourceID)
100108 let startDate = Date ( timeIntervalSince1970: try container. decode ( Double . self, forKey: . startDate) )
101109 let statusKey = try container. decode ( String . self, forKey: . statusKey)
110+ let attendanceStatusKey = container. failsafeDecodeIfPresent ( String . self, forKey: . attendanceStatusKey) ?? " "
102111 let localTimezone = try container. decode ( String . self, forKey: . localTimezone)
103112 let currency = try container. decode ( String . self, forKey: . currency)
104113 let orderInfo : BookingOrderInfo ? = nil // to be prefilled when synced
@@ -119,6 +128,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
119128 resourceID: resourceID,
120129 startDate: startDate,
121130 statusKey: statusKey,
131+ attendanceStatusKey: attendanceStatusKey,
122132 localTimezone: localTimezone,
123133 currency: currency,
124134 orderInfo: orderInfo)
@@ -142,6 +152,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
142152 try container. encode ( resourceID, forKey: . resourceID)
143153 try container. encode ( startDate, forKey: . startDate)
144154 try container. encode ( statusKey, forKey: . statusKey)
155+ try container. encode ( attendanceStatusKey, forKey: . attendanceStatusKey)
145156 try container. encode ( localTimezone, forKey: . localTimezone)
146157 }
147158}
@@ -171,6 +182,7 @@ private extension Booking {
171182 case resourceID = " resource_id "
172183 case startDate = " start "
173184 case statusKey = " status "
185+ case attendanceStatusKey = " attendance_status "
174186 case localTimezone = " local_timezone "
175187 case currency
176188 }
@@ -185,7 +197,6 @@ enum BookingDecodingError: Error {
185197// MARK: - Supporting Types
186198//
187199
188- // periphery: ignore
189200/// Represents a Booking Status.
190201public enum BookingStatus : String , CaseIterable {
191202 case complete
@@ -196,3 +207,12 @@ public enum BookingStatus: String, CaseIterable {
196207 case confirmed
197208 case unknown
198209}
210+
211+ /// periphery: ignore - will be used in UI in upcoming PRs
212+ public enum BookingAttendanceStatus : String , CaseIterable {
213+ case booked
214+ case checkedIn = " checked-in "
215+ case cancelled
216+ case noShow = " no-show "
217+ case unknown
218+ }
0 commit comments