3 :add => '/friendships/create',
4 :remove => '/friendships/destroy',
7 # Provides access to the Twitter Friendship API.
9 # You can add and remove friends using this method.
11 # <tt>action</tt> can be any of the following values:
12 # * <tt>:add</tt> - to add a friend, you would use this <tt>action</tt> value
13 # * <tt>:remove</tt> - to remove an existing friend from your friends list use this.
15 # The <tt>value</tt> must be either the user to befriend or defriend's
16 # screen name, integer unique user ID or Twitter::User object representation.
19 # screen_name = 'dictionary'
20 # client.friend(:add, 'dictionary')
21 # client.friend(:remove, 'dictionary')
23 # client.friend(:add, id)
24 # client.friend(:remove, id)
25 # user = Twitter::User.find(id, client)
26 # client.friend(:add, user)
27 # client.friend(:remove, user)
28 def friend(action, value)
29 raise ArgumentError, "Invalid friend action provided: #{action}" unless @@FRIENDSHIP_URIS.keys.member?(action)
30 value = value.to_i unless value.is_a?(String)
31 uri = "#{@@FRIENDSHIP_URIS[action]}/#{value}.json"
32 response = http_connect {|conn| create_http_get_request(uri) }
33 bless_model(Twitter::User.unmarshal(response.body))