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

Commit 58b0665

Browse files
authored
Merge pull request #1 from microsoftgraph/vidadhee/HttpClient
Core SDK Implementation
2 parents e2bb2ae + 108d5f1 commit 58b0665

File tree

61 files changed

+4831
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4831
-0
lines changed

MSGraphCoreSDK/MSGraphCoreSDK.xcodeproj/project.pbxproj

Lines changed: 785 additions & 0 deletions
Large diffs are not rendered by default.

MSGraphCoreSDK/MSGraphCoreSDK.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0930"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "E5DC73D9211412BF0040BAB6"
18+
BuildableName = "MSGraphCoreSDK.framework"
19+
BlueprintName = "MSGraphCoreSDK"
20+
ReferencedContainer = "container:MSGraphCoreSDK.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
codeCoverageEnabled = "YES"
30+
shouldUseLaunchSchemeArgsEnv = "YES">
31+
<Testables>
32+
<TestableReference
33+
skipped = "NO">
34+
<BuildableReference
35+
BuildableIdentifier = "primary"
36+
BlueprintIdentifier = "E5069AD5211C1AD500432372"
37+
BuildableName = "MSGraphCoreSDKTests.xctest"
38+
BlueprintName = "MSGraphCoreSDKTests"
39+
ReferencedContainer = "container:MSGraphCoreSDK.xcodeproj">
40+
</BuildableReference>
41+
</TestableReference>
42+
</Testables>
43+
<MacroExpansion>
44+
<BuildableReference
45+
BuildableIdentifier = "primary"
46+
BlueprintIdentifier = "E5DC73D9211412BF0040BAB6"
47+
BuildableName = "MSGraphCoreSDK.framework"
48+
BlueprintName = "MSGraphCoreSDK"
49+
ReferencedContainer = "container:MSGraphCoreSDK.xcodeproj">
50+
</BuildableReference>
51+
</MacroExpansion>
52+
<AdditionalOptions>
53+
</AdditionalOptions>
54+
</TestAction>
55+
<LaunchAction
56+
buildConfiguration = "Debug"
57+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
58+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59+
launchStyle = "0"
60+
useCustomWorkingDirectory = "NO"
61+
ignoresPersistentStateOnLaunch = "NO"
62+
debugDocumentVersioning = "YES"
63+
debugServiceExtension = "internal"
64+
allowLocationSimulation = "YES">
65+
<MacroExpansion>
66+
<BuildableReference
67+
BuildableIdentifier = "primary"
68+
BlueprintIdentifier = "E5DC73D9211412BF0040BAB6"
69+
BuildableName = "MSGraphCoreSDK.framework"
70+
BlueprintName = "MSGraphCoreSDK"
71+
ReferencedContainer = "container:MSGraphCoreSDK.xcodeproj">
72+
</BuildableReference>
73+
</MacroExpansion>
74+
<AdditionalOptions>
75+
</AdditionalOptions>
76+
</LaunchAction>
77+
<ProfileAction
78+
buildConfiguration = "Release"
79+
shouldUseLaunchSchemeArgsEnv = "YES"
80+
savedToolIdentifier = ""
81+
useCustomWorkingDirectory = "NO"
82+
debugDocumentVersioning = "YES">
83+
<MacroExpansion>
84+
<BuildableReference
85+
BuildableIdentifier = "primary"
86+
BlueprintIdentifier = "E5DC73D9211412BF0040BAB6"
87+
BuildableName = "MSGraphCoreSDK.framework"
88+
BlueprintName = "MSGraphCoreSDK"
89+
ReferencedContainer = "container:MSGraphCoreSDK.xcodeproj">
90+
</BuildableReference>
91+
</MacroExpansion>
92+
</ProfileAction>
93+
<AnalyzeAction
94+
buildConfiguration = "Debug">
95+
</AnalyzeAction>
96+
<ArchiveAction
97+
buildConfiguration = "Release"
98+
revealArchiveInOrganizer = "YES">
99+
</ArchiveAction>
100+
</Scheme>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
#import <UIKit/UIKit.h>
7+
8+
typedef void(^MSAuthenticationCompletion)(NSMutableURLRequest *request, NSError *error);
9+
10+
/**
11+
The `MSAuthenticationProvider` is a protocol that is used to inject authentication into the MSHTTPClient.
12+
It should handle all initial authentication, refreshing, and returning the access token.
13+
*/
14+
@protocol MSAuthenticationProvider <NSObject>
15+
16+
/**
17+
Gets the access token. This method should be implemented by a class which should provide the capability of providing the access token.
18+
@param completion The completion handler to be called when access token or an error can be returned.
19+
*/
20+
21+
- (void) getAccessTokenWithCompletion:(void (^)(NSString *accessToken, NSError *error))completion;
22+
23+
@end
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 MSConstants_h
8+
#define MSConstants_h
9+
10+
typedef NS_ENUM(NSInteger, MSClientErrorCode)
11+
{
12+
MSClientErrorCodeBadRequest = 400,
13+
MSClientErrorCodeUnauthorized = 401,
14+
MSClientErrorCodeForbidden = 403,
15+
MSClientErrorCodeNotFound = 404,
16+
MSClientErrorCodeMethodNotAllowed = 405,
17+
MSClientErrorCodeUNACCEPTABLE = 406,
18+
MSClientErrorCodeConflict = 409,
19+
MSClientErrorCodeLengthRequired = 411,
20+
MSClientErrorCodePreconditionFailed = 412,
21+
MSClientErrorCodeRequestEntityTooLarge = 413,
22+
MSClientErrorCodeUnsupportedMediaType = 415,
23+
MSClientErrorCodeRequestRangeNotSatisfiable = 416,
24+
MSClientErrorCodeUnprocessableEntity = 422,
25+
MSClientErrorCodeTooManyRequests = 429,
26+
MSClientErrorCodeInternalServerError = 500,
27+
MSClientErrorCodeNotImplemented = 501,
28+
MSClientErrorCodeServiceUnavailable = 503,
29+
MSClientErrorCodeInsufficientStorage = 507,
30+
MSClientErrorCodeUnknownError = 999,
31+
};
32+
33+
typedef NS_ENUM(NSInteger, MSExpectedResponseCodes)
34+
{
35+
MSExpectedResponseCodesOK = 200,
36+
MSExpectedResponseCodesCreated = 201,
37+
MSExpectedResponseCodesAccepted = 202,
38+
MSExpectedResponseCodesMovedPermanantly = 301,
39+
MSExpectedResponseCodesFound = 302,
40+
MSExpectedResponseCodesSeeOther = 303,
41+
MSExpectedResponseCodesNotModified = 304,
42+
MSExpectedResponseCodesTemporaryRedirect = 307,
43+
};
44+
45+
extern NSString *const MSGraphBaseURL;
46+
extern NSString *const MSHeaderSdkVersion;
47+
extern NSString *const MSGraphSdkVersionHeaderPrefix;
48+
49+
extern NSString *const MSErrorDomain;
50+
51+
extern NSString *const MSErrorTooManyRedirectsFormatString;
52+
extern NSString *const MSErrorLocationHeaderNotFoundString;
53+
extern NSString *const MSErrorOperationUnsuccessfulString;
54+
#endif
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 "MSConstants.h"
6+
7+
NSString *const MSGraphBaseURL = @"https://graph.microsoft.com/v1.0";
8+
NSString *const MSHeaderSdkVersion = @"SdkVersion";
9+
NSString *const MSGraphSdkVersionHeaderPrefix = @"graph-ios-";
10+
11+
NSString *const MSErrorDomain = @"com.microsoft.graph.errors";
12+
13+
NSString *const MSErrorTooManyRedirectsFormatString = @"More than %d redirects encountered while sending the request.";
14+
15+
NSString *const MSErrorLocationHeaderNotFoundString = @"There is no location header in the redirect response.";
16+
NSString *const MSErrorOperationUnsuccessfulString = @"Operation was unsuccessful.";
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 "MSURLSessionTask.h"
6+
7+
/**
8+
An MSURLSessionTask to be used for retrieving data.
9+
@see MSURLSessionTask
10+
*/
11+
@interface MSURLSessionDataTask : MSURLSessionTask
12+
13+
/**
14+
Creates a Data task with the given request and client.
15+
@param request The mutableURL request. Must not be nil.
16+
@param client The client that will send the request. Must not be nil.
17+
@param completionHandler The completion handler to call when the task has completed.
18+
*/
19+
- (instancetype)initWithRequest:(NSMutableURLRequest *)request
20+
client:(MSHTTPClient *)client
21+
completion:(MSDataCompletionHandler)completionHandler;
22+
23+
@end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 "MSURLSessionDataTask.h"
6+
#import "MSHTTPClient.h"
7+
8+
@interface MSURLSessionDataTask()
9+
10+
@property (nonatomic, copy) MSDataCompletionHandler completionHandler;
11+
12+
@end
13+
14+
@implementation MSURLSessionDataTask
15+
16+
- (instancetype)initWithRequest:(NSMutableURLRequest *)request
17+
client:(MSHTTPClient *)client
18+
completion:(void (^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler
19+
{
20+
self = [super initWithRequest:request client:client];
21+
if (self)
22+
{
23+
_completionHandler = completionHandler;
24+
}
25+
return self;
26+
}
27+
28+
- (void)taskCompletedWithData:(id)data response:(NSURLResponse *)response andError:(NSError *)error
29+
{
30+
if(_completionHandler)
31+
{
32+
_completionHandler(data, response, error);
33+
}
34+
}
35+
36+
@end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 "MSURLSessionTask.h"
6+
7+
/**
8+
An MSURLSessionTask to be used for downloading content.
9+
@see MSURLSessionTask
10+
*/
11+
@interface MSURLSessionDownloadTask : MSURLSessionTask
12+
13+
/**
14+
The NSProgress to monitor.
15+
*/
16+
17+
@property (strong, readonly) NSProgress *progress;
18+
19+
/**
20+
Creates a Download task with the given request and client.
21+
@param request The mutableURL request. Must not be nil.
22+
@param client The client that will send the request. Must not be nil.
23+
@param completionHandler The completion handler to call when the task has completed.
24+
*/
25+
- (instancetype)initWithRequest:(NSMutableURLRequest *)request
26+
client:(MSHTTPClient *)client
27+
completionHandler:(MSDownloadCompletionHandler)completionHandler;
28+
29+
@end

0 commit comments

Comments
 (0)