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

Commit 8f68561

Browse files
authored
Merge pull request #21 from microsoftgraph/dev
Dev to master merge
2 parents a07f52b + 9534cbe commit 8f68561

28 files changed

+779
-39
lines changed

MSGraphClientSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Pod::Spec.new do |s|
33

44
s.name = "MSGraphClientSDK"
5-
s.version = "0.1.2"
5+
s.version = "0.1.3"
66
s.summary = "Microsoft Graph ObjC SDK."
77

88
s.description = <<-DESC

MSGraphClientSDK/MSGraphClientSDK.xcodeproj/project.pbxproj

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
E52AD9F62133E740005FED47 /* MSURLSessionUploadTaskTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E52AD9F52133E73F005FED47 /* MSURLSessionUploadTaskTests.m */; };
3535
E566782E2150BC4F00C6B7AE /* MSRedirectHandlerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E566782D2150BC4F00C6B7AE /* MSRedirectHandlerTests.m */; };
3636
E56678302150E1AF00C6B7AE /* MSAuthenticationHandlerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E566782F2150E1AF00C6B7AE /* MSAuthenticationHandlerTests.m */; };
37+
E56B101C2220086300ED640F /* MSRedirectHandlerOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E56B101A2220086300ED640F /* MSRedirectHandlerOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
38+
E56B101D2220086300ED640F /* MSRedirectHandlerOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = E56B101B2220086300ED640F /* MSRedirectHandlerOptions.m */; };
39+
E56B102022237F6500ED640F /* MSRetryHandlerOptionsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E56B101F22237F6500ED640F /* MSRetryHandlerOptionsTests.m */; };
40+
E56B1022222382E400ED640F /* MSRedirectHandlerOptionsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E56B1021222382E400ED640F /* MSRedirectHandlerOptionsTests.m */; };
3741
E56FDB9321D36A98001DFE68 /* MSURLSessionDownloadTask.h in Headers */ = {isa = PBXBuildFile; fileRef = E56FDB8B21D36A98001DFE68 /* MSURLSessionDownloadTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
3842
E56FDB9421D36A98001DFE68 /* MSURLSessionTask.m in Sources */ = {isa = PBXBuildFile; fileRef = E56FDB8C21D36A98001DFE68 /* MSURLSessionTask.m */; };
3943
E56FDB9521D36A98001DFE68 /* MSURLSessionUploadTask.h in Headers */ = {isa = PBXBuildFile; fileRef = E56FDB8D21D36A98001DFE68 /* MSURLSessionUploadTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -47,6 +51,9 @@
4751
E573EE0B213427ED00C5E884 /* MSURLSessionTaskDelegateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E573EE0A213427ED00C5E884 /* MSURLSessionTaskDelegateTests.m */; };
4852
E573EE0D213525BA00C5E884 /* MSGraphWorkloadsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E573EE0C213525BA00C5E884 /* MSGraphWorkloadsTests.m */; };
4953
E573EE102136569F00C5E884 /* UserPhoto.jpg in Resources */ = {isa = PBXBuildFile; fileRef = E573EE0F2136569F00C5E884 /* UserPhoto.jpg */; };
54+
E59EBFEF221D3B6800B4B279 /* MSRetryHandlerOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E59EBFEC221D3B6700B4B279 /* MSRetryHandlerOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
55+
E59EBFF0221D3B6800B4B279 /* MSRetryHandlerOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = E59EBFED221D3B6700B4B279 /* MSRetryHandlerOptions.m */; };
56+
E59EBFF1221D3B6800B4B279 /* MSMiddlewareOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E59EBFEE221D3B6700B4B279 /* MSMiddlewareOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
5057
E5B6DB9821497DAA00836E1D /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E5B6DB9621497D7C00836E1D /* libOCMock.a */; };
5158
E5DC73DF211412BF0040BAB6 /* MSGraphClientSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = E5DC73DD211412BF0040BAB6 /* MSGraphClientSDK.h */; settings = {ATTRIBUTES = (Public, ); }; };
5259
E5DC7403211418050040BAB6 /* MSAuthenticationHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = E5DC73EB211418040040BAB6 /* MSAuthenticationHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -108,6 +115,10 @@
108115
E52AD9F52133E73F005FED47 /* MSURLSessionUploadTaskTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSURLSessionUploadTaskTests.m; sourceTree = "<group>"; };
109116
E566782D2150BC4F00C6B7AE /* MSRedirectHandlerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRedirectHandlerTests.m; sourceTree = "<group>"; };
110117
E566782F2150E1AF00C6B7AE /* MSAuthenticationHandlerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSAuthenticationHandlerTests.m; sourceTree = "<group>"; };
118+
E56B101A2220086300ED640F /* MSRedirectHandlerOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSRedirectHandlerOptions.h; sourceTree = "<group>"; };
119+
E56B101B2220086300ED640F /* MSRedirectHandlerOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRedirectHandlerOptions.m; sourceTree = "<group>"; };
120+
E56B101F22237F6500ED640F /* MSRetryHandlerOptionsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRetryHandlerOptionsTests.m; sourceTree = "<group>"; };
121+
E56B1021222382E400ED640F /* MSRedirectHandlerOptionsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRedirectHandlerOptionsTests.m; sourceTree = "<group>"; };
111122
E56FDB8B21D36A98001DFE68 /* MSURLSessionDownloadTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSURLSessionDownloadTask.h; sourceTree = "<group>"; };
112123
E56FDB8C21D36A98001DFE68 /* MSURLSessionTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSURLSessionTask.m; sourceTree = "<group>"; };
113124
E56FDB8D21D36A98001DFE68 /* MSURLSessionUploadTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSURLSessionUploadTask.h; sourceTree = "<group>"; };
@@ -121,6 +132,9 @@
121132
E573EE0A213427ED00C5E884 /* MSURLSessionTaskDelegateTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSURLSessionTaskDelegateTests.m; sourceTree = "<group>"; };
122133
E573EE0C213525BA00C5E884 /* MSGraphWorkloadsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSGraphWorkloadsTests.m; sourceTree = "<group>"; };
123134
E573EE0F2136569F00C5E884 /* UserPhoto.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = UserPhoto.jpg; sourceTree = "<group>"; };
135+
E59EBFEC221D3B6700B4B279 /* MSRetryHandlerOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSRetryHandlerOptions.h; sourceTree = "<group>"; };
136+
E59EBFED221D3B6700B4B279 /* MSRetryHandlerOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSRetryHandlerOptions.m; sourceTree = "<group>"; };
137+
E59EBFEE221D3B6700B4B279 /* MSMiddlewareOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSMiddlewareOptions.h; sourceTree = "<group>"; };
124138
E5B6DB8C21497CAC00836E1D /* OCMockObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMockObject.h; sourceTree = "<group>"; };
125139
E5B6DB8D21497CAC00836E1D /* OCMMacroState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMMacroState.h; sourceTree = "<group>"; };
126140
E5B6DB8E21497CAC00836E1D /* OCMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMock.h; sourceTree = "<group>"; };
@@ -294,22 +308,32 @@
294308
E52AD9F82133F16D005FED47 /* Middleware */ = {
295309
isa = PBXGroup;
296310
children = (
311+
E56B101E22237F3900ED640F /* Options */,
297312
E573EE1221367A7800C5E884 /* Implementations */,
298313
);
299314
path = Middleware;
300315
sourceTree = "<group>";
301316
};
317+
E56B101E22237F3900ED640F /* Options */ = {
318+
isa = PBXGroup;
319+
children = (
320+
E56B101F22237F6500ED640F /* MSRetryHandlerOptionsTests.m */,
321+
E56B1021222382E400ED640F /* MSRedirectHandlerOptionsTests.m */,
322+
);
323+
path = Options;
324+
sourceTree = "<group>";
325+
};
302326
E56FDB8A21D36A98001DFE68 /* Session Tasks */ = {
303327
isa = PBXGroup;
304328
children = (
305-
E56FDB8B21D36A98001DFE68 /* MSURLSessionDownloadTask.h */,
306-
E56FDB8C21D36A98001DFE68 /* MSURLSessionTask.m */,
307-
E56FDB8D21D36A98001DFE68 /* MSURLSessionUploadTask.h */,
308-
E56FDB8E21D36A98001DFE68 /* MSURLSessionDataTask.m */,
309329
E56FDB8F21D36A98001DFE68 /* MSURLSessionTask.h */,
330+
E56FDB8C21D36A98001DFE68 /* MSURLSessionTask.m */,
331+
E56FDB8B21D36A98001DFE68 /* MSURLSessionDownloadTask.h */,
310332
E56FDB9021D36A98001DFE68 /* MSURLSessionDownloadTask.m */,
311-
E56FDB9121D36A98001DFE68 /* MSURLSessionUploadTask.m */,
312333
E56FDB9221D36A98001DFE68 /* MSURLSessionDataTask.h */,
334+
E56FDB8E21D36A98001DFE68 /* MSURLSessionDataTask.m */,
335+
E56FDB8D21D36A98001DFE68 /* MSURLSessionUploadTask.h */,
336+
E56FDB9121D36A98001DFE68 /* MSURLSessionUploadTask.m */,
313337
);
314338
path = "Session Tasks";
315339
sourceTree = "<group>";
@@ -345,6 +369,18 @@
345369
path = Implementations;
346370
sourceTree = "<group>";
347371
};
372+
E59EBFEB221D3B6700B4B279 /* Options */ = {
373+
isa = PBXGroup;
374+
children = (
375+
E59EBFEE221D3B6700B4B279 /* MSMiddlewareOptions.h */,
376+
E59EBFEC221D3B6700B4B279 /* MSRetryHandlerOptions.h */,
377+
E59EBFED221D3B6700B4B279 /* MSRetryHandlerOptions.m */,
378+
E56B101A2220086300ED640F /* MSRedirectHandlerOptions.h */,
379+
E56B101B2220086300ED640F /* MSRedirectHandlerOptions.m */,
380+
);
381+
path = Options;
382+
sourceTree = "<group>";
383+
};
348384
E5B6DB6921497A3300836E1D /* Frameworks */ = {
349385
isa = PBXGroup;
350386
children = (
@@ -427,6 +463,7 @@
427463
E5DC73EA211418040040BAB6 /* Middleware */ = {
428464
isa = PBXGroup;
429465
children = (
466+
E59EBFEB221D3B6700B4B279 /* Options */,
430467
E5DC73F8211418040040BAB6 /* Protocols */,
431468
E5069AC3211AACCD00432372 /* Implementations */,
432469
);
@@ -488,7 +525,10 @@
488525
E5204FF8216F371400E64160 /* MSErrorCodes.h in Headers */,
489526
E5204FEF216F1D9900E64160 /* MSBatchRequestStep.h in Headers */,
490527
E5ECE0A42146657900A289C2 /* MSRedirectHandler.h in Headers */,
528+
E59EBFF1221D3B6800B4B279 /* MSMiddlewareOptions.h in Headers */,
529+
E59EBFEF221D3B6800B4B279 /* MSRetryHandlerOptions.h in Headers */,
491530
E51E616C216DE4D300F1B3C0 /* MSRetryHandler.h in Headers */,
531+
E56B101C2220086300ED640F /* MSRedirectHandlerOptions.h in Headers */,
492532
E5DC73DF211412BF0040BAB6 /* MSGraphClientSDK.h in Headers */,
493533
);
494534
runOnlyForDeploymentPostprocessing = 0;
@@ -598,7 +638,9 @@
598638
E5204FFF2173A7C200E64160 /* MSBatchRequestStepTests.m in Sources */,
599639
E52050042174C1DB00E64160 /* MSBatchResponseContentTests.m in Sources */,
600640
E51E616F216E073F00F1B3C0 /* MSRetryHandlerTests.m in Sources */,
641+
E56B1022222382E400ED640F /* MSRedirectHandlerOptionsTests.m in Sources */,
601642
E573EE072133FFF200C5E884 /* MSHTTPClientTests.m in Sources */,
643+
E56B102022237F6500ED640F /* MSRetryHandlerOptionsTests.m in Sources */,
602644
E52AD9E6212E8845005FED47 /* MSGraphClientSDKTests.h in Sources */,
603645
E56678302150E1AF00C6B7AE /* MSAuthenticationHandlerTests.m in Sources */,
604646
E52AD9F42133E171005FED47 /* MSURLSessionDownloadTaskTests.m in Sources */,
@@ -621,6 +663,8 @@
621663
E5204FF1216F1D9900E64160 /* MSBatchRequestContent.m in Sources */,
622664
E56FDB9421D36A98001DFE68 /* MSURLSessionTask.m in Sources */,
623665
E5204FF7216F371400E64160 /* MSErrorCodes.m in Sources */,
666+
E59EBFF0221D3B6800B4B279 /* MSRetryHandlerOptions.m in Sources */,
667+
E56B101D2220086300ED640F /* MSRedirectHandlerOptions.m in Sources */,
624668
E5DC741A21142C430040BAB6 /* MSClientFactory.m in Sources */,
625669
E5069AC9211AAEC900432372 /* MSConstants.m in Sources */,
626670
E56FDB9821D36A98001DFE68 /* MSURLSessionDownloadTask.m in Sources */,

MSGraphClientSDK/MSGraphClientSDK/Common/MSConstants.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
typedef NS_ENUM(NSInteger, MSClientErrorCode)
1111
{
12+
MSCLientErrorCodeSDKUpperLimitReached = -1,
1213
MSClientErrorCodeBadRequest = 400,
1314
MSClientErrorCodeUnauthorized = 401,
1415
MSClientErrorCodeForbidden = 403,
@@ -43,7 +44,19 @@ typedef NS_ENUM(NSInteger, MSExpectedResponseCodes)
4344
MSExpectedResponseCodesTemporaryRedirect = 307,
4445
};
4546

47+
typedef NS_ENUM(NSInteger, MSMiddlewareOptionsType)
48+
{
49+
MSMiddlewareOptionsTypeNone,
50+
MSMiddlewareOptionsTypeAuth,
51+
MSMiddlewareOptionsTypeRedirect,
52+
MSMiddlewareOptionsTypeRetry
53+
};
54+
4655
extern NSString *const MSGraphBaseURL;
56+
extern NSString *const MSGraphChinaBaseURL;
57+
extern NSString *const MSGraphUSBaseURL;
58+
extern NSString *const MSGraphGermanyBaseURL;
59+
4760
extern NSString *const MSHeaderSdkVersion;
4861
extern NSString *const MSGraphiOSSdkVersionHeaderPrefix;
4962
extern NSString *const MSGraphMacSdkVersionHeaderPrefix;
@@ -53,9 +66,12 @@ extern NSString *const MSErrorDomain;
5366
extern NSString *const MSErrorTooManyRedirectsFormatString;
5467
extern NSString *const MSErrorLocationHeaderNotFoundString;
5568
extern NSString *const MSErrorOperationUnsuccessfulString;
69+
extern NSString *const MSErrorMaxRedirectsLimitExceededString;
5670

5771
extern NSString *const MSErrorTooManyRetries;
5872
extern NSString *const MSErrorTooManyRetriesFormatString;
73+
extern NSString *const MSErrorDelayLimitExceededString;
74+
extern NSString *const MSErrorMaxRetriesLimitExceededString;
5975

6076
extern NSString *const HTTPMethodGet;
6177
extern NSString *const HTTPMethodPut;

MSGraphClientSDK/MSGraphClientSDK/Common/MSConstants.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,27 @@
44

55
#import "MSConstants.h"
66

7-
NSString *const MSGraphBaseURL = @"https://graph.microsoft.com/v1.0";
7+
NSString *const MSGraphBaseURL = @"https://graph.microsoft.com/v1.0";
8+
NSString *const MSGraphChinaBaseURL = @"https://microsoftgraph.chinacloudapi.cn/v1.0";
9+
NSString *const MSGraphUSBaseURL = @"https://graph.microsoft.us/v1.0";
10+
NSString *const MSGraphGermanyBaseURL = @"https://graph.microsoft.de/v1.0";
11+
812
NSString *const MSHeaderSdkVersion = @"SdkVersion";
913
NSString *const MSGraphiOSSdkVersionHeaderPrefix = @"graph-objc-ios-";
1014
NSString *const MSGraphMacSdkVersionHeaderPrefix = @"graph-objc-mac-";
1115

1216

1317
NSString *const MSErrorDomain = @"com.microsoft.graph.errors";
14-
1518
NSString *const MSErrorTooManyRedirectsFormatString = @"More than %ld redirects encountered while sending the request.";
16-
1719
NSString *const MSErrorLocationHeaderNotFoundString = @"There is no location header in the redirect response.";
1820
NSString *const MSErrorOperationUnsuccessfulString = @"Operation was unsuccessful.";
21+
NSString *const MSErrorMaxRedirectsLimitExceededString = @"Limit for maximum redirects allowed is %ld.";
1922

20-
NSString *const MSErrorTooManyRetries = @"Too many retries";
2123

24+
NSString *const MSErrorTooManyRetries = @"Too many retries";
2225
NSString *const MSErrorTooManyRetriesFormatString = @"More than %ld retries encountered while sending the request.";
26+
NSString *const MSErrorDelayLimitExceededString = @"Limit for maximum delay allowed is %ld.";
27+
NSString *const MSErrorMaxRetriesLimitExceededString = @"Limit for maximum retries allowed is %ld";
2328

2429

2530
NSString *const HTTPMethodGet = @"GET";

MSGraphClientSDK/MSGraphClientSDK/Common/Session Tasks/MSURLSessionTask.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#import <Foundation/Foundation.h>
88
#import "MSHttpProvider.h"
9+
#import "MSMiddlewareOptions.h"
910

1011
/**
1112
The Upload Completion Handler to be called when an upload is completed.
@@ -35,6 +36,11 @@ typedef void (^HTTPRequestCompletionHandler)(id data, NSURLResponse * _Nullable
3536
*/
3637
@property (strong) MSHTTPClient *client;
3738

39+
/*
40+
This property can be used to set an array of custom middleware options specific for the execution of the Task.
41+
*/
42+
@property (nonatomic, strong) NSArray<MSMiddlewareOptions> *middlewareOptionsArray;
43+
3844
/**
3945
Creates an `MSURLSessionTask` with the given requests and client.
4046
@param request The request to use. Must not be nil.
@@ -53,4 +59,11 @@ typedef void (^HTTPRequestCompletionHandler)(id data, NSURLResponse * _Nullable
5359
*/
5460
- (void)cancel;
5561

62+
/*
63+
This method can be used by to get a specific middleware matching with the type provided in argument.
64+
@param middlewareOptionsType The type of middleware options that needs to be returned
65+
@return An instance of middleware options if a match is found otherwise it will be nil.
66+
*/
67+
- (id<MSMiddlewareOptions>)getMiddlewareOptionWithType:(MSMiddlewareOptionsType)middlewareOptionsType;
68+
5669
@end

MSGraphClientSDK/MSGraphClientSDK/Common/Session Tasks/MSURLSessionTask.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,23 @@ - (void)taskCompletedWithData:(id)data response:(NSURLResponse *)response andErr
8383
NSAssert(NO, @"Not Implemented, must implement in sub class");
8484
}
8585

86+
- (void)setMiddlewareOptionsArray:(NSArray<MSMiddlewareOptions> *)middlewareOptionsArray
87+
{
88+
_middlewareOptionsArray = [middlewareOptionsArray copy];
89+
}
90+
91+
- (id<MSMiddlewareOptions>)getMiddlewareOptionWithType:(MSMiddlewareOptionsType)middlewareOptionsType
92+
{
93+
id<MSMiddlewareOptions> middlewareOptionsToReturn;
94+
for(id<MSMiddlewareOptions> middlewareOptions in _middlewareOptionsArray)
95+
{
96+
if(middlewareOptionsType == middlewareOptions.middlewareOptionsType)
97+
{
98+
middlewareOptionsToReturn = middlewareOptions;
99+
break;
100+
}
101+
}
102+
return middlewareOptionsToReturn;
103+
}
104+
86105
@end

MSGraphClientSDK/MSGraphClientSDK/HTTPClient/MSClientFactory.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@
1212
Initializes and returns an instance of MSHTTPClient class with a default chain of middleware to handle the HTTP calls.
1313
1414
@param authenticationProvider Instance of the class which implements the methods of MSAuthenticationProvider
15-
@param baseUrl Base URL of all the network calls which will be made my this client.
15+
@return MSHTTPClient instance
1616
*/
1717

1818
+(MSHTTPClient *)createHTTPClientWithAuthenticationProvider:(id<MSAuthenticationProvider>)authenticationProvider;
1919

20+
/*
21+
Initializes and returns an instance of MSHTTPClient class with a default chain of middleware to handle the HTTP calls.
22+
23+
@param authenticationProvider Instance of the class which implements the methods of MSAuthenticationProvider
24+
@param sessionConfiguration Instance of NSURLSessionConfiguration which will be used to create the NSURLSession for this client Instance.
25+
@return MSHTTPClient instance
26+
*/
27+
+(MSHTTPClient *)createHTTPClientWithAuthenticationProvider:(id<MSAuthenticationProvider>)authenticationProvider andSessionConfiguration:(NSURLSessionConfiguration *)sessionConfiguration;
2028
/*
2129
Initializes and returns an instance of MSHTTPClient class with a custom chain of middleware to handle the HTTP calls.
2230
2331
@param middleware Instance of a class which will be the first node in the custom chain of middleware.
32+
@return MSHTTPClient instance
2433
*/
2534

2635
+(MSHTTPClient *)createHTTPClientWithMiddleware:(id<MSGraphMiddleware>)middleware;

MSGraphClientSDK/MSGraphClientSDK/HTTPClient/MSClientFactory.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,30 @@ +(MSHTTPClient *)createHTTPClientWithAuthenticationProvider:(id<MSAuthentication
3131
return [MSClientFactory createHTTPClientWithMiddleware:authenticationHandler];
3232
}
3333

34+
+(MSHTTPClient *)createHTTPClientWithAuthenticationProvider:(id<MSAuthenticationProvider>)authenticationProvider andSessionConfiguration:(NSURLSessionConfiguration *)sessionConfiguration
35+
{
36+
NSParameterAssert(authenticationProvider);
37+
NSParameterAssert(sessionConfiguration);
38+
39+
//Creating a default chain of middlewares starting from Authentication
40+
41+
//Initializing different default middlewares
42+
MSAuthenticationHandler *authenticationHandler = (MSAuthenticationHandler *)[MSMiddlewareFactory createMiddleware:MSMiddlewareTypeAuthentication];
43+
authenticationHandler.authProvider = authenticationProvider;
44+
MSRedirectHandler *redirectHandler = (MSRedirectHandler *)[MSMiddlewareFactory createMiddleware:MSMiddlewareTypeRedirect];
45+
MSRetryHandler *retryHandler = (MSRetryHandler *)[MSMiddlewareFactory createMiddleware:MSMiddlewareTypeRetry];
46+
47+
//Create session manager with custom session configuration
48+
MSURLSessionManager *sessionManager = [[MSURLSessionManager alloc] initWithSessionConfiguration:sessionConfiguration];
49+
50+
//Creating a default chain
51+
[authenticationHandler setNext:redirectHandler];
52+
[redirectHandler setNext:retryHandler];
53+
[retryHandler setNext:sessionManager];
54+
55+
return [MSClientFactory createHTTPClientWithMiddleware:authenticationHandler];
56+
}
57+
3458
+(MSHTTPClient *)createHTTPClientWithMiddleware:(id<MSGraphMiddleware>)middleware
3559
{
3660
NSParameterAssert(middleware);

MSGraphClientSDK/MSGraphClientSDK/HTTPClient/MSMiddlewareFactory.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ @implementation MSMiddlewareFactory
1616
{
1717
case MSMiddlewareTypeHTTP:
1818
{
19-
MSURLSessionManager *sessionManager = [[MSURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
19+
MSURLSessionManager *sessionManager = [[MSURLSessionManager alloc] init];
2020
return sessionManager;
2121
}
2222
case MSMiddlewareTypeRedirect:

0 commit comments

Comments
 (0)