Permalink
Browse files

Added method to update an existing list with the listID

  • Loading branch information...
1 parent 5d4b723 commit 1ffd92e65b1189bda56bdb1ff1561342efcfa0b2 @catsby catsby committed with alexrepty Aug 14, 2010
Showing with 30 additions and 0 deletions.
  1. +3 −0 MGTwitterEngine.h
  2. +27 −0 MGTwitterEngine.m
View
@@ -145,6 +145,9 @@
// description - The description to give the list.
- (NSString *)createListForUser:(NSString *)username withName:(NSString *)listName withOptions:(NSDictionary *)options;
+// update an existing list
+- (NSString *)updateListForUser:(NSString *)username withID:(MGTwitterEngineID)listID withOptions:(NSDictionary *)options;
+
// Direct Message methods
- (NSString *)getDirectMessagesSinceID:(MGTwitterEngineID)sinceID startingAtPage:(int)pageNum; // direct_messages
View
@@ -1584,6 +1584,33 @@ - (NSString *)createListForUser:(NSString *)username withName:(NSString *)listNa
responseType:MGTwitterUserLists];
}
+- (NSString *)updateListForUser:(NSString *)username withID:(MGTwitterEngineID)listID withOptions:(NSDictionary *)options
+{
+ if (!username || !listID) {
+ NSLog(@"returning nil");
+ return nil;
+ }
+ NSString *path = [NSString stringWithFormat:@"%@/lists/%llu.%@", username, listID, API_FORMAT];
+
+ NSMutableDictionary *queryParameters = [NSMutableDictionary dictionaryWithCapacity:0];
+ if ([options objectForKey:@"name"]) {
+ [queryParameters setObject:[options objectForKey:@"name"] forKey:@"name"];
+ }
+ if ([options objectForKey:@"mode"]) {
+ [queryParameters setObject:[options objectForKey:@"mode"] forKey:@"mode"];
+ }
+ if ([options objectForKey:@"description"]) {
+ [queryParameters setObject:[options objectForKey:@"description"] forKey:@"description"];
+ }
+
+ NSString *body = [self _queryStringWithBase:nil parameters:queryParameters prefixed:NO];
+
+ return [self _sendRequestWithMethod:HTTP_POST_METHOD path:path
+ queryParameters:queryParameters body:body
+ requestType:MGTwitterUserListCreate
+ responseType:MGTwitterUserLists];
+}
+
#pragma mark Friendship methods

0 comments on commit 1ffd92e

Please sign in to comment.