File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -129,8 +129,7 @@ public class OrdersRemote: Remote {
129129
130130 let parameters : [ String : Any ] = [
131131 ParameterKeys . include: Set ( orderIDs) . map ( String . init) . joined ( separator: " , " ) ,
132- ParameterKeys . fields: ParameterValues . fieldValues,
133- ParameterKeys . perPage: String ( orderIDs. count)
132+ ParameterKeys . fields: ParameterValues . fieldValues
134133 ]
135134
136135 let path = Constants . ordersPath
Original file line number Diff line number Diff line change @@ -103,6 +103,45 @@ private extension BookingStore {
103103 }
104104 }
105105
106+ func synchronizeBooking(
107+ siteID: Int64 ,
108+ bookingID: Int64 ,
109+ onCompletion: @escaping ( Result < Void , Error > ) -> Void
110+ ) {
111+ enum SynchronizeBookingError : Error {
112+ case bookingIsMissing
113+ }
114+
115+ Task { @MainActor in
116+ do {
117+ let booking = try await remote. loadBooking (
118+ bookingID: bookingID,
119+ siteID: siteID
120+ )
121+
122+ guard let booking else {
123+ onCompletion ( . failure( SynchronizeBookingError . bookingIsMissing) )
124+ return
125+ }
126+
127+ let orders = try await ordersRemote. loadOrders (
128+ for: siteID,
129+ orderIDs: [ booking. orderID]
130+ )
131+
132+ await upsertStoredBookingsInBackground (
133+ readOnlyBookings: [ booking] ,
134+ readOnlyOrders: orders,
135+ siteID: siteID
136+ )
137+
138+ onCompletion ( . success( ( ) ) )
139+ } catch {
140+ onCompletion ( . failure( error) )
141+ }
142+ }
143+ }
144+
106145 /// Checks if the store already has any bookings.
107146 /// Returns `false` if the store has no bookings.
108147 ///
You can’t perform that action at this time.
0 commit comments