Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adds masquerading support in the client. #57

Merged
merged 3 commits into from

2 participants

@derrh
Owner

No description provided.

@elgreco84 elgreco84 merged commit d2e1d2b into instructure:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 25, 2014
  1. @derrh

    Small fixes for modules

    derrh authored
Commits on Mar 6, 2014
  1. @derrh

    Adds support for masquerading

    derrh authored
  2. @derrh

    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.
View
4 CanvasKit/Models/CKIModuleItem.h
@@ -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
View
7 CanvasKit/Models/CKIModuleItem.m
@@ -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
View
5 CanvasKit/Networking/CKIClient.h
@@ -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
View
7 CanvasKit/Networking/CKIClient.m
@@ -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.