@@ -55,7 +55,10 @@ internal extension API {
55
55
childFiles: [ UUID : ParseFile ] ? = nil ,
56
56
uploadProgress: ( ( URLSessionTask , Int64 , Int64 , Int64 ) -> Void ) ? = nil ,
57
57
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) {
59
62
60
63
case . success( let urlRequest) :
61
64
if method == . POST || method == . PUT || method == . PATCH {
@@ -80,6 +83,7 @@ internal extension API {
80
83
}
81
84
82
85
func execute( options: API . Options ,
86
+ batching: Bool = false ,
83
87
notificationQueue: DispatchQueue ? = nil ,
84
88
childObjects: [ String : PointerType ] ? = nil ,
85
89
childFiles: [ UUID : ParseFile ] ? = nil ,
@@ -94,6 +98,7 @@ internal extension API {
94
98
let group = DispatchGroup ( )
95
99
group. enter ( )
96
100
self . executeAsync ( options: options,
101
+ batching: batching,
97
102
callbackQueue: synchronizationQueue,
98
103
notificationQueue: notificationQueue,
99
104
childObjects: childObjects,
@@ -115,6 +120,7 @@ internal extension API {
115
120
// MARK: Asynchronous Execution
116
121
// swiftlint:disable:next function_body_length cyclomatic_complexity
117
122
func executeAsync( options: API . Options ,
123
+ batching: Bool = false ,
118
124
callbackQueue: DispatchQueue ,
119
125
notificationQueue: DispatchQueue ? = nil ,
120
126
childObjects: [ String : PointerType ] ? = nil ,
@@ -131,6 +137,7 @@ internal extension API {
131
137
if !path. urlComponent. contains ( " /files/ " ) {
132
138
// All ParseObjects use the shared URLSession
133
139
switch self . prepareURLRequest ( options: options,
140
+ batching: batching,
134
141
childObjects: childObjects,
135
142
childFiles: childFiles) {
136
143
case . success( let urlRequest) :
@@ -156,6 +163,7 @@ internal extension API {
156
163
// ParseFiles are handled with a dedicated URLSession
157
164
if method == . POST || method == . PUT || method == . PATCH {
158
165
switch self . prepareURLRequest ( options: options,
166
+ batching: batching,
159
167
childObjects: childObjects,
160
168
childFiles: childFiles) {
161
169
@@ -187,6 +195,7 @@ internal extension API {
187
195
} else if method == . DELETE {
188
196
189
197
switch self . prepareURLRequest ( options: options,
198
+ batching: batching,
190
199
childObjects: childObjects,
191
200
childFiles: childFiles) {
192
201
case . success( let urlRequest) :
@@ -213,6 +222,7 @@ internal extension API {
213
222
214
223
if parseURL != nil {
215
224
switch self . prepareURLRequest ( options: options,
225
+ batching: batching,
216
226
childObjects: childObjects,
217
227
childFiles: childFiles) {
218
228
@@ -266,6 +276,7 @@ internal extension API {
266
276
267
277
// MARK: URL Preperation
268
278
func prepareURLRequest( options: API . Options ,
279
+ batching: Bool = false ,
269
280
childObjects: [ String : PointerType ] ? = nil ,
270
281
childFiles: [ UUID : ParseFile ] ? = nil ) -> Result < URLRequest , ParseError > {
271
282
let params = self . params? . getURLQueryItems ( )
@@ -299,7 +310,9 @@ internal extension API {
299
310
} else {
300
311
guard let bodyData = try ? ParseCoding
301
312
. parseEncoder ( )
302
- . encode ( urlBody, collectChildren: false ,
313
+ . encode ( urlBody,
314
+ batching: batching,
315
+ collectChildren: false ,
303
316
objectsSavedBeforeThisOne: childObjects,
304
317
filesSavedBeforeThisOne: childFiles) else {
305
318
return . failure( ParseError ( code: . unknownError,
@@ -393,14 +406,16 @@ internal extension API.Command {
393
406
// MARK: Saving ParseObjects
394
407
static func save< T> ( _ object: T ,
395
408
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
398
412
&& object. objectId == nil && !ignoringCustomObjectIdConfig {
399
413
throw ParseError ( code: . missingObjectId, message: " objectId must not be nil " )
400
414
}
401
415
if object. isSaved {
402
416
// 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)
404
419
}
405
420
return create ( object)
406
421
}
@@ -420,7 +435,8 @@ internal extension API.Command {
420
435
mapper: mapper)
421
436
}
422
437
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 {
424
440
guard object. objectId != nil else {
425
441
throw ParseError ( code: . missingObjectId,
426
442
message: " objectId must not be nil " )
@@ -446,7 +462,8 @@ internal extension API.Command {
446
462
mapper: mapper)
447
463
}
448
464
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 {
450
467
guard object. objectId != nil else {
451
468
throw ParseError ( code: . missingObjectId,
452
469
message: " objectId must not be nil " )
@@ -504,8 +521,10 @@ internal extension API.Command where T: ParseObject {
504
521
guard let body = command. body else {
505
522
return nil
506
523
}
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)
509
528
}
510
529
511
530
let mapper = { ( data: Data ) -> [ Result < T , ParseError > ] in
0 commit comments