Skip to content
This repository was archived by the owner on Apr 18, 2023. It is now read-only.

Commit 712dfb3

Browse files
authored
Merge pull request #5 from microsoftgraph/vidadhee/BatchRequest
Support for Batch Requests
2 parents 8d361f1 + 29c12a5 commit 712dfb3

File tree

14 files changed

+831
-0
lines changed

14 files changed

+831
-0
lines changed

MSGraphCoreSDK/MSGraphCoreSDK.xcodeproj/project.pbxproj

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
E5069AD9211C1AD500432372 /* MSGraphCoreSDKTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E5069AD8211C1AD500432372 /* MSGraphCoreSDKTests.m */; };
1313
E5069ADB211C1AD500432372 /* MSGraphCoreSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E5DC73DA211412BF0040BAB6 /* MSGraphCoreSDK.framework */; };
1414
E5069AE2211C323D00432372 /* MSURLSessionManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E5069AE1211C323D00432372 /* MSURLSessionManagerTests.m */; };
15+
E5204FEE216F1D9900E64160 /* MSBatchRequestContent.h in Headers */ = {isa = PBXBuildFile; fileRef = E5204FE8216F1D9800E64160 /* MSBatchRequestContent.h */; settings = {ATTRIBUTES = (Public, ); }; };
16+
E5204FEF216F1D9900E64160 /* MSBatchRequestStep.h in Headers */ = {isa = PBXBuildFile; fileRef = E5204FE9216F1D9800E64160 /* MSBatchRequestStep.h */; settings = {ATTRIBUTES = (Public, ); }; };
17+
E5204FF0216F1D9900E64160 /* MSBatchResponseContent.m in Sources */ = {isa = PBXBuildFile; fileRef = E5204FEA216F1D9800E64160 /* MSBatchResponseContent.m */; };
18+
E5204FF1216F1D9900E64160 /* MSBatchRequestContent.m in Sources */ = {isa = PBXBuildFile; fileRef = E5204FEB216F1D9800E64160 /* MSBatchRequestContent.m */; };
19+
E5204FF2216F1D9900E64160 /* MSBatchResponseContent.h in Headers */ = {isa = PBXBuildFile; fileRef = E5204FEC216F1D9900E64160 /* MSBatchResponseContent.h */; settings = {ATTRIBUTES = (Public, ); }; };
20+
E5204FF3216F1D9900E64160 /* MSBatchRequestStep.m in Sources */ = {isa = PBXBuildFile; fileRef = E5204FED216F1D9900E64160 /* MSBatchRequestStep.m */; };
21+
E5204FF7216F371400E64160 /* MSErrorCodes.m in Sources */ = {isa = PBXBuildFile; fileRef = E5204FF5216F371400E64160 /* MSErrorCodes.m */; };
22+
E5204FF8216F371400E64160 /* MSErrorCodes.h in Headers */ = {isa = PBXBuildFile; fileRef = E5204FF6216F371400E64160 /* MSErrorCodes.h */; settings = {ATTRIBUTES = (Public, ); }; };
23+
E5204FFF2173A7C200E64160 /* MSBatchRequestStepTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E5204FFE2173A7C200E64160 /* MSBatchRequestStepTests.m */; };
24+
E52050012173AEA900E64160 /* MSBatchRequestContentTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E52050002173AEA900E64160 /* MSBatchRequestContentTests.m */; };
25+
E52050042174C1DB00E64160 /* MSBatchResponseContentTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E52050032174C1DB00E64160 /* MSBatchResponseContentTests.m */; };
26+
E52050062175B10800E64160 /* BatchResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = E52050052175B10800E64160 /* BatchResponse.json */; };
1527
E51E616C216DE4D300F1B3C0 /* MSRetryHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = E51E616A216DE4D300F1B3C0 /* MSRetryHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
1628
E51E616D216DE4D300F1B3C0 /* MSRetryHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = E51E616B216DE4D300F1B3C0 /* MSRetryHandler.m */; };
1729
E51E616F216E073F00F1B3C0 /* MSRetryHandlerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E51E616E216E073F00F1B3C0 /* MSRetryHandlerTests.m */; };
@@ -74,6 +86,18 @@
7486
E5069AD8211C1AD500432372 /* MSGraphCoreSDKTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSGraphCoreSDKTests.m; sourceTree = "<group>"; };
7587
E5069ADA211C1AD500432372 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7688
E5069AE1211C323D00432372 /* MSURLSessionManagerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSURLSessionManagerTests.m; sourceTree = "<group>"; };
89+
E5204FE8216F1D9800E64160 /* MSBatchRequestContent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSBatchRequestContent.h; sourceTree = "<group>"; };
90+
E5204FE9216F1D9800E64160 /* MSBatchRequestStep.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSBatchRequestStep.h; sourceTree = "<group>"; };
91+
E5204FEA216F1D9800E64160 /* MSBatchResponseContent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSBatchResponseContent.m; sourceTree = "<group>"; };
92+
E5204FEB216F1D9800E64160 /* MSBatchRequestContent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSBatchRequestContent.m; sourceTree = "<group>"; };
93+
E5204FEC216F1D9900E64160 /* MSBatchResponseContent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSBatchResponseContent.h; sourceTree = "<group>"; };
94+
E5204FED216F1D9900E64160 /* MSBatchRequestStep.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSBatchRequestStep.m; sourceTree = "<group>"; };
95+
E5204FF5216F371400E64160 /* MSErrorCodes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSErrorCodes.m; sourceTree = "<group>"; };
96+
E5204FF6216F371400E64160 /* MSErrorCodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSErrorCodes.h; sourceTree = "<group>"; };
97+
E5204FFE2173A7C200E64160 /* MSBatchRequestStepTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSBatchRequestStepTests.m; sourceTree = "<group>"; };
98+
E52050002173AEA900E64160 /* MSBatchRequestContentTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSBatchRequestContentTests.m; sourceTree = "<group>"; };
99+
E52050032174C1DB00E64160 /* MSBatchResponseContentTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSBatchResponseContentTests.m; sourceTree = "<group>"; };
100+
E52050052175B10800E64160 /* BatchResponse.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = BatchResponse.json; sourceTree = "<group>"; };
77101
E51E616A216DE4D300F1B3C0 /* MSRetryHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSRetryHandler.h; sourceTree = "<group>"; };
78102
E51E616B216DE4D300F1B3C0 /* MSRetryHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSRetryHandler.m; sourceTree = "<group>"; };
79103
E51E616E216E073F00F1B3C0 /* MSRetryHandlerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRetryHandlerTests.m; sourceTree = "<group>"; };
@@ -185,13 +209,16 @@
185209
E52AD96F212D271C005FED47 /* Session Tasks */,
186210
E5069AC6211AAEC900432372 /* MSConstants.h */,
187211
E5069AC7211AAEC900432372 /* MSConstants.m */,
212+
E5204FF6216F371400E64160 /* MSErrorCodes.h */,
213+
E5204FF5216F371400E64160 /* MSErrorCodes.m */,
188214
);
189215
path = Common;
190216
sourceTree = "<group>";
191217
};
192218
E5069AD7211C1AD500432372 /* MSGraphCoreSDKTests */ = {
193219
isa = PBXGroup;
194220
children = (
221+
E5204FFC2173A79100E64160 /* GraphContent */,
195222
E5B6DB6921497A3300836E1D /* Frameworks */,
196223
E573EE1121367A4000C5E884 /* HTTPClient */,
197224
E573EE0E2136568700C5E884 /* Resources */,
@@ -205,6 +232,45 @@
205232
path = MSGraphCoreSDKTests;
206233
sourceTree = "<group>";
207234
};
235+
E5204FE6216F1D4200E64160 /* GraphContent */ = {
236+
isa = PBXGroup;
237+
children = (
238+
E5204FE7216F1D7300E64160 /* BatchContent */,
239+
);
240+
path = GraphContent;
241+
sourceTree = "<group>";
242+
};
243+
E5204FE7216F1D7300E64160 /* BatchContent */ = {
244+
isa = PBXGroup;
245+
children = (
246+
E5204FE9216F1D9800E64160 /* MSBatchRequestStep.h */,
247+
E5204FED216F1D9900E64160 /* MSBatchRequestStep.m */,
248+
E5204FE8216F1D9800E64160 /* MSBatchRequestContent.h */,
249+
E5204FEB216F1D9800E64160 /* MSBatchRequestContent.m */,
250+
E5204FEC216F1D9900E64160 /* MSBatchResponseContent.h */,
251+
E5204FEA216F1D9800E64160 /* MSBatchResponseContent.m */,
252+
);
253+
path = BatchContent;
254+
sourceTree = "<group>";
255+
};
256+
E5204FFC2173A79100E64160 /* GraphContent */ = {
257+
isa = PBXGroup;
258+
children = (
259+
E5204FFD2173A79E00E64160 /* BatchContent */,
260+
);
261+
path = GraphContent;
262+
sourceTree = "<group>";
263+
};
264+
E5204FFD2173A79E00E64160 /* BatchContent */ = {
265+
isa = PBXGroup;
266+
children = (
267+
E5204FFE2173A7C200E64160 /* MSBatchRequestStepTests.m */,
268+
E52050002173AEA900E64160 /* MSBatchRequestContentTests.m */,
269+
E52050032174C1DB00E64160 /* MSBatchResponseContentTests.m */,
270+
);
271+
path = BatchContent;
272+
sourceTree = "<group>";
273+
};
208274
E5190C7F216DE371001699B5 /* RetryHandler */ = {
209275
isa = PBXGroup;
210276
children = (
@@ -251,6 +317,7 @@
251317
E573EE0E2136568700C5E884 /* Resources */ = {
252318
isa = PBXGroup;
253319
children = (
320+
E52050052175B10800E64160 /* BatchResponse.json */,
254321
E573EE0F2136569F00C5E884 /* UserPhoto.jpg */,
255322
);
256323
path = Resources;
@@ -336,6 +403,7 @@
336403
E5DC73DD211412BF0040BAB6 /* MSGraphCoreSDK.h */,
337404
E5069AC2211AACB600432372 /* Authentication */,
338405
E5069AC5211AAE6900432372 /* Common */,
406+
E5204FE6216F1D4200E64160 /* GraphContent */,
339407
E5DC73E5211418040040BAB6 /* HTTPClient */,
340408
E5DC73EA211418040040BAB6 /* Middleware */,
341409
E5DC73DE211412BF0040BAB6 /* Info.plist */,
@@ -415,6 +483,10 @@
415483
E52AD97C212D27DC005FED47 /* MSURLSessionDataTask.h in Headers */,
416484
E5DC7406211418050040BAB6 /* MSURLSessionTaskDelegate.h in Headers */,
417485
E5ECE09721427A6400A289C2 /* MSMiddlewareFactory.h in Headers */,
486+
E5204FEE216F1D9900E64160 /* MSBatchRequestContent.h in Headers */,
487+
E5204FF2216F1D9900E64160 /* MSBatchResponseContent.h in Headers */,
488+
E5204FF8216F371400E64160 /* MSErrorCodes.h in Headers */,
489+
E5204FEF216F1D9900E64160 /* MSBatchRequestStep.h in Headers */,
418490
E5ECE0A42146657900A289C2 /* MSRedirectHandler.h in Headers */,
419491
E51E616C216DE4D300F1B3C0 /* MSRetryHandler.h in Headers */,
420492
E5DC73DF211412BF0040BAB6 /* MSGraphCoreSDK.h in Headers */,
@@ -503,6 +575,7 @@
503575
buildActionMask = 2147483647;
504576
files = (
505577
E573EE102136569F00C5E884 /* UserPhoto.jpg in Resources */,
578+
E52050062175B10800E64160 /* BatchResponse.json in Resources */,
506579
);
507580
runOnlyForDeploymentPostprocessing = 0;
508581
};
@@ -520,7 +593,10 @@
520593
isa = PBXSourcesBuildPhase;
521594
buildActionMask = 2147483647;
522595
files = (
596+
E52050012173AEA900E64160 /* MSBatchRequestContentTests.m in Sources */,
523597
E573EE0D213525BA00C5E884 /* MSGraphWorkloadsTests.m in Sources */,
598+
E5204FFF2173A7C200E64160 /* MSBatchRequestStepTests.m in Sources */,
599+
E52050042174C1DB00E64160 /* MSBatchResponseContentTests.m in Sources */,
524600
E51E616F216E073F00F1B3C0 /* MSRetryHandlerTests.m in Sources */,
525601
E573EE072133FFF200C5E884 /* MSHTTPClientTests.m in Sources */,
526602
E52AD9E6212E8845005FED47 /* MSGraphCoreSDKTests.h in Sources */,
@@ -542,13 +618,17 @@
542618
isa = PBXSourcesBuildPhase;
543619
buildActionMask = 2147483647;
544620
files = (
621+
E5204FF1216F1D9900E64160 /* MSBatchRequestContent.m in Sources */,
622+
E5204FF7216F371400E64160 /* MSErrorCodes.m in Sources */,
545623
E5DC741A21142C430040BAB6 /* MSClientFactory.m in Sources */,
546624
E5069AC9211AAEC900432372 /* MSConstants.m in Sources */,
547625
E5ECE0A52146657900A289C2 /* MSRedirectHandler.m in Sources */,
548626
E5ECE09821427A6400A289C2 /* MSMiddlewareFactory.m in Sources */,
549627
E52AD97F212D27DC005FED47 /* MSURLSessionDownloadTask.m in Sources */,
628+
E5204FF3216F1D9900E64160 /* MSBatchRequestStep.m in Sources */,
550629
E5DC7405211418050040BAB6 /* MSURLSessionManager.m in Sources */,
551630
E52AD979212D27DC005FED47 /* MSURLSessionTask.m in Sources */,
631+
E5204FF0216F1D9900E64160 /* MSBatchResponseContent.m in Sources */,
552632
E51E616D216DE4D300F1B3C0 /* MSRetryHandler.m in Sources */,
553633
E5DC7408211418050040BAB6 /* MSURLSessionTaskDelegate.m in Sources */,
554634
E52AD97E212D27DC005FED47 /* MSURLSessionUploadTask.m in Sources */,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
//
4+
5+
#import <Foundation/Foundation.h>
6+
7+
#ifndef MSErrorCodes_h
8+
#define MSErrorCodes_h
9+
10+
11+
typedef NS_ENUM(NSInteger, MSErrorCode)
12+
{
13+
MSErrorCodeEmptyRequestId = -62300,
14+
MSErrorCodeNonUniqueRequestId = -62301,
15+
MSErrorCodeMaximumLimitReached = -62302,
16+
MSErrorCodeRequestIdNotAvailable = -62303
17+
};
18+
19+
extern NSString *const MSErrorStringEmptyRequestIdDescription;
20+
extern NSString *const MSErrorStringEmptyRequestIdReason;
21+
22+
extern NSString *const MSErrorStringNonUniqueRequestIdDescription;
23+
extern NSString *const MSErrorStringNonUniqueRequestIdReason;
24+
25+
extern NSString *const MSErrorStringMaximumBatchStepLimitReachedDescription;
26+
extern NSString *const MSErrorStringMaximumBatchStepLimitReachedReason;
27+
28+
extern NSString *const MSErrorStringRequestIdNotAvailableDescription;
29+
extern NSString *const MSErrorStringRequestIdNotAvailableReason;
30+
31+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
//
4+
5+
#import "MSErrorCodes.h"
6+
7+
NSString *const MSErrorStringEmptyRequestIdDescription = @"Empty id for request";
8+
NSString *const MSErrorStringEmptyRequestIdReason = @"Id for a request is empty, Please provide a unique id.";
9+
10+
NSString *const MSErrorStringNonUniqueRequestIdDescription = @"Duplicate RequestId Error";
11+
NSString *const MSErrorStringNonUniqueRequestIdReason = @"Couldn't add request with duplicate id %@, Make the id of requests unique.";
12+
13+
NSString *const MSErrorStringMaximumBatchStepLimitReachedDescription = @"Limit Exceeded Error";
14+
NSString *const MSErrorStringMaximumBatchStepLimitReachedReason = @"Maximum requests limit exceeded, Max allowed number of requests are %ld";
15+
16+
NSString *const MSErrorStringRequestIdNotAvailableDescription = @"Request id not found";
17+
NSString *const MSErrorStringRequestIdNotAvailableReason = @"Request id %@ is not present.";
18+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
//
4+
5+
#import <Foundation/Foundation.h>
6+
7+
@class MSBatchRequestStep;
8+
9+
/*
10+
To make batch requests, all the individual request needs to be clubbed in one single request body. This class provides mechanism to create that content for batch requests.
11+
Maximum limit of MSBatchRequestSteps in one single MSBatchRequestContent is set to 20.
12+
*/
13+
@interface MSBatchRequestContent : NSObject
14+
15+
/*
16+
Creates and returns an instance of MSBatchRequestContent
17+
@param batchRequestStepsArray Array of batch request steps with unique ids.
18+
@param error If any error is encountered during the initalization, it will be assigned to this address.
19+
@return The MSBatchRequestContent object containng the Batch Request Steps.
20+
*/
21+
- (instancetype)initWithRequests:(NSArray<MSBatchRequestStep *> *)batchRequestStepsArray error:(NSError **)error;
22+
23+
/*
24+
Adds an MSBatchRequestStep object to MSBatchRequestContent object
25+
@param batchRequestStep The object which needs to be added.
26+
@param error If any error is encountered while adding a batch request step, it will be assigned to this address.
27+
*/
28+
- (void)addBatchRequestStep:(MSBatchRequestStep *)batchRequestStep error:(NSError **)error;
29+
30+
/*
31+
Removes an MSBatchRequestStep object from MSBatchRequestContent object
32+
@param requestId Id of the MSBatchRequestStep which should be removed.
33+
@param error If any error is encountered during the removal of a batch request step, it will be assigned to this address.
34+
*/
35+
- (void)removeBatchRequesStepWithId:(NSString *)requestId error:(NSError **)error;
36+
37+
/*
38+
Creates and returns a dictionary object which is created by clubbing all the individual batch request step into a format recognised by Microsoft Graph server.
39+
@return A dictionary object.
40+
*/
41+
- (NSMutableDictionary *)getBatchRequestContent;
42+
43+
@end
44+

0 commit comments

Comments
 (0)