/TweetPhoto.h

http://tweetphoto-api-objective-c.googlecode.com/ · C Header · 320 lines · 201 code · 69 blank · 50 comment · 0 complexity · 98c5760dfcc1964b48b42b7254a1b2a1 MD5 · raw file

  1. //
  2. // TweetPhoto.h
  3. // TPAPITest
  4. //
  5. // Created by David J. Hinson on 1/15/10.
  6. // Copyright 2010 TweetPhoto, Inc. All rights reserved.
  7. //
  8. // Objective-C Class interface for the TweetPhoto API, as specified here: http://groups.google.com/group/tweetphoto/web
  9. #import <Foundation/Foundation.h>
  10. #import "ElementParser.h"
  11. #import "Element.h"
  12. #import "Photos.h"
  13. #import "Profiles.h"
  14. #import "Settings.h"
  15. #import "Comments.h"
  16. #import "Favorites.h"
  17. #import "TweetPhotoResponse.h"
  18. #import "SocialFeed.h"
  19. #import "SocialFeedEvent.h"
  20. #import "VoteStatus.h"
  21. typedef enum {
  22. TweetPhotoSocialReturnTypeJSON,
  23. TweetPhotoSocialReturnTypeXML,
  24. } TweetPhotoSocialReturnTypes;
  25. typedef enum {
  26. TweetPhotoFeedTypeATOM,
  27. TweetPhotoFeedTypeRSS,
  28. } TweetPhotoFeedTypes;
  29. typedef enum {
  30. TweetPhotoCommentsReturnTypeJSON,
  31. TweetPhotoCommentsReturnTypeXML,
  32. } TweetPhotoCommentsReturnTypes;
  33. typedef enum {
  34. TweetPhotoFriendsReturnTypeJSON,
  35. TweetPhotoFriendsReturnTypeXML,
  36. } TweetPhotoFriendsReturnTypes;
  37. typedef enum {
  38. TweetPhotoFavoritesReturnTypeJSON,
  39. TweetPhotoFavoritesReturnTypeXML,
  40. } TweetPhotoFavoritesReturnTypes;
  41. typedef enum {
  42. TweetPhotoLocationReturnTypeJSON,
  43. TweetPhotoLocationReturnTypeXML,
  44. } TweetPhotoLocationReturnTypes;
  45. typedef enum {
  46. TweetPhotoSettingsReturnTypeJSON,
  47. TweetPhotoSettingsReturnTypeXML,
  48. } TweetPhotoSettingsReturnTypes;
  49. typedef enum {
  50. TweetPhotoDeletePhotoReturnTypeJSON,
  51. TweetPhotoDeletePhotoReturnTypeXML,
  52. } TweetPhotoDeletePhotoReturnTypes;
  53. typedef enum {
  54. TweetPhotoPhotoReturnTypeJSON,
  55. TweetPhotoPhotoReturnTypeXML,
  56. } TweetPhotoPhotoReturnTypes;
  57. typedef enum {
  58. TweetPhotoVoteReturnTypeJSON,
  59. TweetPhotoVoteReturnTypeXML,
  60. } TweetPhotoVoteReturnTypes;
  61. typedef enum {
  62. TweetPhotoHasVotedReturnTypeJSON,
  63. TweetPhotoHasVotedReturnTypeXML,
  64. } TweetPhotoHasVotedReturnTypes;
  65. typedef enum {
  66. TweetPhotoVoteTypeThumbsUp,
  67. TweetPhotoVoteTypeThumbsDown,
  68. } TweetPhotoVoteTypes;
  69. typedef enum {
  70. TweetPhotoSignInReturnTypeJSON,
  71. TweetPhotoSignInReturnTypeXML,
  72. } TweetPhotoSignInReturnTypes;
  73. typedef enum {
  74. TweetPhotoUploadReturnTypeJSON,
  75. TweetPhotoUploadReturnTypeXML,
  76. } TweetPhotoUploadReturnTypes;
  77. typedef enum {
  78. TweetPhotoCommentReturnTypeJSON,
  79. TweetPhotoCommentReturnTypeXML,
  80. } TweetPhotoCommentReturnTypes;
  81. typedef enum {
  82. TweetPhotoLeaderboardTypeViewed,
  83. TweetPhotoLeaderboardTypeCommented,
  84. TweetPhotoLeaderboardTypeVoted,
  85. } TweetPhotoLeaderboardTypes;
  86. typedef enum {
  87. TweetPhotoLeaderboardReturnTypeJSON,
  88. TweetPhotoLeaderboardReturnTypeXML,
  89. } TweetPhotoLeaderboardReturnTypes;
  90. typedef enum {
  91. TweetPhotoReturnTypeJSON,
  92. TweetPhotoReturnTypeXML,
  93. TweetPhotoReturnTypeRSS,
  94. TweetPhotoReturnTypeATOM,
  95. } TweetPhotoReturnTypes;
  96. typedef enum {
  97. TweetPhotoSortFilterComments,
  98. TweetPhotoSortFilterDate,
  99. TweetPhotoSortFilterViews,
  100. } TweetPhotoSortFilters;
  101. typedef enum {
  102. TweetPhotoSortAsc,
  103. TweetPhotoSortDesc,
  104. } TweetPhotoSorts;
  105. typedef enum {
  106. TweetPhotoSizeAll,
  107. TweetPhotoSizeBig,
  108. TweetPhotoSizeMedium,
  109. TweetPhotoSizeThumbnail,
  110. } TweetPhotoSizes;
  111. @interface TweetPhoto : NSObject {
  112. NSString * _apiKey;
  113. NSString * _identityToken;
  114. NSString * _identitySecret;
  115. NSString * _serviceName;
  116. BOOL _isoAuth;
  117. NSInteger _statusCode;
  118. NSDictionary * _headerFields;
  119. }
  120. @property BOOL isoAuth; // Does the authentication use oAuth / Basic
  121. @property NSInteger statusCode; // HTTP Status Code
  122. @property (retain,nonatomic) NSString * apiKey; // API Key (Supplied by TweetPhoto)
  123. @property (retain,nonatomic) NSString * identityToken; // Identity Token / User ID
  124. @property (retain,nonatomic) NSString * identitySecret; // Identity Secret / Password
  125. @property (retain,nonatomic) NSString * serviceName; // Service Name (Twitter, Foursquare, Facebook)
  126. @property (retain,nonatomic) NSDictionary * headerFields; // HTTP Response Headers
  127. -(id)initWithSetup:(NSString*)identityToken identitySecret:(NSString*)identitySecret apiKey:(NSString*)apiKey serviceName:(NSString*)serviceName isoAuth:(BOOL)isoAuth;
  128. -(NSDate*)dateFromISO8601:(NSString*)str;
  129. // Add/Delete Comment
  130. -(NSData*)comment:(long long)userId photoId:(long long)photoId comment:(NSString*)comment returnType:(TweetPhotoCommentReturnTypes)returnType;
  131. -(NSInteger)commentDelete:(long long)userId photoId:(long long)photoId commentId:(long long)commentId;
  132. // Delete Photo
  133. -(NSData*)deletePhoto:(long long)photoId returnType:(TweetPhotoDeletePhotoReturnTypes)returnType;
  134. // Add/Delete Favorite
  135. -(NSInteger)favoriteAdd:(long long)userId photoId:(long long)photoId;
  136. -(NSInteger)favoriteDelete:(long long)userId photoId:(long long)photoId;
  137. // Get All Comments for a User
  138. -(NSData*)getComments:(long long)userId returnType:(TweetPhotoCommentsReturnTypes)returnType;
  139. // Get All Comments for a User
  140. -(NSData*)getComments:(long long)userId ind:(int)ind ps:(int)ps sort:(TweetPhotoSorts)sort returnType:(TweetPhotoCommentsReturnTypes)returnType;
  141. // Get Photo Comments
  142. -(NSData*)getPhotoComments:(long long)photoId returnType:(TweetPhotoCommentsReturnTypes)returnType;
  143. // Get Photo Comments
  144. -(NSData*)getPhotoComments:(long long)photoId ind:(int)ind ps:(int)ps sort:(TweetPhotoSorts)sort returnType:(TweetPhotoCommentsReturnTypes)returnType;
  145. // Get User Comments
  146. -(NSData*)getUserComments:(long long)userId returnType:(TweetPhotoCommentsReturnTypes)returnType;
  147. // Get User Comments
  148. -(NSData*)getUserComments:(long long)userId ind:(int)ind ps:(int)ps sort:(TweetPhotoSorts)sort returnType:(TweetPhotoCommentsReturnTypes)returnType;
  149. // Get Favorites
  150. -(NSData*)getFavorites:(long long)userId returnType:(TweetPhotoFavoritesReturnTypes)returnType;
  151. // Get Favorites
  152. -(NSData*)getFavorites:(long long)userId ind:(int)ind ps:(int)ps sort:(TweetPhotoSorts)sort returnType:(TweetPhotoFavoritesReturnTypes)returnType;
  153. // Get Feed
  154. -(NSData*)getFeed:(NSString*)userName feedType:(TweetPhotoFeedTypes)feedType;
  155. // Get Favorites
  156. -(NSData*)getFriends:(long long)userId returnType:(TweetPhotoFriendsReturnTypes)returnType;
  157. // Get Friends
  158. -(NSData*)getFriends:(long long)userId ind:(int)ind ps:(int)ps sort:(TweetPhotoSorts)sort returnType:(TweetPhotoFriendsReturnTypes)returnType;
  159. // Get Leaderboard
  160. -(NSData*)getLeaderboard:(TweetPhotoLeaderboardTypes)leaderboardType returnType:(TweetPhotoLeaderboardReturnTypes)returnType;
  161. // Linked Services
  162. -(NSData*)getLinkedServices;
  163. -(Profiles*)linkedServices;
  164. -(NSData*)linkService:(NSString*)apiKey serviceName:(NSString*)serviceName identityToken:(NSString*)identityToken identitySecret:(NSString*)identitySecret;
  165. -(NSData*)unlinkService:(NSString*)serviceName;
  166. // Get Photos
  167. -(NSData*)getPhotos:(TweetPhotoReturnTypes)returnType;
  168. -(NSData*)getPhotos:(long long)userId returnType:(TweetPhotoReturnTypes)returnType;
  169. -(NSData*)getPhotos:(long long)userId ind:(int)ind ps:(int)ps sf:(TweetPhotoSortFilters)sf tags:(NSString*)tags sort:(TweetPhotoSorts)sort size:(TweetPhotoSizes)size returnType:(TweetPhotoReturnTypes)returnType;
  170. -(NSData*)getNext:(long long)userId photoId:(long long)photoId returnType:(TweetPhotoReturnTypes)returnType;
  171. -(NSData*)getPrevious:(long long)userId photoId:(long long)photoId returnType:(TweetPhotoReturnTypes)returnType;
  172. // Get User Profile
  173. -(NSData*)getUserProfileById:(long long)userId returnType:(TweetPhotoReturnTypes)returnType;
  174. -(NSData*)getUserProfileByName:(NSString*)userName returnType:(TweetPhotoReturnTypes)returnType;
  175. // Get Photo Metadata
  176. -(NSData*)getPhotoMetaData:(long long)photoId returnType:(TweetPhotoPhotoReturnTypes)returnType;
  177. // Get Social (Public)
  178. -(NSData*)getSocial:(int)ps ind:(int)ind sort:(TweetPhotoSorts)sort returnType:(TweetPhotoSocialReturnTypes)returnType;
  179. // Get Social (User Id)
  180. -(NSData*)getSocial:(long long)userid ps:(int)ps ind:(int)ind sort:(TweetPhotoSorts)sort returnType:(TweetPhotoSocialReturnTypes)returnType;
  181. // Get User Settings
  182. -(NSData*)getUserSettings:(long long)userId returnType:(TweetPhotoSettingsReturnTypes)returnType;
  183. // Settings
  184. -(NSData*)setDoNotTweetFavoritePhoto:(long long)userId fave:(BOOL)fave;
  185. -(NSData*)setHideViewingPatterns:(long long)userId hideView:(BOOL)hideView;
  186. -(NSData*)setHideVotes:(long long)userId hideVote:(BOOL)hideVote;
  187. -(NSData*)setMapType:(long long)userId mapType:(int)mapType;
  188. -(NSData*)setPin:(long long)userId pin:(long long)pin;
  189. -(NSData*)setShortenUrl:(long long)userId shorten:(BOOL)shorten;
  190. // Delete / Set Location
  191. -(NSData*)deleteLocation:(long long)photoId returnType:(TweetPhotoLocationReturnTypes)returnType;
  192. -(NSData*)setLocation:(long long)photoId lat:(float)lat lon:(float)lon returnType:(TweetPhotoLocationReturnTypes)returnType;
  193. // API Sign In
  194. -(NSData*)apiSignIn:(TweetPhotoSignInReturnTypes)returnType;
  195. // Upload
  196. -(NSData *)upload:(NSData*)photo comment:(NSString*)message tags:(NSString*)tags latitude:(float)latitude longitude:(float)longitude returnType:(TweetPhotoUploadReturnTypes)returnType;
  197. // Set Photo View
  198. -(NSInteger)photoView:(long long)userId photoId:(long long)photoId;
  199. // Vote thumbs up / thumbs down
  200. -(NSData*)vote:(long long)photoId voteType:(TweetPhotoVoteTypes)voteType returnType:(TweetPhotoVoteReturnTypes)returnType;
  201. // Check to see if a user has voted for a photo
  202. -(NSData*)hasVoted:(long long)userId photoId:(long long)photoId returnType:(TweetPhotoHasVotedReturnTypes)returnType;
  203. // Sign In to TweetPhoto
  204. -(Profile *)signIn;
  205. // User Profile By ID
  206. -(Profile *)userProfileById:(long long)userId;
  207. // User Profile By Name
  208. -(Profile *)userProfileByName:(NSString *)userName;
  209. // Returns User Settings
  210. -(Settings *)userSettings:(long long)userId;
  211. // User Has Voted
  212. -(VoteStatus*)userHasVoted:(long long)userId photoId:(long long)photoId;
  213. // Returns Favorites
  214. -(Favorites*)favorites:(long long)userId;
  215. -(Favorites*)favorites:(long long)userId ind:(int)ind ps:(int)ps sort:(TweetPhotoSorts)sort;
  216. // Returns Photos
  217. -(Photos*)photos;
  218. -(Photos*)photos:(long long)userId;
  219. -(Photos*)photos:(long long)userId ind:(int)ind ps:(int)ps sf:(TweetPhotoSortFilters)sf tags:(NSString*)tags sort:(TweetPhotoSorts)sort size:(TweetPhotoSizes)size;
  220. -(Photo*)photoMetaData:(long long)photoId;
  221. -(Photo*)previous:(long long)userId photoId:(long long)photoId;
  222. -(Photo*)next:(long long)userId photoId:(long long)photoId;
  223. -(Photos*)leaderboard:(TweetPhotoLeaderboardTypes)leaderboardType;
  224. // Returns Profiles of Friends
  225. -(Profiles*)friends:(long long)userId;
  226. -(Profiles*)friends:(long long)userId ind:(int)ind ps:(int)ps sort:(TweetPhotoSorts)sort;
  227. // Returns Comments
  228. -(Comments*)comments:(long long)userId;
  229. -(Comments*)comments:(long long)userId ind:(int)ind ps:(int)ps sortType:(TweetPhotoSorts)sort;
  230. -(Comments*)photoComments:(long long)photoId;
  231. -(Comments*)photoComments:(long long)photoId ind:(int)ind ps:(int)ps sort:(TweetPhotoSorts)sort;
  232. -(Comments*)userComments:(long long)userId;
  233. -(Comments*)userComments:(long long)userId ind:(int)ind ps:(int)ps sort:(TweetPhotoSorts)sort;
  234. // Social Feed (Public)
  235. -(SocialFeed*)social:(int)ps ind:(int)ind sort:(TweetPhotoSorts)sort;
  236. // Social Feed (User Id)
  237. -(SocialFeed*)social:(long long)userId ps:(int)ps ind:(int)ind sort:(TweetPhotoSorts)sort;
  238. // Photo Upload
  239. -(TweetPhotoResponse*)photoUpload:(NSData*)photo comment:(NSString*)message tags:(NSString*)tags latitude:(float)latitude longitude:(float)longitude;
  240. // Helper functions that do the XML serialization heavy lifting
  241. -(Comments*)packageComments:(NSString*)dataStr;
  242. -(Favorites*)packageFavorites:(NSString*)dataStr;
  243. -(Photo*)packagePhoto:(NSString*)dataStr;
  244. -(Photos*)packagePhotos:(NSString*)dataStr;
  245. -(Profile*)packageProfile:(NSString*)dataStr;
  246. -(Profiles*)packageProfiles:(NSString*)dataStr;
  247. -(TweetPhotoResponse*)packageResponse:(NSString*)dataStr;
  248. -(Settings*)packageSettings:(NSString*)dataStr;
  249. -(SocialFeed*)packageSocialFeed:(NSString*)dataStr;
  250. -(VoteStatus*)packageVoteStatus:(NSString*)dataStr;
  251. @end