24
24
#import " OCConnection+GraphAPI.h"
25
25
#import " OCMacros.h"
26
26
#import " NSError+OCError.h"
27
+ #import " NSURL+OCURLQueryParameterExtensions.h"
27
28
28
29
@implementation OCConnection (Drives)
29
30
30
31
#pragma mark - Creation
31
- - (nullable NSProgress *)createDriveWithName : (NSString *)name description : (nullable NSString *)description quota : (nullable NSNumber *)quotaBytes completionHandler : (OCConnectionDriveCompletionHandler)completionHandler
32
+ - (nullable NSProgress *)createDriveWithName : (NSString *)name description : (nullable NSString *)description quota : (nullable NSNumber *)quotaBytes template : (nullable OCDriveTemplate) templateName completionHandler : (OCConnectionDriveCompletionHandler)completionHandler
32
33
{
33
34
GADrive *drive = [GADrive new ];
34
35
drive.name = name;
@@ -41,8 +42,16 @@ - (nullable NSProgress *)createDriveWithName:(NSString *)name description:(nulla
41
42
drive.quota = quota;
42
43
}
43
44
44
- return ([self createODataObject: drive atURL: [self URLForEndpoint: OCConnectionEndpointIDGraphDrives options: nil ] requireSignals: [NSSet setWithObject: OCConnectionSignalIDAuthenticationAvailable] parameters: nil responseEntityClass: Nil completionHandler: ^(NSError * _Nullable error, id _Nullable response) {
45
- NSLog (@" New space: %@ " , response);
45
+ NSURL *creationURL = [self URLForEndpoint: OCConnectionEndpointIDGraphDrives options: nil ];
46
+ if (templateName != nil )
47
+ {
48
+ creationURL = [creationURL urlByAppendingQueryParameters: @{
49
+ @" template" : templateName
50
+ } replaceExisting: NO ];
51
+ }
52
+
53
+ return ([self createODataObject: drive atURL: creationURL requireSignals: [NSSet setWithObject: OCConnectionSignalIDAuthenticationAvailable] parameters: nil responseEntityClass: Nil completionHandler: ^(NSError * _Nullable error, id _Nullable response) {
54
+ OCLogDebug (@" New space: %@ " , response);
46
55
completionHandler (error, (response != nil ) ? [OCDrive driveFromGADrive: (GADrive *)response] : nil );
47
56
}]);
48
57
}
@@ -119,7 +128,7 @@ - (nullable NSProgress *)updateDrive:(OCDrive *)drive properties:(NSDictionary<O
119
128
}
120
129
121
130
return ([self updateODataObject: gaDriveUpdate atURL: [[self URLForEndpoint: OCConnectionEndpointIDGraphDrives options: nil ] URLByAppendingPathComponent: drive.identifier] requireSignals: [NSSet setWithObject: OCConnectionSignalIDAuthenticationAvailable] parameters: nil responseEntityClass: GADrive.class completionHandler: ^(NSError * _Nullable error, id _Nullable response) {
122
- NSLog (@" Updated space: %@ " , response);
131
+ OCLogDebug (@" Updated space: %@ " , response);
123
132
completionHandler (error, (response != nil ) ? [OCDrive driveFromGADrive: (GADrive *)response] : nil );
124
133
}]);
125
134
}
0 commit comments