PageRenderTime 62ms CodeModel.GetById 18ms app.highlight 40ms RepoModel.GetById 2ms app.codeStats 0ms

/NSRTMParamsCriteria.m

http://rtm2cocoa.googlecode.com/
Objective C | 94 lines | 61 code | 13 blank | 20 comment | 5 complexity | 6e741d27d5371915bb44232d875de11d MD5 | raw file
 1/*
 2*  NSRTMParamsCriteria.m
 3*  RTMApiTest
 4*
 5*  Created by kkillian on 17/11/09.
 6*  Copyright 2009 shufflecodebox. All rights reserved.
 7*	This program is free software; you can redistribute it and/or modify
 8*	it under the terms of the GNU General Public License as published by
 9*	the Free Software Foundation; either version 2 of the License, or
10*	(at your option) any later version.
11*
12*	This program is distributed in the hope that it will be useful,
13*	but WITHOUT ANY WARRANTY; without even the implied warranty of
14*	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*	GNU General Public License for more details.
16*
17*	You should have received a copy of the GNU General Public License
18*	along with this program; if not, write to the Free Software
19*	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20*/
21
22#import "NSRTMParamsCriteria.h"
23
24#define RTMCriteriaListName @"list"
25#define RTMCriteriaTaskName @"name"
26#define RTMCriteriaNoteContains @"noteContains"
27#define RTMCriteriaHasNotes @"hasNotes"
28#define RTMCriteriaPriority @"priority"
29#define RTMCriteriaTimeEstimate @"timeEstimate"
30#define RTMCriteriaPostponed @"postponed"
31#define RTMCriteriaStatus @"status"
32
33#define RTM_TRUE @"true"
34#define RTM_FALSE @"false"
35
36@implementation NSRTMParamsCriteria
37
38+(NSRTMParamsCriteria *)criteriaWithListName:(NSString *)value {
39	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaListName] retain];
40	[criteria setCriteriaValue:value];
41	return criteria;
42}
43
44+(NSRTMParamsCriteria *)criteriaWithTaskName:(NSString *)value {
45	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaTaskName] retain];
46	[criteria setCriteriaValue:value];
47	return criteria;
48}
49
50+(NSRTMParamsCriteria *)criteriaWithNote:(NSString *)value {
51	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaNoteContains] retain];
52	[criteria setCriteriaValue:value];
53	return criteria;
54}
55
56+(NSRTMParamsCriteria *)criteriaWithNoted:(BOOL)value {
57	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaHasNotes] retain];
58	if(value) {
59		[criteria setCriteriaValue:RTM_TRUE];
60	} else {
61		[criteria setCriteriaValue:RTM_FALSE];
62	}	
63	return criteria;
64}
65
66+(NSRTMParamsCriteria *)criteriaWithPriority:(NSInteger *)value {
67	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaPriority] retain];
68	[criteria setCriteriaValue:[NSString stringWithFormat:@"%d", value]];
69	return criteria;
70}
71
72+(NSRTMParamsCriteria *)criteriaWithEstimeteTime:(NSString *)value {
73	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaTimeEstimate] retain];
74	[criteria setCriteriaValue:value];
75	return criteria;
76}
77
78+(NSRTMParamsCriteria *)criteriaWithPosponedNum:(NSInteger*)value option:(NSRTMPosponedFilter)filter {
79	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaPostponed] retain];
80	[criteria setCriteriaValue:[NSString stringWithFormat:@"%d", value]];
81	return criteria;
82}
83
84+(NSRTMParamsCriteria *)criteriaWithStatus:(NSRTMStatusOptions)value {
85	NSRTMParamsCriteria *criteria = [[[NSRTMParamsCriteria alloc] initWithCriteria:RTMCriteriaStatus] retain];
86	if(value == NSRTMTaskStatusCompleted) {
87		[criteria setCriteriaValue:@"completed"];
88	} else {
89		[criteria setCriteriaValue:@"incomplete"];
90	}	
91	return criteria;
92}
93
94@end