Module: Twitter::REST::Favorites

Includes:
Utils, Utils
Included in:
API
Defined in:
lib/twitter/rest/favorites.rb

Constant Summary

Constant Summary

Constants included from Utils

Utils::DEFAULT_CURSOR, Utils::URI_SUBSTRING

Instance Method Summary (collapse)

Methods included from Utils

flat_pmap, pmap

Instance Method Details

- (Array<Twitter::Tweet>) favorite(*tweets) - (Array<Twitter::Tweet>) favorite(*tweets, options) Also known as: fav, fave

Favorites the specified Tweets as the authenticating user

Raises:

See Also:

Rate Limited?:

  • No

Authentication:

  • Requires user context



69
70
71
72
73
74
75
76
77
78
# File 'lib/twitter/rest/favorites.rb', line 69

def favorite(*args)
  arguments = Twitter::Arguments.new(args)
  pmap(arguments) do |tweet|
    begin
      perform_with_object(:post, '/1.1/favorites/create.json', arguments.options.merge(:id => extract_id(tweet)), Twitter::Tweet)
    rescue Twitter::Error::AlreadyFavorited, Twitter::Error::NotFound
      next
    end
  end.compact
end

- (Array<Twitter::Tweet>) favorite!(*tweets) - (Array<Twitter::Tweet>) favorite!(*tweets, options) 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

Raises:

See Also:

Rate Limited?:

  • No

Authentication:

  • Requires user context



97
98
99
100
101
102
# File 'lib/twitter/rest/favorites.rb', line 97

def favorite!(*args)
  arguments = Twitter::Arguments.new(args)
  pmap(arguments) do |tweet|
    perform_with_object(:post, '/1.1/favorites/create.json', arguments.options.merge(:id => extract_id(tweet)), Twitter::Tweet)
  end
end

- (Array<Twitter::Tweet>) favorites(options = {}) - (Array<Twitter::Tweet>) favorites(user, options = {})

Returns favorite Tweets.

Overloads:

  • - (Array<Twitter::Tweet>) favorites(options = {})

    Returns the 20 most recent favorite Tweets for the authenticating user

    Options Hash (options):

    • :count (Integer)

      Specifies the number of records to retrieve. Must be less than or equal to 100.

    • :since_id (Integer)

      Returns results with an ID greater than (that is, more recent than) the specified ID.

  • - (Array<Twitter::Tweet>) favorites(user, options = {})

    Returns the 20 most recent favorite Tweets for the specified user

    Options Hash (options):

    • :count (Integer)

      Specifies the number of records to retrieve. Must be less than or equal to 100.

    • :since_id (Integer)

      Returns results with an ID greater than (that is, more recent than) the specified ID.

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



33
34
35
36
37
# File 'lib/twitter/rest/favorites.rb', line 33

def favorites(*args)
  arguments = Twitter::Arguments.new(args)
  merge_user!(arguments.options, arguments.pop) if arguments.last
  perform_with_objects(:get, '/1.1/favorites/list.json', arguments.options, Twitter::Tweet)
end

- (Array<Twitter::Tweet>) unfavorite(*tweets) - (Array<Twitter::Tweet>) unfavorite(*tweets, options) Also known as: destroy_favorite

Un-favorites the specified Tweets as the authenticating user

Raises:

See Also:

Rate Limited?:

  • No

Authentication:

  • Requires user context



51
52
53
# File 'lib/twitter/rest/favorites.rb', line 51

def unfavorite(*args)
  parallel_objects_from_response(Twitter::Tweet, :post, '/1.1/favorites/destroy.json', args)
end