2 # Why Twitter.com developers can't correctly document their API, I do not know!
4 :add => '/favourings/create',
5 :remove => '/favourings/destroy',
8 # Provides access to the Twitter list favorites API.
10 # You can access the authenticated [Twitter] user's favorites list using this method.
12 # By default you will receive the last twenty statuses added to your favorites list.
13 # To get a previous page you can provide options to this method. For example,
14 # statuses = client.favorites(:page => 2)
15 # The above one-liner will get the second page of favorites for the authenticated user.
16 def favorites(options = nil)
17 def uri_suffix(opts); opts && opts[:page] ? "?page=#{opts[:page]}" : ""; end
18 uri = '/favorites.json' + uri_suffix(options)
19 response = http_connect {|conn| create_http_get_request(uri) }
20 bless_models(Twitter::Status.unmarshal(response.body))
23 # Provides access to the Twitter add/remove favorite API.
25 # You can add and remove favorite status using this method.
27 # <tt>action</tt> can be any of the following values:
28 # * <tt>:add</tt> - to add a status to your favorites, you would use this <tt>action</tt> value
29 # * <tt>:remove</tt> - to remove an status from your existing favorites list use this.
31 # The <tt>value</tt> must be either the status object to add or remove or
32 # the integer unique status ID.
36 # client.favorite(:add, id)
37 # client.favorite(:remove, id)
38 # status = Twitter::Status.find(id, client)
39 # client.favorite(:add, status)
40 # client.favorite(:remove, status)
41 def favorite(action, value)
42 raise ArgumentError, "Invalid favorite action provided: #{action}" unless @@FAVORITES_URIS.keys.member?(action)
43 value = value.to_i.to_s unless value.is_a?(String)
44 uri = "#{@@FAVORITES_URIS[action]}/#{value}.json"
47 response = http_connect {|conn| create_http_post_request(uri) }
49 response = http_connect {|conn| create_http_delete_request(uri) }
51 bless_model(Twitter::Status.unmarshal(response.body))