Permalink
Browse files

Note which requests require authentication

  • Loading branch information...
1 parent 0ad63e7 commit 6fe2696d476deb02ab0ca72099e537da61ce0a81 Brent Royal-Gordon committed Oct 25, 2012
Showing with 31 additions and 8 deletions.
  1. +5 −1 ANAuthenticatedRequest.h
  2. +10 −3 ANAuthenticatedRequest.m
  3. +4 −0 ANPostRequest.m
  4. +4 −0 ANPostsInGlobalStreamRequest.m
  5. +4 −0 ANPostsWithTagRequest.m
  6. +4 −4 ANResource.h
@@ -10,7 +10,11 @@
#import "ANRequest.h"
-@interface ANAuthenticatedRequest : ANRequest <NSMutableCopying> @end
+@interface ANAuthenticatedRequest : ANRequest <NSMutableCopying>
+
+@property (readonly,assign) BOOL requiresAccessToken;
+
+@end
@interface ANMutableAuthenticatedRequest : ANRequest
@@ -21,12 +21,19 @@ - (id)mutableCopyWithZone:(NSZone *)zone {
return req;
}
+- (BOOL)requiresAccessToken {
+ return YES;
+}
+
- (NSMutableURLRequest *)URLRequest {
- NSAssert(self.session.accessToken, @"Session's access token has not been set");
-
NSMutableURLRequest * req = super.URLRequest;
- [req setValue:[NSString stringWithFormat:@"Bearer %@", self.session.accessToken] forHTTPHeaderField:@"Authorization"];
+ if(self.session.accessToken) {
+ [req setValue:[NSString stringWithFormat:@"Bearer %@", self.session.accessToken] forHTTPHeaderField:@"Authorization"];
+ }
+ else {
+ NSAssert(!self.requiresAccessToken, @"Session's access token has not been set");
+ }
return req;
}
View
@@ -22,6 +22,10 @@ - (ANRequestMethod)method {
return ANRequestMethodGet;
}
+- (BOOL)requiresAccessToken {
+ return NO;
+}
+
- (void)sendRequestWithCompletion:(ANPostRequestCompletion)completion {
[self sendRequestWithRepresentationCompletion:^(ANResponse * response, id rep, NSError *error) {
[self.session completePostRequest:completion withResponse:response representation:rep error:error];
@@ -14,4 +14,8 @@ - (NSURL *)URL {
return [NSURL URLWithString:@"posts/stream/global" relativeToURL:[self.session URLForStreamAPIVersion:ANStreamAPIVersion0]];
}
+- (BOOL)requiresAccessToken {
+ return NO;
+}
+
@end
@@ -14,4 +14,8 @@ - (NSURL *)URL {
return [NSURL URLWithString:[NSString stringWithFormat:@"posts/tag/%@", self.tag] relativeToURL:[self.session URLForStreamAPIVersion:ANStreamAPIVersion0]];
}
+- (BOOL)requiresAccessToken {
+ return NO;
+}
+
@end
View
@@ -17,10 +17,10 @@ extern NSString * const ANResourceDidUpdateNotification;
@protocol ANTextualResource <NSObject>
-@property (readonly) NSString * text;
-@property (readonly) NSString * HTML;
-@property (readonly) ANEntitySet * entities;
-@property (readonly) NSDictionary * entitiesRepresentation;
+@property (nonatomic,readonly) NSString * text;
+@property (nonatomic,readonly) NSString * HTML;
+@property (nonatomic,readonly) ANEntitySet * entities;
+@property (nonatomic,readonly) NSDictionary * entitiesRepresentation;
@end

0 comments on commit 6fe2696

Please sign in to comment.