Module: Twitter::REST::Favorites
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#favorite(*args) ⇒ Array<Twitter::Tweet>
(also: #fav, #fave)
Favorites the specified Tweets as the authenticating user.
-
#favorite!(*args) ⇒ Array<Twitter::Tweet>
(also: #create_favorite!, #fav!, #fave!)
Favorites the specified Tweets as the authenticating user and raises an error if one has already been favorited.
-
#favorites(*args) ⇒ Array<Twitter::Tweet>
Favorite Tweets.
-
#unfavorite(*args) ⇒ Array<Twitter::Tweet>
(also: #destroy_favorite)
Un-favorites the specified Tweets as the authenticating user.
-
#unfavorite!(*args) ⇒ Array<Twitter::Tweet>
Un-favorites the specified Tweets as the authenticating user and raises an error if one is not found.
Methods included from Utils
Instance Method Details
#favorite(*tweets) ⇒ Array<Twitter::Tweet> #favorite(*tweets, options) ⇒ Array<Twitter::Tweet> Also known as: fav, fave
Favorites the specified Tweets as the authenticating user
89 90 91 92 93 94 95 96 |
# File 'lib/twitter/rest/favorites.rb', line 89 def favorite(*args) arguments = Twitter::Arguments.new(args) pmap(arguments) do |tweet| perform_post_with_object("/1.1/favorites/create.json", arguments..merge(id: extract_id(tweet)), Twitter::Tweet) rescue Twitter::Error::AlreadyFavorited, Twitter::Error::NotFound next end.compact end |
#favorite!(*tweets) ⇒ Array<Twitter::Tweet> #favorite!(*tweets, options) ⇒ Array<Twitter::Tweet> Also known as: create_favorite!, fav!, fave!
Favorites the specified Tweets as the authenticating user and raises an error if one has already been favorited
114 115 116 117 118 119 |
# File 'lib/twitter/rest/favorites.rb', line 114 def favorite!(*args) arguments = Twitter::Arguments.new(args) pmap(arguments) do |tweet| perform_post_with_object("/1.1/favorites/create.json", arguments..merge(id: extract_id(tweet)), Twitter::Tweet) end end |
#favorites(options = {}) ⇒ Array<Twitter::Tweet> #favorites(user, options = {}) ⇒ Array<Twitter::Tweet>
Returns favorite Tweets.
32 33 34 35 36 |
# File 'lib/twitter/rest/favorites.rb', line 32 def favorites(*args) arguments = Twitter::Arguments.new(args) merge_user!(arguments., arguments.pop) if arguments.last perform_get_with_objects("/1.1/favorites/list.json", arguments., Twitter::Tweet) end |
#unfavorite(*tweets) ⇒ Array<Twitter::Tweet> #unfavorite(*tweets, options) ⇒ Array<Twitter::Tweet> Also known as: destroy_favorite
Un-favorites the specified Tweets as the authenticating user
50 51 52 53 54 55 56 57 |
# File 'lib/twitter/rest/favorites.rb', line 50 def unfavorite(*args) arguments = Twitter::Arguments.new(args) pmap(arguments) do |tweet| perform_post_with_object("/1.1/favorites/destroy.json", arguments..merge(id: extract_id(tweet)), Twitter::Tweet) rescue Twitter::Error::NotFound next end.compact end |
#unfavorite!(*tweets) ⇒ Array<Twitter::Tweet> #unfavorite!(*tweets, options) ⇒ Array<Twitter::Tweet>
Un-favorites the specified Tweets as the authenticating user and raises an error if one is not found
73 74 75 |
# File 'lib/twitter/rest/favorites.rb', line 73 def unfavorite!(*args) parallel_objects_from_response(Twitter::Tweet, :post, "/1.1/favorites/destroy.json", args) end |