Author: vdichev
Date: Thu Mar  5 21:29:19 2009
New Revision: 750596

URL: http://svn.apache.org/viewvc?rev=750596&view=rev
Log:
Twitter API: get friends/followers of specified user

Modified:
    
incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala

Modified: 
incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala
URL: 
http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala?rev=750596&r1=750595&r2=750596&view=diff
==============================================================================
--- 
incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala 
(original)
+++ 
incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala 
Thu Mar  5 21:29:19 2009
@@ -84,7 +84,9 @@
     case Req(l: List[String], this.method, PostRequest) if l == ApiPath ::: 
"statuses" :: "update" :: Nil => update
 
     case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: 
"statuses" :: "friends" :: Nil => friends
+    case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: 
"statuses" :: "friends" :: l.last :: Nil => () => friends(l last)
     case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: 
"statuses" :: "followers" :: Nil => followers
+    case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: 
"statuses" :: "followers" :: l.last :: Nil => () => followers(l last)
     case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: 
"users" :: "show" :: l.last :: Nil => () => showUser(l last)
 
     case Req(l: List[String], this.method, PostRequest) if l == ApiPath ::: 
"friendships" :: "create" :: l.last :: Nil => () => createFriendship(l last)
@@ -185,11 +187,11 @@
   }
   
   def userTimeline(userName: String): Box[TwitterResponse] = {
-    User.findFromWeb(userName) map (userTimeline(_))
+    User.findFromWeb(userName) map (userTimeline)
   }
   
   def userTimeline(): Box[TwitterResponse] = {
-    calcUser map (userTimeline(_))
+    calcUser map (userTimeline)
   }
   
   def replies(): Box[TwitterResponse] = {
@@ -221,18 +223,28 @@
     }
   }
 
+  def friends(user: User): TwitterResponse = {
+    Right(Map("users" -> ("user", user.following().map(userData)) ))
+  }
+  
+  def friends(userName: String): Box[TwitterResponse] = {
+    User.findFromWeb(userName) map(friends)
+  }
+  
   def friends(): Box[TwitterResponse] = {
-    for (user <- calcUser ?~ "User not found")
-    yield {
-      Right(Map("users" -> ("user", user.following().map(userData)) ))
-    }
+    calcUser map(friends)
+  }
+  
+  def followers(user: User): TwitterResponse = {
+    Right(Map("users" -> ("user", user.followers().map(userData)) ))
+  }
+  
+  def followers(userName: String): Box[TwitterResponse] = {
+    User.findFromWeb(userName) map(followers)
   }
   
   def followers(): Box[TwitterResponse] = {
-    for (user <- calcUser ?~ "User not found")
-    yield {
-      Right(Map("users" -> ("user", user.followers().map(userData)) ))
-    }
+    calcUser map(followers)
   }
   
   def showUser(name: String): Box[TwitterResponse] = {


Reply via email to