@@ -55,7 +55,10 @@ internal extension API {
5555 childFiles: [ UUID : ParseFile ] ? = nil ,
5656 uploadProgress: ( ( URLSessionTask , Int64 , Int64 , Int64 ) -> Void ) ? = nil ,
5757 stream: InputStream ) throws {
58- switch self . prepareURLRequest ( options: options, childObjects: childObjects, childFiles: childFiles) {
58+ switch self . prepareURLRequest ( options: options,
59+ batching: false ,
60+ childObjects: childObjects,
61+ childFiles: childFiles) {
5962
6063 case . success( let urlRequest) :
6164 if method == . POST || method == . PUT || method == . PATCH {
@@ -80,6 +83,7 @@ internal extension API {
8083 }
8184
8285 func execute( options: API . Options ,
86+ batching: Bool = false ,
8387 notificationQueue: DispatchQueue ? = nil ,
8488 childObjects: [ String : PointerType ] ? = nil ,
8589 childFiles: [ UUID : ParseFile ] ? = nil ,
@@ -94,6 +98,7 @@ internal extension API {
9498 let group = DispatchGroup ( )
9599 group. enter ( )
96100 self . executeAsync ( options: options,
101+ batching: batching,
97102 callbackQueue: synchronizationQueue,
98103 notificationQueue: notificationQueue,
99104 childObjects: childObjects,
@@ -115,6 +120,7 @@ internal extension API {
115120 // MARK: Asynchronous Execution
116121 // swiftlint:disable:next function_body_length cyclomatic_complexity
117122 func executeAsync( options: API . Options ,
123+ batching: Bool = false ,
118124 callbackQueue: DispatchQueue ,
119125 notificationQueue: DispatchQueue ? = nil ,
120126 childObjects: [ String : PointerType ] ? = nil ,
@@ -131,6 +137,7 @@ internal extension API {
131137 if !path. urlComponent. contains ( " /files/ " ) {
132138 // All ParseObjects use the shared URLSession
133139 switch self . prepareURLRequest ( options: options,
140+ batching: batching,
134141 childObjects: childObjects,
135142 childFiles: childFiles) {
136143 case . success( let urlRequest) :
@@ -156,6 +163,7 @@ internal extension API {
156163 // ParseFiles are handled with a dedicated URLSession
157164 if method == . POST || method == . PUT || method == . PATCH {
158165 switch self . prepareURLRequest ( options: options,
166+ batching: batching,
159167 childObjects: childObjects,
160168 childFiles: childFiles) {
161169
@@ -187,6 +195,7 @@ internal extension API {
187195 } else if method == . DELETE {
188196
189197 switch self . prepareURLRequest ( options: options,
198+ batching: batching,
190199 childObjects: childObjects,
191200 childFiles: childFiles) {
192201 case . success( let urlRequest) :
@@ -213,6 +222,7 @@ internal extension API {
213222
214223 if parseURL != nil {
215224 switch self . prepareURLRequest ( options: options,
225+ batching: batching,
216226 childObjects: childObjects,
217227 childFiles: childFiles) {
218228
@@ -266,6 +276,7 @@ internal extension API {
266276
267277 // MARK: URL Preperation
268278 func prepareURLRequest( options: API . Options ,
279+ batching: Bool = false ,
269280 childObjects: [ String : PointerType ] ? = nil ,
270281 childFiles: [ UUID : ParseFile ] ? = nil ) -> Result < URLRequest , ParseError > {
271282 let params = self . params? . getURLQueryItems ( )
@@ -299,7 +310,9 @@ internal extension API {
299310 } else {
300311 guard let bodyData = try ? ParseCoding
301312 . parseEncoder ( )
302- . encode ( urlBody, collectChildren: false ,
313+ . encode ( urlBody,
314+ batching: batching,
315+ collectChildren: false ,
303316 objectsSavedBeforeThisOne: childObjects,
304317 filesSavedBeforeThisOne: childFiles) else {
305318 return . failure( ParseError ( code: . unknownError,
@@ -393,14 +406,16 @@ internal extension API.Command {
393406 // MARK: Saving ParseObjects
394407 static func save< T> ( _ object: T ,
395408 original data: Data ? ,
396- ignoringCustomObjectIdConfig: Bool ) throws -> API . Command < T , T > where T: ParseObject {
397- if Parse . configuration. isAllowingCustomObjectIds
409+ ignoringCustomObjectIdConfig: Bool ,
410+ batching: Bool = false ) throws -> API . Command < T , T > where T: ParseObject {
411+ if Parse . configuration. isRequiringCustomObjectIds
398412 && object. objectId == nil && !ignoringCustomObjectIdConfig {
399413 throw ParseError ( code: . missingObjectId, message: " objectId must not be nil " )
400414 }
401415 if object. isSaved {
402416 // MARK: Should be switched to "update" when server supports PATCH.
403- return try replace ( object, original: data)
417+ return try replace ( object,
418+ original: data)
404419 }
405420 return create ( object)
406421 }
@@ -420,7 +435,8 @@ internal extension API.Command {
420435 mapper: mapper)
421436 }
422437
423- static func replace< T> ( _ object: T , original data: Data ? ) throws -> API . Command < T , T > where T: ParseObject {
438+ static func replace< T> ( _ object: T ,
439+ original data: Data ? ) throws -> API . Command < T , T > where T: ParseObject {
424440 guard object. objectId != nil else {
425441 throw ParseError ( code: . missingObjectId,
426442 message: " objectId must not be nil " )
@@ -446,7 +462,8 @@ internal extension API.Command {
446462 mapper: mapper)
447463 }
448464
449- static func update< T> ( _ object: T , original data: Data ? ) throws -> API . Command < T , T > where T: ParseObject {
465+ static func update< T> ( _ object: T ,
466+ original data: Data ? ) throws -> API . Command < T , T > where T: ParseObject {
450467 guard object. objectId != nil else {
451468 throw ParseError ( code: . missingObjectId,
452469 message: " objectId must not be nil " )
@@ -504,8 +521,10 @@ internal extension API.Command where T: ParseObject {
504521 guard let body = command. body else {
505522 return nil
506523 }
507- return API . Command < T , T > ( method: command. method, path: . any( path) ,
508- body: body, mapper: command. mapper)
524+ return API . Command < T , T > ( method: command. method,
525+ path: . any( path) ,
526+ body: body,
527+ mapper: command. mapper)
509528 }
510529
511530 let mapper = { ( data: Data ) -> [ Result < T , ParseError > ] in
0 commit comments