Skip to content

Commit 17b6355

Browse files
committed
Add copiable for booking
1 parent a52d5d3 commit 17b6355

File tree

2 files changed

+70
-24
lines changed

2 files changed

+70
-24
lines changed

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

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public struct Booking: Codable, GeneratedCopiable, Equatable, GeneratedFakeable
2626
/// Computed Properties
2727
///
2828
public var bookingStatus: BookingStatus {
29-
return BookingStatus(rawValue: statusKey)
29+
return BookingStatus(rawValue: statusKey) ?? .unknown
3030
}
3131

3232
/// Booking struct initializer.
@@ -110,7 +110,6 @@ public struct Booking: Codable, GeneratedCopiable, Equatable, GeneratedFakeable
110110
orderID: orderID,
111111
orderItemID: orderItemID,
112112
parentID: parentID,
113-
personCounts: personCounts,
114113
productID: productID,
115114
resourceID: resourceID,
116115
startDate: startDate,
@@ -132,7 +131,6 @@ public struct Booking: Codable, GeneratedCopiable, Equatable, GeneratedFakeable
132131
try container.encode(orderID, forKey: .orderID)
133132
try container.encode(orderItemID, forKey: .orderItemID)
134133
try container.encode(parentID, forKey: .parentID)
135-
try container.encode(personCounts, forKey: .personCounts)
136134
try container.encode(productID, forKey: .productID)
137135
try container.encode(resourceID, forKey: .resourceID)
138136
try container.encode(startDate, forKey: .startDate)
@@ -178,23 +176,11 @@ enum BookingDecodingError: Error {
178176
/// Represents a Booking Status.
179177
///
180178
public enum BookingStatus: String, CaseIterable {
181-
case complete = "complete"
182-
case paid = "paid"
183-
case unpaid = "unpaid"
184-
case cancelled = "cancelled"
185-
186-
public init(rawValue: String) {
187-
switch rawValue {
188-
case "complete":
189-
self = .complete
190-
case "paid":
191-
self = .paid
192-
case "unpaid":
193-
self = .unpaid
194-
case "cancelled":
195-
self = .cancelled
196-
default:
197-
self = .unpaid
198-
}
199-
}
179+
case complete
180+
case paid
181+
case unpaid
182+
case cancelled
183+
case pendingConfirmation = "pending-confirmation"
184+
case inCart = "in-cart"
185+
case unknown
200186
}

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

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,66 @@ extension Networking.BlazeTargetTopic {
428428
}
429429
}
430430

431+
extension Networking.Booking {
432+
public func copy(
433+
siteID: CopiableProp<Int64> = .copy,
434+
bookingID: CopiableProp<Int64> = .copy,
435+
allDay: CopiableProp<Bool> = .copy,
436+
cost: CopiableProp<String> = .copy,
437+
customerID: CopiableProp<Int64> = .copy,
438+
dateCreated: CopiableProp<Date> = .copy,
439+
dateModified: CopiableProp<Date> = .copy,
440+
endDate: CopiableProp<Date> = .copy,
441+
googleCalendarEventID: NullableCopiableProp<String> = .copy,
442+
orderID: CopiableProp<Int64> = .copy,
443+
orderItemID: CopiableProp<Int64> = .copy,
444+
parentID: CopiableProp<Int64> = .copy,
445+
productID: CopiableProp<Int64> = .copy,
446+
resourceID: CopiableProp<Int64> = .copy,
447+
startDate: CopiableProp<Date> = .copy,
448+
statusKey: CopiableProp<String> = .copy,
449+
localTimezone: CopiableProp<String> = .copy
450+
) -> Networking.Booking {
451+
let siteID = siteID ?? self.siteID
452+
let bookingID = bookingID ?? self.bookingID
453+
let allDay = allDay ?? self.allDay
454+
let cost = cost ?? self.cost
455+
let customerID = customerID ?? self.customerID
456+
let dateCreated = dateCreated ?? self.dateCreated
457+
let dateModified = dateModified ?? self.dateModified
458+
let endDate = endDate ?? self.endDate
459+
let googleCalendarEventID = googleCalendarEventID ?? self.googleCalendarEventID
460+
let orderID = orderID ?? self.orderID
461+
let orderItemID = orderItemID ?? self.orderItemID
462+
let parentID = parentID ?? self.parentID
463+
let productID = productID ?? self.productID
464+
let resourceID = resourceID ?? self.resourceID
465+
let startDate = startDate ?? self.startDate
466+
let statusKey = statusKey ?? self.statusKey
467+
let localTimezone = localTimezone ?? self.localTimezone
468+
469+
return Networking.Booking(
470+
siteID: siteID,
471+
bookingID: bookingID,
472+
allDay: allDay,
473+
cost: cost,
474+
customerID: customerID,
475+
dateCreated: dateCreated,
476+
dateModified: dateModified,
477+
endDate: endDate,
478+
googleCalendarEventID: googleCalendarEventID,
479+
orderID: orderID,
480+
orderItemID: orderItemID,
481+
parentID: parentID,
482+
productID: productID,
483+
resourceID: resourceID,
484+
startDate: startDate,
485+
statusKey: statusKey,
486+
localTimezone: localTimezone
487+
)
488+
}
489+
}
490+
431491
extension Networking.Coupon {
432492
public func copy(
433493
siteID: CopiableProp<Int64> = .copy,
@@ -2749,8 +2809,8 @@ extension Networking.Site {
27492809
hasSSOEnabled: CopiableProp<Bool> = .copy,
27502810
applicationPasswordAvailable: CopiableProp<Bool> = .copy,
27512811
isGarden: CopiableProp<Bool> = .copy,
2752-
gardenName: CopiableProp<String?> = .copy,
2753-
gardenPartner: CopiableProp<String?> = .copy
2812+
gardenName: NullableCopiableProp<String> = .copy,
2813+
gardenPartner: NullableCopiableProp<String> = .copy
27542814
) -> Networking.Site {
27552815
let siteID = siteID ?? self.siteID
27562816
let name = name ?? self.name

0 commit comments

Comments
 (0)