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

Commit 1ea88de

Browse files
author
Vikas Dadheech
committed
Add base model files and a placeholder podspec
1 parent 4e964e4 commit 1ea88de

File tree

12 files changed

+614
-16
lines changed

12 files changed

+614
-16
lines changed

MSGraphCoreSDK.podspec

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
Pod::Spec.new do |s|
3+
4+
5+
s.name = "MSGraphCoreSDK"
6+
s.version = "0.1.1"
7+
s.summary = "Microsoft Graph ObjC SDK."
8+
9+
s.description = <<-DESC
10+
Integrate the Microsoft Graph API into your iOS App!
11+
DESC
12+
13+
s.homepage = "http://graph.microsoft.io"
14+
s.license = { :type => "MIT", :file => "LICENSE" }
15+
s.author = 'Microsoft Graph'
16+
17+
18+
s.ios.deployment_target = "9.0"
19+
#s.osx.deployment_target = "10.7"
20+
21+
s.source = { :git => "https://github.com/microsoftgraph/msgraph-sdk-objc.git", :tag => "#{s.version}" }
22+
23+
24+
25+
s.source_files = "MSGraphCoreSDK/MSGraphCoreSDK/MSGraphCoreSDK.h"
26+
s.exclude_files = "MSGraphCoreSDK/MSGraphCoreSDKTests/*"
27+
s.public_header_files = "MSGraphCoreSDK/MSGraphCoreSDK/MSGraphCoreSDK.h"
28+
29+
#s.subspec "Models" do |models|
30+
# models.source_files = "MSGraphCoreSDK/MSGraphCoreSDK/Models/*.{h,m}"
31+
#models.public_header_files = "MSGraphCoreSDK/MSGraphCoreSDK/Models/*.h"
32+
# end
33+
34+
s.subspec "Authentication" do |authentication|
35+
authentication.source_files = "MSGraphCoreSDK/MSGraphCoreSDK/Authentication/*.{h,m}"
36+
authentication.public_header_files = "MSGraphCoreSDK/MSGraphCoreSDK/Authentication/*.h"
37+
end
38+
39+
40+
41+
s.subspec "Common" do |common|
42+
common.source_files = "MSGraphCoreSDK/MSGraphCoreSDK/Common/**/*.{h,m}, MSGraphCoreSDK/MSGraphCoreSDK/Middleware/**/*.{h,m}"
43+
common.public_header_files = "MSGraphCoreSDK/MSGraphCoreSDK/Common/**/*.h, MSGraphCoreSDK/MSGraphCoreSDK/Middleware/**/*.h"
44+
end
45+
46+
#s.subspec "Middleware" do |middleware|
47+
# middleware.source_files = "MSGraphCoreSDK/MSGraphCoreSDK/Middleware/**/*.{h,m}"
48+
# middleware.public_header_files = "MSGraphCoreSDK/MSGraphCoreSDK/Middleware/**/*.h"
49+
#end
50+
51+
s.subspec "GraphContent" do |graphContent|
52+
graphContent.source_files = "MSGraphCoreSDK/MSGraphCoreSDK/GraphContent/**/*.{h,m}"
53+
graphContent.public_header_files = "MSGraphCoreSDK/MSGraphCoreSDK/GraphContent/**/*.h"
54+
end
55+
56+
s.subspec "HTTPClient" do |httpClient|
57+
httpClient.source_files = "MSGraphCoreSDK/MSGraphCoreSDK/HTTPClient/**/*.{h,m}"
58+
httpClient.public_header_files = "MSGraphCoreSDK/MSGraphCoreSDK/HTTPClient/**/*.h"
59+
end
60+
61+
62+
63+
# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
64+
#
65+
# A list of resources included with the Pod. These are copied into the
66+
# target bundle with a build phase script. Anything else will be cleaned.
67+
# You can preserve files from being cleaned, please don't preserve
68+
# non-essential files like tests, examples and documentation.
69+
#
70+
71+
# s.resource = "icon.png"
72+
# s.resources = "Resources/*.png"
73+
74+
# s.preserve_paths = "FilesToSave", "MoreFilesToSave"
75+
76+
77+
# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
78+
#
79+
# Link your library with frameworks, or libraries. Libraries do not include
80+
# the lib prefix of their name.
81+
#
82+
83+
# s.framework = "SomeFramework"
84+
# s.frameworks = "SomeFramework", "AnotherFramework"
85+
86+
# s.library = "iconv"
87+
# s.libraries = "iconv", "xml2"
88+
89+
90+
# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
91+
#
92+
# If your library depends on compiler flags you can set them in the xcconfig hash
93+
# where they will only apply to your library. If you depend on other Podspecs
94+
# you can include multiple dependencies to ensure it works.
95+
96+
# s.requires_arc = true
97+
98+
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
99+
# s.dependency "JSONKit", "~> 1.4"
100+
101+
end

MSGraphCoreSDK/MSGraphCoreSDK.xcodeproj/project.pbxproj

Lines changed: 64 additions & 16 deletions
Large diffs are not rendered by default.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
2+
3+
#import "MSObject.h"
4+
5+
/**
6+
An `MSCollection` object is a collection of Graph objects.
7+
@see MSObject
8+
*/
9+
@interface MSCollection : MSObject
10+
11+
/**
12+
An array of Graph objects.
13+
*/
14+
@property (strong, nonatomic) NSArray *value;
15+
16+
/**
17+
There may be more items in the collection available via paging. This is the url to the next page of the collection.
18+
*/
19+
@property (strong, nonatomic) NSURL *nextLink;
20+
21+
/**
22+
Any additional data returned from the collection request will be in this dictionary.
23+
*/
24+
@property (strong, nonatomic) NSDictionary *additionalData;
25+
26+
/**
27+
Creates an MSCollection with the response from the service.
28+
@param array The array of OneDrive objects.
29+
@param nextLink The link to the next page of items, if there is one.
30+
@param additionalData Any other data returned from the service.
31+
*/
32+
- (instancetype)initWithArray:(NSArray *)array
33+
nextLink:(NSString *)nextLink
34+
additionalData:(NSDictionary *)additionalData;
35+
//
36+
///**
37+
// Return an array with all values compatible with NSJsonSerialization
38+
//*/
39+
//- (NSArray *) arrayFromItem;
40+
41+
@end
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
2+
3+
#import "MSCollection.h"
4+
#import "NSDate+MSSerialization.h"
5+
6+
@implementation MSCollection
7+
8+
-(instancetype)initWithArray:(NSArray *)array
9+
nextLink:(NSString *)nextLink
10+
additionalData:(NSDictionary *)additionalData
11+
{
12+
self = [super init];
13+
if (self){
14+
_value = array;
15+
_nextLink = [NSURL URLWithString:nextLink];
16+
_additionalData = additionalData;
17+
}
18+
return self;
19+
}
20+
21+
- (instancetype)initWithData:(NSData *)data
22+
{
23+
self = [super initWithData:data];
24+
if(self){
25+
self.value = [[self dictionaryFromItem] objectForKey:@"value"];
26+
self.nextLink = [[self dictionaryFromItem] objectForKey:@"@odata.nextLink"];
27+
}
28+
return self;
29+
}
30+
31+
- (instancetype)initWithDictionary:(NSDictionary *)dictionary
32+
{
33+
self = [super initWithDictionary:dictionary];
34+
if(self)
35+
{
36+
self.value = [dictionary objectForKey:@"values"];
37+
self.nextLink = [dictionary objectForKey:@"@odata.nextLink"];
38+
}
39+
return self;
40+
}
41+
42+
//- (NSArray *) arrayFromItem
43+
//{
44+
// NSMutableArray *retArray = [NSMutableArray arrayWithCapacity:[self.value count]];
45+
// [self.value enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
46+
// retArray[idx] = [MSObject getNSJsonSerializationCompatibleValue:obj];
47+
// }];
48+
// return retArray;
49+
//}
50+
51+
@end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
2+
3+
#import <Foundation/Foundation.h>
4+
5+
@interface MSDate : NSObject
6+
7+
+ (instancetype) date;
8+
+ (instancetype) dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day;
9+
10+
- (id) initWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day;
11+
- (id) initWithNSDate:(NSDate*)date;
12+
13+
@property (nonatomic, readonly) NSInteger year;
14+
@property (nonatomic, readonly) NSInteger month;
15+
@property (nonatomic, readonly) NSInteger day;
16+
17+
- (NSString *)ms_toString;
18+
+ (instancetype)ms_dateFromString:(NSString *)dateString;
19+
20+
@end
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
2+
3+
#import "MSDate.h"
4+
5+
static NSString *dateFormat = @"yyyy-MM-dd";
6+
7+
@interface MSDate ()
8+
9+
@property (nonatomic, strong) NSDate *date;
10+
11+
@end
12+
13+
@implementation MSDate
14+
15+
#pragma mark - Initializers
16+
17+
+ (instancetype) date {
18+
return [[MSDate alloc] initWithNSDate:[NSDate date]];
19+
}
20+
21+
+ (instancetype) dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day {
22+
return [[MSDate alloc] initWithYear:year month:month day:day];
23+
}
24+
25+
- (id) initWithNSDate:(NSDate*)date {
26+
if (self = [super init]) {
27+
self.date = date;
28+
}
29+
return self;
30+
}
31+
32+
- (id) initWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day {
33+
if (self = [super init]) {
34+
NSDateComponents *components = [[NSDateComponents alloc] init];
35+
components.year = year;
36+
components.month = month;
37+
components.day = day;
38+
components.calendar = [NSCalendar currentCalendar];
39+
self.date = [components date];
40+
}
41+
return self;
42+
}
43+
44+
45+
#pragma mark - Properties
46+
47+
- (NSInteger) year {
48+
NSDateComponents *components = [[MSDate gregorianCalendar] components:NSCalendarUnitYear fromDate:self.date];
49+
return components.year;
50+
}
51+
52+
- (NSInteger) month {
53+
NSDateComponents *components = [[MSDate gregorianCalendar] components:NSCalendarUnitMonth fromDate:self.date];
54+
return components.month;
55+
}
56+
57+
- (NSInteger) day {
58+
NSDateComponents *components = [[MSDate gregorianCalendar] components:NSCalendarUnitDay fromDate:self.date];
59+
return components.day;
60+
}
61+
62+
63+
#pragma mark - Serialization
64+
65+
- (NSString *)ms_toString
66+
{
67+
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
68+
[dateFormatter setDateFormat:dateFormat];
69+
NSLocale *posix = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
70+
[dateFormatter setLocale:posix];
71+
return [dateFormatter stringFromDate:self.date];
72+
}
73+
74+
+ (instancetype)ms_dateFromString:(NSString *)dateString
75+
{
76+
NSDate *date = nil;
77+
if (dateString){
78+
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
79+
[dateFormatter setDateFormat:dateFormat];
80+
NSLocale *posix = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
81+
[dateFormatter setLocale:posix];
82+
date = [dateFormatter dateFromString:dateString];
83+
}
84+
return [[MSDate alloc] initWithNSDate:date];
85+
}
86+
87+
#pragma mark - Helpers
88+
89+
+ (NSCalendar*) gregorianCalendar {
90+
static NSCalendar *calendar;
91+
static dispatch_once_t onceToken;
92+
dispatch_once(&onceToken, ^{
93+
calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
94+
});
95+
return calendar;
96+
}
97+
98+
@end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// MSObject.h
3+
// MSGraphPOCSDK
4+
//
5+
// Created by Vikas Dadheech on 26/07/18.
6+
// Copyright © 2018 Vikas Dadheech. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface MSObject : NSObject
12+
13+
/**
14+
Creates an MSObject with the given dictionary.
15+
@param dictionary The dictionary representation of the object.
16+
@warning This method will return nil if the dictionary is nil.
17+
*/
18+
- (instancetype)initWithDictionary:(NSDictionary*)dictionary;
19+
20+
-(instancetype)initWithData:(NSData *)data;
21+
22+
/**
23+
Creates a dictionary from the given item.
24+
@return dictionary Representation for the given item.
25+
*/
26+
- (NSDictionary*)dictionaryFromItem;
27+
28+
- (NSData *)serializedData;
29+
30+
31+
@end
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// MSObject.m
3+
// MSGraphPOCSDK
4+
//
5+
// Created by Vikas Dadheech on 26/07/18.
6+
// Copyright © 2018 Vikas Dadheech. All rights reserved.
7+
//
8+
9+
#import "MSObject.h"
10+
11+
@interface MSObject()
12+
13+
@property NSMutableDictionary *dictionary;
14+
15+
@end
16+
17+
@implementation MSObject
18+
19+
20+
- (instancetype)init {
21+
return [self initWithDictionary:[NSMutableDictionary new]];
22+
}
23+
24+
-(instancetype)initWithData:(NSData *)data{
25+
self = [super init];
26+
if(self){
27+
self.dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
28+
}
29+
return self;
30+
}
31+
32+
-(instancetype)initWithDictionary:(NSDictionary *)dictionary{
33+
self = [super init];
34+
if(self){
35+
self.dictionary = [NSMutableDictionary dictionaryWithDictionary:dictionary];
36+
}
37+
return self;
38+
}
39+
40+
-(NSMutableDictionary *)dictionaryFromItem{
41+
return [self.dictionary mutableCopy];
42+
}
43+
44+
- (NSData *)serializedData{
45+
return [NSJSONSerialization dataWithJSONObject:self.dictionary options:kNilOptions error:nil];
46+
}
47+
@end

0 commit comments

Comments
 (0)