Skip to content

Commit f293a37

Browse files
committed
Add attendance status property to readonly booking
1 parent 26a1d72 commit f293a37

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Modules/Sources/Networking/Model/Bookings/Booking.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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,10 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
2829
return BookingStatus(rawValue: statusKey) ?? .unknown
2930
}
3031

32+
public var attendanceStatus: BookingAttendanceStatus {
33+
return BookingAttendanceStatus(rawValue: attendanceStatusKey) ?? .unknown
34+
}
35+
3136
/// Booking struct initializer.
3237
///
3338
public init(siteID: Int64,
@@ -46,6 +51,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
4651
resourceID: Int64,
4752
startDate: Date,
4853
statusKey: String,
54+
attendanceStatusKey: String,
4955
localTimezone: String,
5056
currency: String,
5157
orderInfo: BookingOrderInfo?) {
@@ -65,6 +71,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
6571
self.resourceID = resourceID
6672
self.startDate = startDate
6773
self.statusKey = statusKey
74+
self.attendanceStatusKey = attendanceStatusKey
6875
self.localTimezone = localTimezone
6976
self.currency = currency
7077
self.orderInfo = orderInfo
@@ -99,6 +106,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
99106
let resourceID = try container.decode(Int64.self, forKey: .resourceID)
100107
let startDate = Date(timeIntervalSince1970: try container.decode(Double.self, forKey: .startDate))
101108
let statusKey = try container.decode(String.self, forKey: .statusKey)
109+
let attendanceStatusKey = try container.decode(String.self, forKey: .attendanceStatusKey)
102110
let localTimezone = try container.decode(String.self, forKey: .localTimezone)
103111
let currency = try container.decode(String.self, forKey: .currency)
104112
let orderInfo: BookingOrderInfo? = nil // to be prefilled when synced
@@ -142,6 +150,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
142150
try container.encode(resourceID, forKey: .resourceID)
143151
try container.encode(startDate, forKey: .startDate)
144152
try container.encode(statusKey, forKey: .statusKey)
153+
try container.encode(attendanceStatusKey, forKey: .attendanceStatusKey)
145154
try container.encode(localTimezone, forKey: .localTimezone)
146155
}
147156
}
@@ -171,6 +180,7 @@ private extension Booking {
171180
case resourceID = "resource_id"
172181
case startDate = "start"
173182
case statusKey = "status"
183+
case attendanceStatusKey = "attendance_status"
174184
case localTimezone = "local_timezone"
175185
case currency
176186
}
@@ -185,7 +195,6 @@ enum BookingDecodingError: Error {
185195
// MARK: - Supporting Types
186196
//
187197

188-
// periphery: ignore
189198
/// Represents a Booking Status.
190199
public enum BookingStatus: String, CaseIterable {
191200
case complete
@@ -196,3 +205,11 @@ public enum BookingStatus: String, CaseIterable {
196205
case confirmed
197206
case unknown
198207
}
208+
209+
public enum BookingAttendanceStatus: String, CaseIterable {
210+
case booked
211+
case checkedIn = "checked_in"
212+
case cancelled
213+
case noShow = "no_show"
214+
case unknown
215+
}

0 commit comments

Comments
 (0)