Module: Instagram::Client::Users

Included in:
Instagram::Client
Defined in:
lib/instagram/client/users.rb

Overview

Defines methods related to users

Instance Method Summary collapse

Instance Method Details

#user(id = nil, options = {}) ⇒ Hashie::Mash

Returns extended information of a given user

Returns The requested user.

Examples:

Return extended information for @shayne

Instagram.user(20)

Parameters:

  • user (Integer)

    An Instagram user ID

Returns:

  • (Hashie::Mash)

    The requested user.

See Also:

  • url


18
19
20
21
22
# File 'lib/instagram/client/users.rb', line 18

def user(*args)
  id = args.first || 'self'
  response = get("users/#{id}")
  response["data"]
end

#user_follows(id = nil, options = {}) ⇒ Hashie::Mash #user_follows(id = nil, options = {}) ⇒ Hashie::Mash

Returns a list of users whom a given user follows

Overloads:

  • #user_follows(id = nil, options = {}) ⇒ Hashie::Mash

    Examples:

    Returns a list of users the authenticated user follows

    Instagram.user_follows

    Parameters:

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

      A customizable set of options.

    Returns:

    • (Hashie::Mash)
  • #user_follows(id = nil, options = {}) ⇒ Hashie::Mash

    Examples:

    Return a list of users @mikeyk follows

    Instagram.user_follows(4) # @mikeyk user ID being 4

    Parameters:

    • user (Integer)

      An Instagram user ID.

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: nil

      Breaks the results into pages. Provide values as returned in the response objects’s next_cursor attribute to page forward in the list.

    • :count (Integer) — default: nil

      Limits the number of results returned per page.

    Returns:

    • (Hashie::Mash)

See Also:

  • url


62
63
64
65
66
67
# File 'lib/instagram/client/users.rb', line 62

def user_follows(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  id = args.first || "self"
  response = get("users/#{id}/follows", options)
  response["data"]
end

#user_search(query, options = {}) ⇒ Array

Returns users that match the given query

Examples:

Return users that match “Shayne Sweeney”

Instagram.user_search("Shayne Sweeney")

Parameters:

  • query (String)

    The search query to run against user search.

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

    A customizable set of options.

Options Hash (options):

  • :count (Integer)

    The number of users to retrieve.

Returns:

  • (Array)

See Also:

  • url


36
37
38
39
# File 'lib/instagram/client/users.rb', line 36

def user_search(query, options={})
  response = get('users/search', options.merge(:q => query))
  response["data"]
end