Permalink
Browse files

Merge branch 'refs/heads/filters'

Conflicts:
	ANSession+Requests.m
  • Loading branch information...
2 parents c3950e8 + bb09576 commit 46d481f1a4d915c69be5e52767d29b86c22b897a Brent Royal-Gordon committed Oct 28, 2012
View
@@ -10,10 +10,13 @@
@class ANUser;
@class ANPost;
+@class ANFilter;
@class ANResponse;
typedef void (^ANAccessTokenInformationRequestCompletion)(ANResponse * response, NSArray * scopes, ANUser * user, NSError * error);
typedef void (^ANUserRequestCompletion)(ANResponse * response, ANUser * user, NSError * error);
typedef void (^ANUserListRequestCompletion)(ANResponse * response, NSArray * users, NSError * error);
typedef void (^ANPostRequestCompletion)(ANResponse * response, ANPost * post, NSError * error);
typedef void (^ANPostListRequestCompletion)(ANResponse * response, NSArray * posts, NSError * error);
+typedef void (^ANFilterRequestCompletion)(ANResponse * response, ANFilter * filter, NSError * error);
+typedef void (^ANFilterListRequestCompletion)(ANResponse * response, NSArray * filters, NSError * error);
View
@@ -0,0 +1,17 @@
+//
+// ANCreateFilterRequest.h
+// Alef
+//
+// Created by Brent Royal-Gordon on 10/21/12.
+// Copyright (c) 2012 Architechies. All rights reserved.
+//
+
+#import "ANAuthenticatedRequest.h"
+
+@interface ANCreateFilterRequest : ANAuthenticatedRequest
+
+@property (nonatomic,strong) ANDraftFilter * draftFilter;
+
+- (void)sendRequestWithCompletion:(ANFilterRequestCompletion)completion;
+
+@end
View
@@ -0,0 +1,31 @@
+//
+// ANCreateFilterRequest.m
+// Alef
+//
+// Created by Brent Royal-Gordon on 10/21/12.
+// Copyright (c) 2012 Architechies. All rights reserved.
+//
+
+#import "ANCreateFilterRequest.h"
+
+@implementation ANCreateFilterRequest
+
+- (NSURL *)URL {
+ return [NSURL URLWithString:@"filters" relativeToURL:[self.session URLForStreamAPIVersion:ANStreamAPIVersion0]];
+}
+
+- (NSDictionary *)parameters {
+ return self.draftFilter.representation;
+}
+
+- (ANRequestMethod)method {
+ return ANRequestMethodPost;
+}
+
+- (void)sendRequestWithCompletion:(ANFilterRequestCompletion)completion {
+ [self sendRequestWithRepresentationCompletion:^(ANResponse *response, id rep, NSError *error) {
+ [self.session completeFilterRequest:completion withResponse:response representation:rep error:error];
+ }];
+}
+
+@end
View
@@ -0,0 +1,17 @@
+//
+// ANDeleteFilterRequest.h
+// Alef
+//
+// Created by Brent Royal-Gordon on 10/21/12.
+// Copyright (c) 2012 Architechies. All rights reserved.
+//
+
+#import "ANAuthenticatedRequest.h"
+
+@interface ANDeleteFilterRequest : ANAuthenticatedRequest
+
+@property (nonatomic,assign) ANResourceID filterID;
+
+- (void)sendRequestWithCompletion:(ANFilterRequestCompletion)completion;
+
+@end
View
@@ -0,0 +1,31 @@
+//
+// ANDeleteFilterRequest.m
+// Alef
+//
+// Created by Brent Royal-Gordon on 10/21/12.
+// Copyright (c) 2012 Architechies. All rights reserved.
+//
+
+#import "ANDeleteFilterRequest.h"
+
+@implementation ANDeleteFilterRequest
+
+- (NSURL *)URL {
+ return [NSURL URLWithString:[NSString stringWithFormat:@"filters/%lld", self.filterID] relativeToURL:[self.session URLForStreamAPIVersion:ANStreamAPIVersion0]];
+}
+
+- (NSDictionary *)parameters {
+ return nil;
+}
+
+- (ANRequestMethod)method {
+ return ANRequestMethodDelete;
+}
+
+- (void)sendRequestWithCompletion:(ANFilterRequestCompletion)completion {
+ [self sendRequestWithRepresentationCompletion:^(ANResponse *response, id rep, NSError *error) {
+ [self.session completeFilterRequest:completion withResponse:response representation:rep error:error];
+ }];
+}
+
+@end
@@ -0,0 +1,15 @@
+//
+// ANDeleteFiltersForUserRequest.h
+// Alef
+//
+// Created by Brent Royal-Gordon on 10/21/12.
+// Copyright (c) 2012 Architechies. All rights reserved.
+//
+
+#import "ANAuthenticatedRequest.h"
+
+@interface ANDeleteFiltersForUserRequest : ANAuthenticatedRequest
+
+- (void)sendRequestWithCompletion:(ANFilterListRequestCompletion)completion;
+
+@end
@@ -0,0 +1,31 @@
+//
+// ANDeleteFiltersForUserRequest.m
+// Alef
+//
+// Created by Brent Royal-Gordon on 10/21/12.
+// Copyright (c) 2012 Architechies. All rights reserved.
+//
+
+#import "ANDeleteFiltersForUserRequest.h"
+
+@implementation ANDeleteFiltersForUserRequest
+
+- (NSURL *)URL {
+ return [NSURL URLWithString:@"filters" relativeToURL:[self.session URLForStreamAPIVersion:ANStreamAPIVersion0]];
+}
+
+- (NSDictionary *)parameters {
+ return nil;
+}
+
+- (ANRequestMethod)method {
+ return ANRequestMethodDelete;
+}
+
+- (void)sendRequestWithCompletion:(ANFilterListRequestCompletion)completion {
+ [self sendRequestWithRepresentationCompletion:^(ANResponse *response, id rep, NSError *error) {
+ [self.session completeFilterListRequest:completion withResponse:response representation:rep error:error];
+ }];
+}
+
+@end
View
@@ -0,0 +1,100 @@
+//
+// ANFilter.h
+// Alef
+//
+// Created by Brent Royal-Gordon on 10/19/12.
+// Copyright (c) 2012 Architechies. All rights reserved.
+//
+
+#import "ANIdentifiedResource.h"
+#import "ANCompletions.h"
+
+@class ANDraftFilter;
+@class ANDraftFilterClause;
+
+typedef enum {
+ ANFilterMatchPolicyIncludeAny,
+ ANFilterMatchPolicyIncludeAll,
+ ANFilterMatchPolicyExcludeAny,
+ ANFilterMatchPolicyExcludeAll
+} ANFilterMatchPolicy;
+
+extern NSString * ANStringFromFilterMatchPolicy(ANFilterMatchPolicy matchPolicy);
+extern ANFilterMatchPolicy ANFilterMatchPolicyFromString(NSString * string);
+
+@interface ANFilter : ANIdentifiedResource
+
+@property (nonatomic,readonly) NSString * name;
+
+@property (nonatomic,readonly) NSArray * clauses;
+@property (nonatomic,readonly) NSArray * clauseRepresentations;
+
+@property (nonatomic,readonly) ANFilterMatchPolicy matchPolicy;
+@property (nonatomic,readonly) NSString * matchPolicyRepresentation;
+
+- (void)deleteWithCompletion:(ANFilterRequestCompletion)completion;
+- (void)updateFromDraft:(ANDraftFilter*)draftFilter completion:(ANFilterRequestCompletion)completion;
+
+- (ANDraftFilter*)draftFilter;
+
+@end
+
+typedef enum {
+ ANFilterClauseObjectTypePost,
+ ANFilterClauseObjectTypeStar,
+ ANFilterClauseObjectTypeUserFollow
+} ANFilterClauseObjectType;
+
+extern NSString * ANStringFromFilterClauseObjectType(ANFilterClauseObjectType objectType);
+extern ANFilterClauseObjectType ANFilterClauseObjectTypeFromString(NSString * string);
+
+typedef enum {
+ ANFilterClauseOperatorEquals,
+ ANFilterClauseOperatorMatches,
+ ANFilterClauseOperatorLess,
+ ANFilterClauseOperatorLessOrEquals,
+ ANFilterClauseOperatorGreater,
+ ANFilterClauseOperatorGreaterOrEquals,
+ ANFilterClauseOperatorOneOf
+} ANFilterClauseOperator;
+
+extern NSString * ANStringFromFilterClauseOperator(ANFilterClauseOperator operator);
+extern ANFilterClauseOperator ANFilterClauseOperatorFromString(NSString * string);
+
+@interface ANFilterClause : ANResource
+
+@property (nonatomic,readonly) ANFilterClauseObjectType objectType;
+@property (nonatomic,readonly) NSString * objectTypeRepresentation;
+
+@property (nonatomic,readonly) ANFilterClauseOperator operator;
+@property (nonatomic,readonly) NSString * operatorRepresentation;
+
+@property (nonatomic,readonly) NSString * field;
+@property (nonatomic,readonly) id value;
+
+- (ANDraftFilterClause*)draftFilterClause;
+
+@end
+
+@interface ANDraftFilter : NSObject
+
+@property (nonatomic,readwrite) NSString * name;
+@property (nonatomic,readonly) NSMutableArray * clauses;
+@property (nonatomic,readwrite) ANFilterMatchPolicy matchPolicy;
+
+@property (nonatomic,copy) NSDictionary * representation;
+
+- (void)createFilterViaSession:(ANSession*)session completion:(ANFilterRequestCompletion)completion;
+
+@end
+
+@interface ANDraftFilterClause : NSObject
+
+@property (nonatomic,assign) ANFilterClauseObjectType objectType;
+@property (nonatomic,assign) ANFilterClauseOperator operator;
+@property (nonatomic,strong) NSString * field;
+@property (nonatomic,strong) id value;
+
+@property (nonatomic,copy) NSDictionary * representation;
+
+@end
Oops, something went wrong.

0 comments on commit 46d481f

Please sign in to comment.