Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Note which requests require authentication

  • Loading branch information...
commit 6fe2696d476deb02ab0ca72099e537da61ce0a81 1 parent 0ad63e7
Brent Royal-Gordon authored
View
6 ANAuthenticatedRequest.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
View
13 ANAuthenticatedRequest.m
@@ -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
4 ANPostRequest.m
@@ -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];
View
4 ANPostsInGlobalStreamRequest.m
@@ -14,4 +14,8 @@ - (NSURL *)URL {
return [NSURL URLWithString:@"posts/stream/global" relativeToURL:[self.session URLForStreamAPIVersion:ANStreamAPIVersion0]];
}
+- (BOOL)requiresAccessToken {
+ return NO;
+}
+
@end
View
4 ANPostsWithTagRequest.m
@@ -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
8 ANResource.h
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.