PageRenderTime 203ms CodeModel.GetById 14ms app.highlight 179ms RepoModel.GetById 1ms app.codeStats 0ms

/NSRTM.m

http://rtm2cocoa.googlecode.com/
Objective C | 1245 lines | 1037 code | 113 blank | 95 comment | 156 complexity | 4a41a6d2240d2d842158c5325753a7f5 MD5 | raw file
   1/*
   2 *  NSRTM.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/**
  23 * NSRTM is the main class of the Cocoa2RTM framework
  24 * Usage:
  25 * User Authentication
  26 * Generate a frob code
  27 * With the frob code generate a auth process and allow application in the user account. This process will generate a token code
  28 * Request the token code.
  29 * Now you are ready to work with RTM
  30 */
  31#import "NSRTM.h"
  32#import "DebugLog.h"
  33#import "NSRTMMethod.h"
  34#import "NSRTMInvoker.h"
  35#import "NSRTMService.h"
  36#import "NSRTMController.h"
  37
  38#import "NSRTMTagCriteria.h"
  39#import "NSRTMParamsCriteria.h"
  40
  41// AUTH METHODS
  42#define RTM_AUTH_checkToken @"rtm.auth.checkToken"
  43#define RTM_AUTH_getFrob @"rtm.auth.getFrob"
  44#define RTM_AUTH_getToken @"rtm.auth.getToken"
  45
  46// CONTACTS METHOD
  47#define RTM_CONTACTS_add @"rtm.contacts.add"
  48#define RTM_CONTACTS_delete @"rtm.contacts.delete"
  49#define RTM_CONTACTS_getList @"rtm.contacts.getList"
  50
  51// GROUP METHODS
  52#define RTM_GROUPS_add @"rtm.groups.add"
  53#define RTM_GROUPS_addContact @"rtm.groups.addContact"
  54#define RTM_GROUPS_delete @"rtm.groups.delete"
  55#define RTM_GROUPS_getList @"rtm.groups.getList"
  56#define RTM_GROUPS_removeContact @"rtm.groups.removeContact"
  57
  58//LISTS METHODS
  59#define RTM_LISTS_add @"rtm.lists.add"
  60#define RTM_LISTS_archive @"rtm.lists.archive"
  61#define RTM_LISTS_delete @"rtm.lists.delete"
  62#define RTM_LISTS_getList @"rtm.lists.getList"
  63#define RTM_LISTS_setDefaultList @"rtm.lists.setDefaultList"
  64#define RTM_LISTS_setName @"rtm.lists.setName"
  65#define RTM_LISTS_unarchive @"rtm.lists.unarchive"
  66
  67// LOCATION METHOD
  68#define RTM_LOCATIONS_getList @"rtm.locations.getList"
  69
  70// REFLECTION METHOD
  71#define RTM_REFLECTION_getMethodInfo @"rtm.reflection.getMethodInfo"
  72#define RTM_REFLECTION_getMethods @"rtm.reflection.getMethods"
  73
  74// SETTINGS METHOD
  75#define RTM_SETTINGS_getList @"rtm.settings.getList"
  76
  77// TASKS METHODS
  78#define RTM_TASKS_add @"rtm.tasks.add"
  79#define RTM_TASKS_addTags @"rtm.tasks.addTags"
  80#define RTM_TASKS_complete @"rtm.tasks.complete"
  81#define RTM_TASKS_delete @"rtm.tasks.delete"
  82#define RTM_TASKS_getList @"rtm.tasks.getList"
  83#define RTM_TASKS_movePriority @"rtm.tasks.movePriority"
  84#define RTM_TASKS_moveTo @"rtm.tasks.moveTo"
  85#define RTM_TASKS_notes_add @"rtm.tasks.notes.add"
  86#define RTM_TASKS_notes_delete @"rtm.tasks.notes.delete"
  87#define RTM_TASKS_notes_edit @"rtm.tasks.notes.edit"
  88#define RTM_TASKS_postpone @"rtm.tasks.postpone"
  89#define RTM_TASKS_removeTags @"rtm.tasks.removeTags"
  90#define RTM_TASKS_setDueDate @"rtm.tasks.setDueDate"
  91#define RTM_TASKS_seEstimate @"rtm.tasks.setEstimate"
  92#define RTM_TASKS_setLocation @"rtm.tasks.setLocation"
  93#define RTM_TASKS_setName @"rtm.tasks.setName"
  94#define RTM_TASKS_setPriority @"rtm.tasks.setPriority"
  95#define RTM_TASKS_setRecurrence @"rtm.tasks.setRecurrence"
  96#define RTM_TASKS_setTags @"rtm.tasks.setTags"
  97#define RTM_TASKS_setURL @"rtm.tasks.setURL"
  98#define RTM_TASKS_uncomplete @"rtm.tasks.uncomplete"
  99
 100	// NOTE METHODS
 101#define RTM_NOTE_add @"rtm.tasks.notes.add"
 102#define RTM_NOTE_delete @"rtm.tasks.notes.delete"
 103#define RTM_NOTE_edit @"rtm.tasks.note.edit"
 104// TEST METHODS
 105#define RTM_TEST_echo @"rtm.test.echo"
 106#define RTM_TEST_login @"rtm.test.login"
 107
 108// TIME METHODS
 109#define RTM_TIME_convert @"rtm.time.convert"
 110#define RTM_TIME_parse @"rtm.time.parse"
 111
 112// OTHERS
 113#define RTM_TIMELINES_create @"rtm.timelines.create"
 114
 115#define RTM_TIMEZONES_getList @"rtm.timezones.getList"
 116
 117#define RTM_TRANSACTIONS_undo @"rtm.transactions.undo"
 118
 119#define RTMPrefSavedToken @"rtm.cocoa.token.pref"
 120#define RTMPrefSavedFrob @"rtm.cocoa.frob.pref"
 121
 122@implementation NSRTM
 123
 124/**
 125 * Inizialize the RTM controller
 126 * @param apikey the apikey for all the methos
 127 * @param sicretvalue the sicret given with the apikey
 128 */
 129#pragma mark Inizialize
 130-(id)initWithApikey:(NSString *)apikey andSicret:(NSString *)sicretvalue {
 131	self = [super init];
 132	if(![self loadMyNibFile]) {
 133		NSException *exception = [NSException exceptionWithName:@"ComponenteException" reason:@"Unable to load the bundle"  userInfo:nil];
 134		@throw exception;
 135	}
 136	if (self != nil) {
 137		api_key = apikey;
 138		sicret = sicretvalue;
 139		if(api_key != nil && sicret != nil) {
 140			mainInvoker = [[NSRTMInvoker alloc] initWithApiKey:api_key andSicret:sicret];
 141			if(mainInvoker != nil) {
 142				mainService = [[NSRTMService alloc] initWithInvoker:mainInvoker];
 143			}
 144		}
 145		defaults = [NSUserDefaults standardUserDefaults];
 146		
 147		if([defaults stringForKey:RTMPrefSavedToken] != NULL) {
 148			token = [defaults stringForKey:RTMPrefSavedToken];
 149		}
 150	} else {
 151		NSException *exception = [NSException exceptionWithName:@"InitException" reason:@"apikey and sicretValue can't be nil"  userInfo:nil];
 152		@throw exception;
 153	}
 154	return self;
 155}
 156
 157- (BOOL)loadMyNibFile {
 158    // The myNib file must be in the bundle that defines self's class.
 159	dialogController = [[NSRTMController alloc] init];
 160	[dialogController setDelegate:self];
 161    if (![NSBundle loadNibNamed:@"rtm" owner:dialogController]) {
 162        DLog(@"Warning! Could not load myNib file.\n");
 163        return NO;
 164    }
 165    return YES;
 166	
 167}
 168
 169-(void)dealloc {
 170	[mainInvoker release];
 171	[mainService release];	
 172	[dialogController release];
 173	[super dealloc];
 174}
 175
 176#pragma mark -
 177
 178
 179#pragma mark Delegate
 180
 181-(void)setDelegate:(id)val {
 182	rtmDelegate = val;
 183}
 184-(id)delegate {
 185	return rtmDelegate;
 186}
 187
 188- (void)manageError:(NSRTMError *)error {
 189    if ([rtmDelegate respondsToSelector:@selector(manageRTMError:)]) {
 190        [rtmDelegate manageRTMError:error];
 191    } else {
 192		[NSApp presentError:error];
 193			// [NSException raise:NSInternalInconsistencyException format:@"Delegate doesn't respond to manageRTMError"];
 194    }
 195}
 196#pragma mark -
 197
 198#pragma mark Extra
 199/*
 200-(NSMutableArray *)getAllTasks {
 201	NSMutableArray *tasks = [[NSMutableArray alloc] init];
 202
 203	NSMutableArray *fullists = [self getTaskList];
 204	NSEnumerator * enumerator = [fullists objectEnumerator];
 205	NSRTMList *element;	
 206	while(element = [enumerator nextObject])
 207	{
 208		[tasks addObjectsFromArray:[element getTaskseries]];
 209	}
 210	return tasks;
 211}*/
 212
 213-(NSMutableArray *)getFullTaskLists {
 214	NSMutableArray *lists = [self getLists];
 215	if(lists != nil && [lists count] > 0) {
 216		NSMutableArray *fullists = [self getTaskList];
 217		NSEnumerator * enumerator = [lists objectEnumerator];
 218		NSRTMList *element;	
 219		while(element = [enumerator nextObject])
 220		{
 221			NSInteger foundIndex = [fullists indexOfObject:element];
 222			if(foundIndex != NSNotFound) {
 223				NSRTMList *fullList = [fullists objectAtIndex:foundIndex];
 224				[element setTaskseries:[fullList getTaskseries]];
 225
 226			}
 227		}
 228	}
 229	return lists;
 230}
 231
 232-(NSMutableArray *)getFullTaskLists:(BOOL)completed {
 233	NSMutableArray *lists = [self getLists];
 234	if(lists != nil && [lists count] > 0) {
 235		NSMutableArray *fullists = [self getTaskList];
 236		NSEnumerator * enumerator = [lists objectEnumerator];
 237		NSRTMList *element;	
 238		while(element = [enumerator nextObject])
 239		{
 240			NSInteger foundIndex = [fullists indexOfObject:element];
 241			if(foundIndex != NSNotFound) {
 242				NSRTMList *fullList = [fullists objectAtIndex:foundIndex];
 243				NSMutableArray *taskseries = [fullList getTaskseries:completed];
 244				[element setTaskseries:taskseries];
 245			}
 246		}
 247	}
 248	return lists;
 249}
 250
 251-(NSMutableArray *)getFullTaskLists2:(BOOL)completed {
 252	NSMutableArray *lists = [self getLists];
 253	if(lists != nil && [lists count] > 0) {
 254		NSRTMParamsCriteria *paramCriteria = [NSRTMParamsCriteria criteriaWithStatus:NSRTMTaskStatusInCompleted];
 255		NSRTMPredicate *predicate = [[NSRTMPredicate alloc] initPredicateWithCriteria:paramCriteria];
 256		DLog(@"%@ %d",[predicate formattedPredicate],[predicate getCriteriaCount]);
 257		
 258		NSEnumerator * enumerator = [lists objectEnumerator];
 259		NSRTMList *element;
 260		while(element = [enumerator nextObject])
 261		{
 262			NSRTMList *listtaskseries = [self getTaskListWithId:[[element getListId] intValue] filter:predicate lastSync:nil];
 263			DLog(@"%@",[listtaskseries description]);
 264			[element setTaskseries:[listtaskseries getTaskseries]];
 265		}
 266	}
 267		// NSRTMTagCriteria *tagCriteria = [NSRTMTagCriteria criteriaWithTagConteins:@"@"];
 268		//DLog(@"%@",[tagCriteria getFormattedCriteria]);
 269		
 270	return lists;
 271}
 272#pragma mark -
 273
 274#pragma mark MainMethods
 275
 276/**
 277 * Method can be called without authenticate
 278 * return a list of all the available api methods
 279 * @return NSRTMResponse
 280 */
 281-(NSRTMResponse *)getMethods {
 282	NSRTMError *error = nil;
 283	NSMutableArray *params = [[NSMutableArray alloc] init];
 284	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_REFLECTION_getMethods]];
 285	if([mainService execute:params error:&error]) {
 286		return [mainService getResponse];
 287	} else {
 288		[self manageError:error];
 289		return nil;
 290	}
 291}
 292
 293#pragma mark -
 294
 295#pragma mark Authenticate
 296-(BOOL)isRegistrated {
 297	BOOL isRegistrated = NO;
 298	if([defaults stringForKey:RTMPrefSavedToken] != NULL) {
 299		token = [defaults stringForKey:RTMPrefSavedToken];
 300		if([self checkToken]) {
 301			isRegistrated = YES;
 302		} else {
 303			[defaults removeObjectForKey:RTMPrefSavedToken];
 304		}
 305	}
 306	return isRegistrated;	
 307}
 308
 309/**
 310 * This method generate the process for the authentication
 311 * @param level the level of authentication
 312 * @see generateFrob
 313 */
 314-(void)authenticate:(NSString *)level {
 315	[dialogController openDialog:self];
 316	levelAuth = level;
 317}
 318
 319-(void)authenticateSelf {
 320	frob = [self generateFrob];
 321	DLog(@"My Frob: %@",frob);
 322	NSMutableArray *params = [[NSMutableArray alloc] init];
 323	[params addObject:[[NSRTMParam alloc] initWithKey:@"perms" value:levelAuth]];
 324	[params addObject:[[NSRTMParam alloc] initWithKey:@"frob" value:frob]];
 325	[mainService auth:params];
 326}
 327
 328/**
 329 * Generate Frob
 330 * with this method send a request for generate frob string
 331 * @return NSRTMResponse
 332 */
 333-(NSString *)generateFrob {
 334	NSRTMError *error = nil;
 335	NSMutableArray *params = [[NSMutableArray alloc] init];
 336	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_AUTH_getFrob]];
 337	NSRTMResponse *response = [mainService execute:params error:&error];
 338	if (error) {
 339		[self manageError:error];
 340		return nil;
 341	} else {
 342		return [response getFrob];
 343	}
 344}
 345
 346/**
 347 * Generate the auth token
 348 */
 349-(NSString *)getToken {
 350	NSRTMError *error = nil;
 351	if(frob != NULL) {	
 352		NSMutableArray *params = [[NSMutableArray alloc] init];
 353		[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_AUTH_getToken]];
 354		[params addObject:[[NSRTMParam alloc] initWithKey:@"frob" value:frob]];
 355		NSRTMResponse *response = [mainService execute:params error:&error];
 356		if(error) {
 357			[self manageError:error];
 358			return nil;
 359		} else {
 360			return [[response getAuth] getToken];
 361		}
 362	} else {
 363		return nil;
 364	}
 365}
 366
 367/**
 368 * Check the auth token
 369 */
 370-(BOOL)checkToken {
 371	NSRTMError *error = nil;
 372	NSMutableArray *params = [[NSMutableArray alloc] init];
 373	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_AUTH_checkToken]];
 374	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 375	
 376	[mainService execute:params error:&error];
 377	if(error) {
 378		[self manageError:error];
 379		return NO;
 380	} else {
 381		return YES;
 382	}
 383}
 384
 385/**
 386 * This method save the auth token in the preferencies
 387 */
 388-(BOOL)saveToken {
 389	BOOL isSaved = NO;
 390	if(frob != NULL) {		
 391		NSString *theToken = [self getToken];
 392		DLog(@"theToken: %@",theToken);
 393		if(theToken != NULL) {
 394			[defaults setObject:theToken forKey:RTMPrefSavedToken];
 395			isSaved = YES;
 396		}			
 397	}
 398	return isSaved;
 399}
 400#pragma mark -
 401
 402#pragma mark Methos
 403
 404/**
 405 * Test method can be called without any api key
 406 * if you send some parameters it will respont with an acho of that parameters
 407 * @param params the listo of parameters to sent in the interface request
 408 * @return NSRTMResponse
 409 */
 410-(NSString *)testEcho:(NSMutableArray *)params {
 411	NSRTMError *error = nil;
 412	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TEST_echo]];
 413	NSRTMResponse *response = [mainService execute:params error:&error];
 414	if(error) {
 415		[self manageError:error];
 416		return nil;
 417	} else {
 418		return [response description];
 419	}
 420}
 421#pragma mark -
 422
 423#pragma mark MethodsContacts
 424
 425-(NSString *)addContact:(NSString *)contact {
 426	NSRTMError *error = nil;
 427	NSMutableArray *params = [[NSMutableArray alloc] init];
 428	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_CONTACTS_add]];
 429	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 430	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 431	[params addObject:[[NSRTMParam alloc] initWithKey:@"contact" value:contact]];
 432	NSRTMResponse *response = [mainService execute:params error:&error];
 433	if(error) {
 434		[self manageError:error];
 435		return nil;
 436	} else {
 437		return [[response getContact] getContact_id];
 438	}
 439	
 440}
 441
 442-(BOOL)deleteContact:(NSString *)contactId {
 443	NSRTMError *error = nil;
 444	NSMutableArray *params = [[NSMutableArray alloc] init];
 445	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_CONTACTS_delete]];
 446	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 447	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 448	[params addObject:[[NSRTMParam alloc] initWithKey:@"contact_id" value:contactId]];	
 449	
 450	[mainService execute:params error:&error];
 451	if(error) {
 452		[self manageError:error];
 453		return NO;
 454	} else {
 455		return YES;
 456	}
 457	
 458}
 459
 460-(NSMutableArray *)getContactsList {
 461	NSRTMError *error = nil;
 462	NSMutableArray *params = [[NSMutableArray alloc] init];
 463	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_CONTACTS_getList]];
 464	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 465	
 466	NSRTMResponse *response = [mainService execute:params error:&error];
 467	if(error) {
 468		[self manageError:error];
 469		return nil;
 470	} else {
 471		return [response getContacts];
 472	}
 473	
 474}
 475
 476#pragma mark -
 477
 478#pragma mark Timeline
 479
 480-(NSString *)createTimeline {
 481	NSRTMError *error = nil;
 482	NSString *timelineString = nil;
 483	NSMutableArray *params = [[NSMutableArray alloc] init];
 484	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TIMELINES_create]];
 485	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];	
 486	NSRTMResponse *response = [mainService execute:params error:&error];
 487	if(error) {
 488		[self manageError:error];
 489		return nil;
 490	} else {
 491		NSRTMTimeline *timeline = [response getTimeline];
 492		timelineString = [NSString stringWithString:[timeline getValue]];
 493		lastTimeline = timelineString;
 494	}
 495	return timelineString;	
 496}
 497
 498-(NSString *)getLastTimeline {
 499	return lastTimeline;
 500}
 501
 502-(BOOL)undo:(NSString *)transactionid {
 503	NSRTMError *error = nil;
 504	NSMutableArray *params = [[NSMutableArray alloc] init];
 505	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TRANSACTIONS_undo]];
 506	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 507	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:lastTimeline]];
 508	[params addObject:[[NSRTMParam alloc] initWithKey:@"transaction_id" value:transactionid]];
 509	[mainService execute:params error:&error];
 510	if(error) {
 511		[self manageError:error];
 512		return NO;
 513	} else {
 514		return YES;
 515	}
 516	
 517}
 518
 519#pragma mark -
 520
 521#pragma mark ListMethods
 522-(NSRTMList *)addList:(NSString *)name filter:(NSRTMPredicate *)predicate {
 523	NSRTMError *error = nil;
 524	NSMutableArray *params = [[NSMutableArray alloc] init];
 525	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_LISTS_add]];
 526	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 527	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 528	[params addObject:[[NSRTMParam alloc] initWithKey:@"name" value:name]];
 529	[params addObject:[[NSRTMParam alloc] initWithKey:@"filter" value:[predicate formattedPredicate]]];
 530	NSRTMResponse *response = [mainService execute:params error:&error];
 531	if(error) {
 532		[self manageError:error];
 533		return nil;
 534	} else {
 535		return [response getList];
 536	}	 
 537}
 538
 539-(BOOL)archiveList:(NSInteger)listId {
 540	NSRTMError *error = nil;
 541	NSMutableArray *params = [[NSMutableArray alloc] init];
 542	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_LISTS_archive]];
 543	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 544	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 545	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[[NSNumber numberWithInteger:listId] stringValue]]];
 546	[mainService execute:params error:&error];
 547	if(error) {
 548		[self manageError:error];
 549		return NO;
 550	} else {
 551		return YES;
 552	}	 	 
 553}
 554
 555-(BOOL)unarchiveList:(NSInteger)listId{
 556	NSRTMError *error = nil;
 557	NSMutableArray *params = [[NSMutableArray alloc] init];
 558	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_LISTS_unarchive]];
 559	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 560	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 561	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[[NSNumber numberWithInteger:listId] stringValue]]];
 562	[mainService execute:params error:&error];
 563	if(error) {
 564		[self manageError:error];
 565		return NO;
 566	} else {
 567		return YES;
 568	}	 	 	 
 569}
 570
 571-(BOOL)deleteList:(NSInteger)listId{
 572	NSRTMError *error = nil;
 573	NSMutableArray *params = [[NSMutableArray alloc] init];
 574	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_LISTS_delete]];
 575	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 576	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 577	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[[NSNumber numberWithInteger:listId] stringValue]]];
 578	[mainService execute:params error:&error];
 579	if(error) {
 580		[self manageError:error];
 581		return NO;
 582	} else {
 583		return YES;
 584	}		
 585}
 586	 
 587-(NSMutableArray *)getLists{
 588	NSRTMError *error = nil;
 589	NSMutableArray *params = [[NSMutableArray alloc] init];
 590	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_LISTS_getList]];
 591	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 592	NSRTMResponse *response = [mainService execute:params error:&error];
 593	if(error) {
 594		[self manageError:error];
 595		return nil;
 596	} else {
 597		return [response getLists];
 598	}	 	 
 599}
 600
 601-(BOOL)setDefaultList:(NSInteger)listId{
 602	NSRTMError *error = nil;
 603	NSMutableArray *params = [[NSMutableArray alloc] init];
 604	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_LISTS_setDefaultList]];
 605	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 606	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 607	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[[NSNumber numberWithInteger:listId] stringValue]]];
 608	[mainService execute:params error:&error];
 609	if(error) {
 610		[self manageError:error];
 611		return NO;
 612	} else {
 613		return YES;
 614	}	 
 615}
 616	 
 617-(NSRTMList *)setListName:(NSString *)name withId:(NSInteger)listId{
 618	NSRTMError *error = nil;
 619	NSMutableArray *params = [[NSMutableArray alloc] init];
 620	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_LISTS_delete]];
 621	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 622	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 623	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[[NSNumber numberWithInteger:listId] stringValue]]];
 624	[params addObject:[[NSRTMParam alloc] initWithKey:@"name" value:name]];
 625	NSRTMResponse *response = [mainService execute:params error:&error];
 626	if(error) {
 627		[self manageError:error];
 628		return nil;
 629	} else {
 630		return [response getList];
 631	}
 632}
 633#pragma mark -
 634
 635#pragma mark LocationMethods
 636-(NSMutableArray *)getLocationsList {
 637	NSRTMError *error = nil;
 638	NSMutableArray *params = [[NSMutableArray alloc] init];
 639	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_LOCATIONS_getList]];
 640	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 641	NSRTMResponse *response = [mainService execute:params error:&error];
 642	if(error) {
 643		[self manageError:error];
 644		return nil;
 645	} else {
 646		return [response getLocations];
 647	}
 648}
 649-(NSRTMSettings *)getSettingsList {
 650	NSRTMError *error = nil;
 651	NSMutableArray *params = [[NSMutableArray alloc] init];
 652	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_SETTINGS_getList]];
 653	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 654	NSRTMResponse *response = [mainService execute:params error:&error];
 655	if(error) {
 656		[self manageError:error];
 657		return nil;
 658	} else {
 659		return [response getSettings];
 660	}
 661}
 662-(NSMutableArray *)getTinmezones {
 663	NSRTMError *error = nil;
 664	NSMutableArray *params = [[NSMutableArray alloc] init];
 665	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TIMEZONES_getList]];
 666	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 667	NSRTMResponse *response = [mainService execute:params error:&error];
 668	if(error) {
 669		[self manageError:error];
 670		return nil;
 671	} else {
 672		return [response getTimezones];
 673	}
 674}
 675#pragma mark -
 676
 677-(NSRTMList *)addNewTask:(NSString *)name atList:(NSInteger)listId parse:(BOOL)option {
 678	NSRTMError *error = nil;
 679	NSMutableArray *params = [[NSMutableArray alloc] init];
 680	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_add]];
 681	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 682	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 683	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[[NSNumber numberWithInteger:listId] stringValue]]];
 684	[params addObject:[[NSRTMParam alloc] initWithKey:@"name" value:name]];
 685	if(option) [params addObject:[[NSRTMParam alloc] initWithKey:@"parse" value:@"1"]];
 686
 687	NSRTMResponse *response = [mainService execute:params error:&error];
 688	if(error) {
 689		[self manageError:error];
 690		return nil;
 691	} else {
 692		return [response getList];
 693	}
 694}
 695
 696-(NSRTMList *)addTags:(NSMutableArray *)tags withLocator:(NSRTMLocator *)locator{
 697	NSRTMError *error = nil;
 698	NSMutableArray *params = [[NSMutableArray alloc] init];
 699	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_add]];
 700	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 701	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 702	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
 703	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 704	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 705	[params addObject:[[NSRTMParam alloc] initWithKey:@"tags" value:[tags componentsJoinedByString:@","]]];
 706	NSRTMResponse *response = [mainService execute:params error:&error];
 707	if(error) {
 708		[self manageError:error];
 709		return nil;
 710	} else {
 711		return [response getList];
 712	}
 713}
 714	 
 715-(NSRTMList *)completeTask:(NSRTMLocator *)locator{
 716	NSRTMError *error = nil;
 717	NSMutableArray *params = [[NSMutableArray alloc] init];
 718	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_complete]];
 719	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 720	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 721	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
 722	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 723	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 724
 725	 NSRTMResponse *response = [mainService execute:params error:&error];
 726	 if(error) {
 727		 [self manageError:error];
 728		 return nil;
 729	 } else {
 730		 return [response getList];
 731	 }
 732}
 733	 
 734-(NSRTMList *)deleteTask:(NSRTMLocator *)locator {
 735	NSRTMError *error = nil;
 736	NSMutableArray *params = [[NSMutableArray alloc] init];
 737	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_delete]];
 738	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 739	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 740	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
 741	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 742	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 743	
 744	NSRTMResponse *response = [mainService execute:params error:&error];
 745	if(error) {
 746		[self manageError:error];
 747		return nil;
 748	} else {
 749		return [response getList];
 750	}
 751}
 752
 753-(NSMutableArray *)getTaskList {
 754	NSRTMError *error = nil;
 755	NSMutableArray *params = [[NSMutableArray alloc] init];
 756	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_getList]];
 757	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 758	
 759	NSRTMResponse *response = [mainService execute:params error:&error];
 760	if(error) {
 761		[self manageError:error];
 762		return nil;
 763	} else {
 764		return [response getListsTasks];
 765	}
 766}
 767
 768-(NSMutableArray *)getTaskListWithId:(NSInteger)listId {
 769	NSRTMError *error = nil;
 770	NSMutableArray *params = [[NSMutableArray alloc] init];
 771	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_getList]];
 772	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 773	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[[NSNumber numberWithInteger:listId] stringValue]]];
 774	
 775	NSRTMResponse *response = [mainService execute:params error:&error];
 776	if(error) {
 777		[self manageError:error];
 778		return nil;
 779	} else {
 780		return [response getListsTasks];
 781	}
 782	
 783}
 784-(NSRTMList *)getTaskListWithId:(NSInteger)listId filter:(NSRTMPredicate *)predicate lastSync:(NSDate *)time {
 785	NSRTMError *error = nil;
 786	NSMutableArray *params = [[NSMutableArray alloc] init];
 787	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_getList]];
 788	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 789	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[[NSNumber numberWithInteger:listId] stringValue]]];
 790	if(predicate != nil) {
 791		[params addObject:[[NSRTMParam alloc] initWithKey:@"filter" value:[predicate formattedPredicate]]];
 792	}
 793	if(time != nil) {
 794		[params addObject:[[NSRTMParam alloc] initWithKey:@"last_sync" value:[time description]]];
 795	}
 796	
 797	NSRTMResponse *response = [mainService execute:params error:&error];
 798	if(error) {
 799		[self manageError:error];
 800		return nil;
 801	} else {
 802		if ([[response getListsTasks] count] > 0) {
 803			return (NSRTMList*)[[response getListsTasks] objectAtIndex:0];
 804		} else {
 805			return nil;
 806		}
 807		
 808	}
 809}
 810
 811-(NSMutableArray *)getTaskListWithPredicate:(NSRTMPredicate *)predicate lastSync:(NSDate *)time {
 812	NSRTMError *error = nil;
 813	NSMutableArray *params = [[NSMutableArray alloc] init];
 814	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_getList]];
 815	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 816	if(predicate != nil) {
 817		[params addObject:[[NSRTMParam alloc] initWithKey:@"filter" value:[predicate formattedPredicate]]];
 818	}
 819	if(time != nil) {
 820		[params addObject:[[NSRTMParam alloc] initWithKey:@"last_sync" value:[time description]]];
 821	}
 822	
 823	NSRTMResponse *response = [mainService execute:params error:&error];
 824	if(error) {
 825		[self manageError:error];
 826		return nil;
 827	} else {
 828		if ([[response getListsTasks] count] > 0) {
 829			return [response getListsTasks];
 830		} else {
 831			return nil;
 832		}
 833		
 834	}
 835}
 836
 837-(NSRTMList *)movePriority:(NSRTMPriorityDirection)direction withLocator:(NSRTMLocator *)locator{
 838	NSRTMError *error = nil;
 839	NSMutableArray *params = [[NSMutableArray alloc] init];
 840	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_movePriority]];
 841	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 842	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 843	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
 844	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 845	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 846	if(direction == NSRTMDirectionUp) {
 847		[params addObject:[[NSRTMParam alloc] initWithKey:@"direction" value:@"up"]];
 848	} else {
 849		[params addObject:[[NSRTMParam alloc] initWithKey:@"direction" value:@"down"]];
 850	}
 851	
 852	NSRTMResponse *response = [mainService execute:params error:&error];
 853	if(error) {
 854		[self manageError:error];
 855		return nil;
 856	} else {
 857		return [response getList];
 858	}
 859	
 860}
 861-(NSRTMList *)moveToList:(NSInteger)fromId withLocator:(NSRTMLocator *)locator{
 862	NSRTMError *error = nil;
 863	NSMutableArray *params = [[NSMutableArray alloc] init];
 864	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_moveTo]];
 865	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 866	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 867	[params addObject:[[NSRTMParam alloc] initWithKey:@"to_list_id" value:[locator getListId]]];
 868	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 869	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 870	[params addObject:[[NSRTMParam alloc] initWithKey:@"from_task_id" value:[[NSNumber numberWithInt:fromId] stringValue]]];
 871	
 872	NSRTMResponse *response = [mainService execute:params error:&error];
 873	if(error) {
 874		[self manageError:error];
 875		return nil;
 876	} else {
 877		return [response getList];
 878	}
 879	
 880}
 881
 882-(NSRTMList *)posponeTask:(NSRTMLocator *)locator{
 883	NSRTMError *error = nil;
 884	NSMutableArray *params = [[NSMutableArray alloc] init];
 885	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_postpone]];
 886	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 887	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 888	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
 889	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 890	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 891	
 892	NSRTMResponse *response = [mainService execute:params error:&error];
 893	if(error) {
 894		[self manageError:error];
 895		return nil;
 896	} else {
 897		return [response getList];
 898	}	
 899}
 900
 901-(NSRTMList *)removeTags:(NSMutableArray *)tags withLocator:(NSRTMLocator *)locator{
 902	NSRTMError *error = nil;
 903	NSMutableArray *params = [[NSMutableArray alloc] init];
 904	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_removeTags]];
 905	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 906	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 907	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
 908	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 909	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 910	[params addObject:[[NSRTMParam alloc] initWithKey:@"tags" value:[tags componentsJoinedByString:@","]]];
 911	NSRTMResponse *response = [mainService execute:params error:&error];
 912	if(error) {
 913		[self manageError:error];
 914		return nil;
 915	} else {
 916		return [response getList];
 917	}
 918}
 919#pragma mark Dasistemare
 920-(NSRTMList *)setDueDate:(NSDate *)date withLocator:(NSRTMLocator *)locator{
 921	NSRTMError *error = nil;
 922	NSMutableArray *params = [[NSMutableArray alloc] init];
 923	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setDueDate]];
 924	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 925	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 926	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
 927	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 928	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 929	[params addObject:[[NSRTMParam alloc] initWithKey:@"due" value:[date description]]];
 930	NSRTMResponse *response = [mainService execute:params error:&error];
 931	if(error) {
 932		[self manageError:error];
 933		return nil;
 934	} else {
 935		return [response getList];
 936	}
 937}
 938
 939-(NSRTMList *)setDueDateWithString:(NSString *)date withLocator:(NSRTMLocator *)locator{
 940	NSRTMError *error = nil;
 941	NSMutableArray *params = [[NSMutableArray alloc] init];
 942	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setDueDate]];
 943	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 944	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 945	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
 946	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 947	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 948	[params addObject:[[NSRTMParam alloc] initWithKey:@"due" value:date]];
 949	NSRTMResponse *response = [mainService execute:params error:&error];
 950	if(error) {
 951		[self manageError:error];
 952		return nil;
 953	} else {
 954		return [response getList];
 955	}
 956}
 957
 958-(NSRTMList *)removeDueDate:(NSRTMLocator *)locator{
 959	NSRTMError *error = nil;
 960	NSMutableArray *params = [[NSMutableArray alloc] init];
 961	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setDueDate]];
 962	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 963	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 964	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
 965	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 966	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 967		// [params addObject:[[NSRTMParam alloc] initWithKey:@"due" value:date]];
 968	NSRTMResponse *response = [mainService execute:params error:&error];
 969	if(error) {
 970		[self manageError:error];
 971		return nil;
 972	} else {
 973		return [response getList];
 974	}
 975}
 976#pragma mark -
 977
 978-(NSRTMList *)setEstimate:(NSInteger)time withLocator:(NSRTMLocator *)locator{
 979	NSRTMError *error = nil;
 980	NSMutableArray *params = [[NSMutableArray alloc] init];
 981	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_seEstimate]];
 982	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
 983	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
 984	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
 985	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
 986	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
 987	[params addObject:[[NSRTMParam alloc] initWithKey:@"estimate" value:[[NSNumber numberWithInt:time] stringValue]]];
 988	NSRTMResponse *response = [mainService execute:params error:&error];
 989	if(error) {
 990		[self manageError:error];
 991		return nil;
 992	} else {
 993		return [response getList];
 994	}
 995}
 996-(NSRTMList *)removeEstimate:(NSRTMLocator *)locator{
 997	NSRTMError *error = nil;
 998	NSMutableArray *params = [[NSMutableArray alloc] init];
 999	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_seEstimate]];
1000	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1001	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1002	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1003	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1004	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1005		// [params addObject:[[NSRTMParam alloc] initWithKey:@"estimate" value:[[NSNumber numberWithInt:time] stringValue]]];
1006	NSRTMResponse *response = [mainService execute:params error:&error];
1007	if(error) {
1008		[self manageError:error];
1009		return nil;
1010	} else {
1011		return [response getList];
1012	}
1013}
1014
1015-(NSRTMList *)setLocation:(NSRTMLocation *)location withLocator:(NSRTMLocator *)locator{
1016	NSRTMError *error = nil;
1017	NSMutableArray *params = [[NSMutableArray alloc] init];
1018	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setLocation]];
1019	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1020	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1021	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1022	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1023	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1024	[params addObject:[[NSRTMParam alloc] initWithKey:@"location_id" value:[location getLocationId]]];
1025	NSRTMResponse *response = [mainService execute:params error:&error];
1026	if(error) {
1027		[self manageError:error];
1028		return nil;
1029	} else {
1030		return [response getList];
1031	}
1032}
1033-(NSRTMList *)setName:(NSString *)name withLocator:(NSRTMLocator *)locator{
1034	NSRTMError *error = nil;
1035	NSMutableArray *params = [[NSMutableArray alloc] init];
1036	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setName]];
1037	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1038	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1039	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1040	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1041	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1042	[params addObject:[[NSRTMParam alloc] initWithKey:@"name" value:name]];
1043	NSRTMResponse *response = [mainService execute:params error:&error];
1044	if(error) {
1045		[self manageError:error];
1046		return nil;
1047	} else {
1048		return [response getList];
1049	}
1050}
1051-(NSRTMList *)setPriority:(NSRTMPriority)priority withLocator:(NSRTMLocator *)locator{
1052	NSRTMError *error = nil;
1053	NSMutableArray *params = [[NSMutableArray alloc] init];
1054	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setPriority]];
1055	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1056	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1057	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1058	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1059	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1060	if(priority == NSRTMPriorityN) {
1061		[params addObject:[[NSRTMParam alloc] initWithKey:@"priority" value:@"N"]];
1062	} else {
1063		[params addObject:[[NSRTMParam alloc] initWithKey:@"priority" value:[[NSNumber numberWithInt:priority] stringValue]]];
1064	}
1065	
1066	NSRTMResponse *response = [mainService execute:params error:&error];
1067	if(error) {
1068		[self manageError:error];
1069		return nil;
1070	} else {
1071		return [response getList];
1072	}
1073}
1074
1075-(NSRTMList *)removePriority:(NSRTMLocator *)locator{
1076	NSRTMError *error = nil;
1077	NSMutableArray *params = [[NSMutableArray alloc] init];
1078	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setPriority]];
1079	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1080	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1081	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1082	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1083	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1084	
1085	NSRTMResponse *response = [mainService execute:params error:&error];
1086	if(error) {
1087		[self manageError:error];
1088		return nil;
1089	} else {
1090		return [response getList];
1091	}
1092}
1093
1094-(NSRTMList *)setRecurrence:(NSRTMRecurrence *)recurrence withLocator:(NSRTMLocator *)locator{
1095	NSRTMError *error = nil;
1096	NSMutableArray *params = [[NSMutableArray alloc] init];
1097	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setRecurrence]];
1098	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1099	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1100	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1101	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1102	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1103	[params addObject:[[NSRTMParam alloc] initWithKey:@"repeat" value:[recurrence getPeriod]]];
1104	
1105	NSRTMResponse *response = [mainService execute:params error:&error];
1106	if(error) {
1107		[self manageError:error];
1108		return nil;
1109	} else {
1110		return [response getList];
1111	}
1112}
1113
1114-(NSRTMList *)setTags:(NSMutableArray *)tags withLocator:(NSRTMLocator *)locator{
1115	NSRTMError *error = nil;
1116	NSMutableArray *params = [[NSMutableArray alloc] init];
1117	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setTags]];
1118	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1119	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1120	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1121	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1122	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1123	[params addObject:[[NSRTMParam alloc] initWithKey:@"tags" value:[tags componentsJoinedByString:@","]]];
1124	NSRTMResponse *response = [mainService execute:params error:&error];
1125	if(error) {
1126		[self manageError:error];
1127		return nil;
1128	} else {
1129		return [response getList];
1130	}
1131}
1132
1133-(NSRTMList *)setUrl:(NSURL *)url withLocator:(NSRTMLocator *)locator{
1134	NSRTMError *error = nil;
1135	NSMutableArray *params = [[NSMutableArray alloc] init];
1136	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setURL]];
1137	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1138	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1139	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1140	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1141	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1142	[params addObject:[[NSRTMParam alloc] initWithKey:@"url" value:[url host]]];
1143	NSRTMResponse *response = [mainService execute:params error:&error];
1144	if(error) {
1145		[self manageError:error];
1146		return nil;
1147	} else {
1148		return [response getList];
1149	}
1150	
1151}
1152
1153-(NSRTMList *)removeUrl:(NSRTMLocator *)locator{
1154	NSRTMError *error = nil;
1155	NSMutableArray *params = [[NSMutableArray alloc] init];
1156	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_setURL]];
1157	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1158	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1159	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1160	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1161	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1162	NSRTMResponse *response = [mainService execute:params error:&error];
1163	if(error) {
1164		[self manageError:error];
1165		return nil;
1166	} else {
1167		return [response getList];
1168	}
1169	
1170}
1171-(NSRTMList *)uncompleteTask:(NSRTMLocator *)locator{
1172	NSRTMError *error = nil;
1173	NSMutableArray *params = [[NSMutableArray alloc] init];
1174	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_TASKS_uncomplete]];
1175	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1176	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1177	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1178	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1179	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1180	NSRTMResponse *response = [mainService execute:params error:&error];
1181	if(error) {
1182		[self manageError:error];
1183		return nil;
1184	} else {
1185		return [response getList];
1186	}
1187}
1188#pragma mark -
1189
1190#pragma mark NoteMethods
1191-(NSRTMNote *)addNoteWithTitle:(NSString *)title andText:(NSString *)text withLocator:(NSRTMLocator *)locator{
1192	NSRTMError *error = nil;
1193	NSMutableArray *params = [[NSMutableArray alloc] init];
1194	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_NOTE_add]];
1195	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1196	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1197	[params addObject:[[NSRTMParam alloc] initWithKey:@"list_id" value:[locator getListId]]];
1198	[params addObject:[[NSRTMParam alloc] initWithKey:@"taskseries_id" value:[locator getTaskSeriesId]]];
1199	[params addObject:[[NSRTMParam alloc] initWithKey:@"task_id" value:[locator getTaskId]]];
1200	[params addObject:[[NSRTMParam alloc] initWithKey:@"note_title" value:title]];
1201	[params addObject:[[NSRTMParam alloc] initWithKey:@"note_text" value:text]];
1202	NSRTMResponse *response = [mainService execute:params error:&error];
1203	if(error) {
1204		[self manageError:error];
1205		return nil;
1206	} else {
1207		return [response getNote];
1208	}
1209}
1210-(BOOL)removeNote:(NSInteger)noteId{
1211	NSRTMError *error = nil;
1212	NSMutableArray *params = [[NSMutableArray alloc] init];
1213	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_NOTE_delete]];
1214	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1215	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1216	[params addObject:[[NSRTMParam alloc] initWithKey:@"note_id" value:[[NSNumber numberWithInt:noteId] stringValue]]];
1217	[mainService execute:params error:&error];
1218	if(error) {
1219		[self manageError:error];
1220		return NO;
1221	} else {
1222		return YES;
1223	}
1224}
1225-(NSRTMNote *)editNote:(NSInteger)noteId title:(NSString *)titlevalue andText:(NSString *)text{
1226	NSRTMError *error = nil;
1227	NSMutableArray *params = [[NSMutableArray alloc] init];
1228	[params addObject:[[NSRTMMethod alloc] initWithMethod:RTM_NOTE_edit]];
1229	[params addObject:[[NSRTMParam alloc] initWithKey:@"auth_token" value:token]];
1230	[params addObject:[[NSRTMParam alloc] initWithKey:@"timeline" value:[self createTimeline]]];
1231	[params addObject:[[NSRTMParam alloc] initWithKey:@"note_id" value:[[NSNumber numberWithInt:noteId] stringValue]]];
1232	[params addObject:[[NSRTMParam alloc] initWithKey:@"note_title" value:titlevalue]];
1233	[params addObject:[[NSRTMParam alloc] initWithKey:@"note_text" value:text]];
1234	NSRTMResponse *response = [mainService execute:params error:&error];
1235	if(error) {
1236		[self manageError:error];
1237		return nil;
1238	} else {
1239		return [response getNote];
1240	}
1241}
1242#pragma mark -
1243
1244
1245@end