00001 // 00002 // GtdApi.h 00003 // ToodledoAPI 00004 // 00005 // Created by Alex Leutgöb on 05.11.09. 00006 // Copyright 2009 alexleutgoeb.com. All rights reserved. 00007 // 00008 00009 #import <Foundation/Foundation.h> 00010 #import "GtdFolder.h" 00011 #import "GtdTask.h" 00012 #import "GtdNote.h" 00013 #import "GtdContext.h" 00014 00015 00016 // This constant defines the GtdApi error domain. 00017 extern NSString *const GtdApiErrorDomain; 00018 00019 @protocol GtdApi 00020 00021 @property (readonly) BOOL isAuthenticated; 00022 00023 // Main initializer, performs authentication. 00024 - (id)initWithUsername:(NSString *)username password:(NSString *)password error:(NSError **)error; 00025 00026 // Returns the last modifications dates in a dictionary, see doc for details. 00027 - (NSDictionary *)getLastModificationsDates:(NSError **)error; 00028 00029 // Loads and returns an array with GtdFolder objects. 00030 - (NSArray *)getFolders:(NSError **)error; 00031 00032 // Adds a remote folder 00033 - (NSInteger)addFolder:(GtdFolder *)aFolder error:(NSError **)error; 00034 00035 // Deletes a remote folder 00036 - (BOOL)deleteFolder:(GtdFolder *)aFolder error:(NSError **)error; 00037 00038 // Edits a remote folder 00039 - (BOOL)editFolder:(GtdFolder *)aFolder error:(NSError **)error; 00040 00041 //Loads and returns an array with GtdTask objects. 00042 - (NSArray *)getTasks:(NSError **)error; 00043 00044 //Adds a remote task 00045 - (NSInteger)addTask:(GtdTask *)aTask error:(NSError **)error; 00046 00047 //Edits a remote task 00048 - (BOOL)editTask:(GtdTask *)aTask error:(NSError **)error; 00049 00050 //Deletes a remote task 00051 - (BOOL)deleteTask:(GtdTask *)aTask error:(NSError **)error; 00052 00053 //Loads and returns an array with deleted task objects. 00054 - (NSArray *)getDeleted:(NSError **)error; 00055 00056 //Get remote Notes 00057 - (NSArray *)getNotes:(NSError **)error; 00058 00059 //Delete a given Note 00060 - (BOOL)deleteNote:(GtdNote *)aNote error:(NSError **)error; 00061 00062 //Adds given Note 00063 - (NSInteger)addNote:(GtdNote *)aNote error:(NSError **)error; 00064 00065 //Edits given Note 00066 - (BOOL)editNote:(GtdNote *)aNote error:(NSError **)error; 00067 00068 // Adds a given context 00069 - (NSInteger)addContext:(GtdContext *)aContext error:(NSError **)error; 00070 00071 // Gets a list of contexts 00072 - (NSArray *)getContexts:(NSError **)error; 00073 00074 // Deletes a given context 00075 - (BOOL)deleteContext:(GtdContext *)aContext error:(NSError **)error; 00076 00077 @end 00078 00079 00080 typedef enum { 00081 GtdApiNoConnectionError = 10, 00082 GtdApiNotReachableError = 20, 00083 GtdApiDataError = 30, 00084 GtdApiMissingParameters = 40, 00085 GtdApiMissingCredentialsError = 110, 00086 GtdApiWrongCredentialsError = 120, 00087 GtdApiFolderNotAddedError = 210, 00088 GtdApiFolderNotDeletedError = 310, 00089 GtdApiFolderNotEditedError = 410 00090 } GtdApiError;