Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Modules/Sources/Fakes/Networking.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ extension Networking.Booking {
resourceID: .fake(),
startDate: .fake(),
statusKey: .fake(),
attendanceStatusKey: .fake(),
localTimezone: .fake(),
currency: .fake(),
orderInfo: .fake()
Expand Down
22 changes: 21 additions & 1 deletion Modules/Sources/Networking/Model/Bookings/Booking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
public let resourceID: Int64
public let startDate: Date
public let statusKey: String
public let attendanceStatusKey: String
public let localTimezone: String
public let currency: String
public let orderInfo: BookingOrderInfo?
Expand All @@ -28,6 +29,11 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
return BookingStatus(rawValue: statusKey) ?? .unknown
}

/// periphery: ignore - will be used in UI in upcoming PRs
public var attendanceStatus: BookingAttendanceStatus {
return BookingAttendanceStatus(rawValue: attendanceStatusKey) ?? .unknown
}

/// Booking struct initializer.
///
public init(siteID: Int64,
Expand All @@ -46,6 +52,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
resourceID: Int64,
startDate: Date,
statusKey: String,
attendanceStatusKey: String,
localTimezone: String,
currency: String,
orderInfo: BookingOrderInfo?) {
Expand All @@ -65,6 +72,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
self.resourceID = resourceID
self.startDate = startDate
self.statusKey = statusKey
self.attendanceStatusKey = attendanceStatusKey
self.localTimezone = localTimezone
self.currency = currency
self.orderInfo = orderInfo
Expand Down Expand Up @@ -99,6 +107,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
let resourceID = try container.decode(Int64.self, forKey: .resourceID)
let startDate = Date(timeIntervalSince1970: try container.decode(Double.self, forKey: .startDate))
let statusKey = try container.decode(String.self, forKey: .statusKey)
let attendanceStatusKey = container.failsafeDecodeIfPresent(String.self, forKey: .attendanceStatusKey) ?? ""
let localTimezone = try container.decode(String.self, forKey: .localTimezone)
let currency = try container.decode(String.self, forKey: .currency)
let orderInfo: BookingOrderInfo? = nil // to be prefilled when synced
Expand All @@ -119,6 +128,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
resourceID: resourceID,
startDate: startDate,
statusKey: statusKey,
attendanceStatusKey: attendanceStatusKey,
localTimezone: localTimezone,
currency: currency,
orderInfo: orderInfo)
Expand All @@ -142,6 +152,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
try container.encode(resourceID, forKey: .resourceID)
try container.encode(startDate, forKey: .startDate)
try container.encode(statusKey, forKey: .statusKey)
try container.encode(attendanceStatusKey, forKey: .attendanceStatusKey)
try container.encode(localTimezone, forKey: .localTimezone)
}
}
Expand Down Expand Up @@ -171,6 +182,7 @@ private extension Booking {
case resourceID = "resource_id"
case startDate = "start"
case statusKey = "status"
case attendanceStatusKey = "attendance_status"
case localTimezone = "local_timezone"
case currency
}
Expand All @@ -185,7 +197,6 @@ enum BookingDecodingError: Error {
// MARK: - Supporting Types
//

// periphery: ignore
/// Represents a Booking Status.
public enum BookingStatus: String, CaseIterable {
case complete
Expand All @@ -196,3 +207,12 @@ public enum BookingStatus: String, CaseIterable {
case confirmed
case unknown
}

/// periphery: ignore - will be used in UI in upcoming PRs
public enum BookingAttendanceStatus: String, CaseIterable {
case booked
case checkedIn = "checked-in"
case cancelled
case noShow = "no-show"
case unknown
}
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ extension Networking.Booking {
resourceID: CopiableProp<Int64> = .copy,
startDate: CopiableProp<Date> = .copy,
statusKey: CopiableProp<String> = .copy,
attendanceStatusKey: CopiableProp<String> = .copy,
localTimezone: CopiableProp<String> = .copy,
currency: CopiableProp<String> = .copy,
orderInfo: NullableCopiableProp<BookingOrderInfo> = .copy
Expand All @@ -466,6 +467,7 @@ extension Networking.Booking {
let resourceID = resourceID ?? self.resourceID
let startDate = startDate ?? self.startDate
let statusKey = statusKey ?? self.statusKey
let attendanceStatusKey = attendanceStatusKey ?? self.attendanceStatusKey
let localTimezone = localTimezone ?? self.localTimezone
let currency = currency ?? self.currency
let orderInfo = orderInfo ?? self.orderInfo
Expand All @@ -487,6 +489,7 @@ extension Networking.Booking {
resourceID: resourceID,
startDate: startDate,
statusKey: statusKey,
attendanceStatusKey: attendanceStatusKey,
localTimezone: localTimezone,
currency: currency,
orderInfo: orderInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension Booking {
@NSManaged public var googleCalendarEventID: String?
@NSManaged public var orderItemID: Int64
@NSManaged public var statusKey: String?
@NSManaged public var attendanceStatusKey: String?
@NSManaged public var localTimezone: String?
@NSManaged public var currency: String?
@NSManaged public var orderInfo: BookingOrderInfo?
Expand Down
4 changes: 4 additions & 0 deletions Modules/Sources/Storage/Model/MIGRATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## Model 129 (Release X.X.X.X)
- @rafaelkayumov 2025-10-17
- Added `attendanceStatusKey` attribute to `Booking` entity.

## Model 128 (Release 23.5.0.0)
- @itsmeichigo 2025-10-14
- Added `BookingOrderInfo` entity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Model 128.xcdatamodel</string>
<string>Model 129.xcdatamodel</string>
</dict>
</plist>
Loading