Skip to content

Commit 26a1be1

Browse files
[Bookings] Handle attendance_status for booking (#16257)
2 parents 97ec53c + 92b1598 commit 26a1be1

File tree

10 files changed

+1241
-2
lines changed

10 files changed

+1241
-2
lines changed

Modules/Sources/Fakes/Networking.generated.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ extension Networking.Booking {
338338
resourceID: .fake(),
339339
startDate: .fake(),
340340
statusKey: .fake(),
341+
attendanceStatusKey: .fake(),
341342
localTimezone: .fake(),
342343
currency: .fake(),
343344
orderInfo: .fake()

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

Lines changed: 21 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,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.
190201
public 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+
}

Modules/Sources/Networking/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ extension Networking.Booking {
446446
resourceID: CopiableProp<Int64> = .copy,
447447
startDate: CopiableProp<Date> = .copy,
448448
statusKey: CopiableProp<String> = .copy,
449+
attendanceStatusKey: CopiableProp<String> = .copy,
449450
localTimezone: CopiableProp<String> = .copy,
450451
currency: CopiableProp<String> = .copy,
451452
orderInfo: NullableCopiableProp<BookingOrderInfo> = .copy
@@ -466,6 +467,7 @@ extension Networking.Booking {
466467
let resourceID = resourceID ?? self.resourceID
467468
let startDate = startDate ?? self.startDate
468469
let statusKey = statusKey ?? self.statusKey
470+
let attendanceStatusKey = attendanceStatusKey ?? self.attendanceStatusKey
469471
let localTimezone = localTimezone ?? self.localTimezone
470472
let currency = currency ?? self.currency
471473
let orderInfo = orderInfo ?? self.orderInfo
@@ -487,6 +489,7 @@ extension Networking.Booking {
487489
resourceID: resourceID,
488490
startDate: startDate,
489491
statusKey: statusKey,
492+
attendanceStatusKey: attendanceStatusKey,
490493
localTimezone: localTimezone,
491494
currency: currency,
492495
orderInfo: orderInfo

Modules/Sources/Storage/Model/Booking/Booking+CoreDataProperties.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extension Booking {
1919
@NSManaged public var googleCalendarEventID: String?
2020
@NSManaged public var orderItemID: Int64
2121
@NSManaged public var statusKey: String?
22+
@NSManaged public var attendanceStatusKey: String?
2223
@NSManaged public var localTimezone: String?
2324
@NSManaged public var currency: String?
2425
@NSManaged public var orderInfo: BookingOrderInfo?

Modules/Sources/Storage/Model/MIGRATIONS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This file documents changes in the WCiOS Storage data model. Please explain any changes to the data model as well as any custom migrations.
44

5+
## Model 129 (Release X.X.X.X)
6+
- @rafaelkayumov 2025-10-17
7+
- Added `attendanceStatusKey` attribute to `Booking` entity.
8+
59
## Model 128 (Release 23.5.0.0)
610
- @itsmeichigo 2025-10-14
711
- Added `BookingOrderInfo` entity.

Modules/Sources/Storage/Resources/WooCommerce.xcdatamodeld/.xccurrentversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<plist version="1.0">
44
<dict>
55
<key>_XCCurrentVersionName</key>
6-
<string>Model 128.xcdatamodel</string>
6+
<string>Model 129.xcdatamodel</string>
77
</dict>
88
</plist>

0 commit comments

Comments
 (0)