Module: Tuiter::FriendshipMethods
- Included in:
- Client
- Defined in:
- lib/tuiter/methods/friendship.rb
Instance Method Summary collapse
- #friendships_create(user, follow = nil) ⇒ Object
- #friendships_destroy(user) ⇒ Object
- #friendships_exists?(id) ⇒ Boolean
Instance Method Details
#friendships_create(user, follow = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tuiter/methods/friendship.rb', line 10 def friendships_create(user, follow = nil) log("friendship_new() following: #{user}") res = @request_handler.post("/friendships/create/#{user}.json", (follow ? {'follow'=>"true"} : "" )) case res when Net::HTTPSuccess, Net::HTTPRedirection log("friendship_new() success: OK") return res # OK else log("friendship_new() error: #{res.error!}") res.error! end end |
#friendships_destroy(user) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tuiter/methods/friendship.rb', line 23 def friendships_destroy(user) log("friendship_new() following: #{user}") res = @request_handler.post("/friendships/destroy/#{user}.json") case res when Net::HTTPSuccess, Net::HTTPRedirection log("remove_friendship() success: OK") return res # OK else log("remove_friendship() error: #{res.error!}") res.error! end end |
#friendships_exists?(id) ⇒ Boolean
36 37 38 39 40 41 42 43 |
# File 'lib/tuiter/methods/friendship.rb', line 36 def friendships_exists?(id) if res = @request_handler.get("http://twitter.com/friendships/exists.json?user_a=#{id}&user_b=#{@username}").body return true if res == "true" return false else return nil end end |