Module: Twitter::Client::Favorites

Included in:
Twitter::Client
Defined in:
lib/twitter/client/favorites.rb

Overview

Defines methods related to favorites (or favourites)

Instance Method Summary collapse

Instance Method Details

#favorite(id, options = {}) ⇒ Twitter::Status Also known as: favorite_create

Favorites the specified status as the authenticating user

Examples:

Favorite the status with the ID 25938088801

Twitter.favorite(25938088801)

Parameters:

  • id (Integer)

    The numerical ID of the desired status.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :include_entities (Boolean, String, Integer)

    Include Tweet Entities when set to true, 't' or 1.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



56
57
58
59
# File 'lib/twitter/client/favorites.rb', line 56

def favorite(id, options={})
  status = post("/1/favorites/create/#{id}.json", options)
  Twitter::Status.new(status)
end

#favorites(options = {}) ⇒ Array<Twitter::Status> #favorites(user, options = {}) ⇒ Array<Twitter::Status>

Overloads:

  • #favorites(options = {}) ⇒ Array<Twitter::Status>

    Returns the 20 most recent favorite statuses for the authenticating user

    Examples:

    Return the 20 most recent favorite statuses for the authenticating user

    Twitter.favorites

    Parameters:

    • options (Hash) (defaults to: {})

      A customizable set of options.

    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.

    • :page (Integer)

      Specifies the page of results to retrieve.

    • :include_entities (Boolean, String, Integer)

      Include Tweet Entities when set to true, 't' or 1.

    Returns:

  • #favorites(user, options = {}) ⇒ Array<Twitter::Status>

    Returns the 20 most recent favorite statuses for the specified user

    Examples:

    Return the 20 most recent favorite statuses for @sferik

    Twitter.favorites("sferik")

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • options (Hash) (defaults to: {})

      A customizable set of options.

    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.

    • :page (Integer)

      Specifies the page of results to retrieve.

    Returns:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • No



33
34
35
36
37
38
39
40
41
42
# File 'lib/twitter/client/favorites.rb', line 33

def favorites(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  if user = args.first
    get("/1/favorites/#{user}.json", options)
  else
    get("/1/favorites.json", options)
  end.map do |status|
    Twitter::Status.new(status)
  end
end

#unfavorite(id, options = {}) ⇒ Twitter::Status Also known as: favorite_destroy

Un-favorites the specified status as the authenticating user

Examples:

Un-favorite the status with the ID 25938088801

Twitter.unfavorite(25938088801)

Parameters:

  • id (Integer)

    The numerical ID of the desired status.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :include_entities (Boolean, String, Integer)

    Include Tweet Entities when set to true, 't' or 1.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



74
75
76
77
# File 'lib/twitter/client/favorites.rb', line 74

def unfavorite(id, options={})
  status = delete("/1/favorites/destroy/#{id}.json", options)
  Twitter::Status.new(status)
end