Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adds masquerading support in the client. #57

Merged
merged 3 commits into from

2 participants

Derrick Hathaway Rick
Derrick Hathaway
Owner

No description provided.

Rick elgreco84 merged commit d2e1d2b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 25, 2014
  1. Derrick Hathaway

    Small fixes for modules

    derrh authored
Commits on Mar 6, 2014
  1. Derrick Hathaway

    Adds support for masquerading

    derrh authored
  2. Derrick Hathaway

    Merge remote-tracking branch 'instructure/CanvasKit/master'

    derrh authored
    Conflicts:
    	CanvasKit/Networking/CKIClient.m
This page is out of date. Refresh to see the latest.
4 CanvasKit/Models/CKIModuleItem.h
View
@@ -8,6 +8,8 @@
#import "CKIModel.h"
+@class CKIModule;
+
/**
The module item is a file.
@@ -155,4 +157,6 @@ extern NSString * const CKIModuleItemCompletionRequirementMinimumScore;
*/
@property (nonatomic) BOOL completed;
+
+@property (nonatomic) CKIModule *context;
@end
7 CanvasKit/Models/CKIModuleItem.m
View
@@ -7,13 +7,14 @@
//
#import "CKIModuleItem.h"
+#import "CKIModule.h"
#import "NSValueTransformer+CKIPredefinedTransformerAdditions.h"
#import "NSDictionary+DictionaryByAddingObjectsFromDictionary.h"
NSString * const CKIModuleItemTypeFile = @"File";
NSString * const CKIModuleItemTypePage = @"Page";
-NSString * const CKIModuleItemTypeDiscussion = @"Dicussion";
+NSString * const CKIModuleItemTypeDiscussion = @"Discussion";
NSString * const CKIModuleItemTypeAssignment = @"Assignment";
NSString * const CKIModuleItemTypeQuiz = @"Quiz";
NSString * const CKIModuleItemTypeSubHeader = @"SubHeader";
@@ -75,4 +76,8 @@ - (NSString *)itemID
return self.contentID ?: self.pageID;
}
+- (NSString *)path
+{
+ return [[self.context.path stringByAppendingPathComponent:@"items"] stringByAppendingPathComponent:self.id];
+}
@end
5 CanvasKit/Networking/CKIClient.h
View
@@ -31,6 +31,11 @@
@property (nonatomic, readonly) CKIUser *currentUser;
/**
+ The ID of the user that the current user should masquerade as
+ */
+@property (nonatomic) NSString *actAsUserID;
+
+/**
Instantiates a canvas client with the given information.
@param baseURL the base URL to be used by the client
7 CanvasKit/Networking/CKIClient.m
View
@@ -219,8 +219,11 @@ - (RACSignal *)fetchResponseAtPath:(NSString *)path parameters:(NSDictionary *)p
NSDictionary *newParameters = [@{@"per_page": @50} dictionaryByAddingObjectsFromDictionary:parameters];
return [[[RACSignal createSignal:^RACDisposable *(id <RACSubscriber> subscriber) {
- NSLog(@"Request for path: %@", path);
- NSURLSessionDataTask *task = [self GET:path parameters:newParameters success:^(NSURLSessionDataTask *task, id responseObject) {
+ NSDictionary *finalParameters = newParameters;
+ if ([self.actAsUserID length]) {
+ finalParameters = [@{@"as_user_id": self.actAsUserID} dictionaryByAddingObjectsFromDictionary:finalParameters];
+ }
+ NSURLSessionDataTask *task = [self GET:path parameters:finalParameters success:^(NSURLSessionDataTask *task, id responseObject) {
NSHTTPURLResponse *response = (NSHTTPURLResponse *) task.response;
NSURL *currentPage = response.currentPage;
NSURL *nextPage = response.nextPage;
Something went wrong with that request. Please try again.