Class: Zootool::UsersQuery
- Defined in:
- lib/zootool/users_query.rb
Overview
Performs User queries to the Zootool API.
Usage: You don’t need to create an object of this class directly. Instead use the users method on your ZootoolApi object.
See zootool.com/api/docs/users for Users API documentation.
Instance Attribute Summary collapse
-
#username ⇒ Object
The username of the user for which the API should return results.
Attributes inherited from ZooQuery
Instance Method Summary collapse
-
#followers(*args) ⇒ Object
Returns a list of followers for a specific user.
-
#friends(*args) ⇒ Object
Returns a list of friends for a specific user.
-
#info ⇒ Object
Returns info about a certain user.
-
#initialize(api, username) ⇒ UsersQuery
constructor
Initializes the UsersQuery.
-
#items(*args) ⇒ Object
Requests and returns the items for a specific user.
-
#profiles ⇒ Object
Returns a list of external profiles for a user.
-
#validate ⇒ Object
Not implemented yet.
Methods inherited from ZooQuery
#args_to_hash, #build_query_string
Constructor Details
#initialize(api, username) ⇒ UsersQuery
Initializes the UsersQuery.
18 19 20 21 |
# File 'lib/zootool/users_query.rb', line 18 def initialize api, username @api = api @username = username end |
Instance Attribute Details
#username ⇒ Object
The username of the user for which the API should return results.
15 16 17 |
# File 'lib/zootool/users_query.rb', line 15 def username @username end |
Instance Method Details
#followers(*args) ⇒ Object
Returns a list of followers for a specific user. If username is nil or empty, the API will return an error.
Optional Supported Arguments: offset, limit, search
Returns an array of hashes containing user info.
90 91 92 93 94 |
# File 'lib/zootool/users_query.rb', line 90 def followers *args hash = args_to_hash(args) hash[:username] = @username @api.request("users/followers/?#{build_query_string(hash)}") end |
#friends(*args) ⇒ Object
Returns a list of friends for a specific user. If username is nil or empty, the API will return an error.
Optional Supported Arguments: offset, limit, search
Returns an array of hashes containing user info.
77 78 79 80 81 |
# File 'lib/zootool/users_query.rb', line 77 def friends *args hash = args_to_hash(args) hash[:username] = @username @api.request("users/friends/?#{build_query_string(hash)}") end |
#info ⇒ Object
Returns info about a certain user. If username is nil or empty, the API will return an error.
Returns a hash containing the info for a user. The hash keys (as of the current version of the API) include:
- username: the username of the user
- website: the url of the user's website
- avatar: the url of the user's avatar image
- profile: the url of the user's profile
65 66 67 68 |
# File 'lib/zootool/users_query.rb', line 65 def info hash = {:username => @username} @api.request("users/info/?#{build_query_string(hash)}") end |
#items(*args) ⇒ Object
Requests and returns the items for a specific user. Private items will be returned if authenticated. If username is nil or empty, items for all users will be returned.
Optional Supported Arguments: tag, offset, limit
Returns an array of zero or more hashes where each hash contains the info for an item. The hash keys (as of the current version of the API) include:
- uid: the unique id of the item
- title: the title of the item
- url: the url of the item
- added: when the item was added
- type: the type of the item (page, etc.)
- views: the number of views for the item (a string)
- likes: the number of likes the item has received (a string)
- comments: the number of comments the item has received (a string)
- permalink: the url of the permalink for the item
- tinyurl: a tiny url for linking to the item
- thumbnail: the url of the thumbnail for the item
- image: the url of the image for the item
- referer: the page from which the item was captured
- description: a description of the item
- tags: an array of tags for the item
- inthezoo: a boolean
- public: a boolean indicating whether or not the item is public
49 50 51 52 53 |
# File 'lib/zootool/users_query.rb', line 49 def items *args hash = args_to_hash(args) hash[:username] = @username unless @username.nil? || @username.empty? @api.request("users/items/?#{build_query_string(hash)}") end |
#profiles ⇒ Object
Returns a list of external profiles for a user. If username is nil or empty, the API will return an error.
Returns an array of hashes where each hash contains info for a user’s profile on an external site, including the following info: slug, url, title
102 103 104 105 |
# File 'lib/zootool/users_query.rb', line 102 def profiles hash = {:username => @username} @api.request("users/profiles/?#{build_query_string(hash)}") end |
#validate ⇒ Object
Not implemented yet.
109 110 111 |
# File 'lib/zootool/users_query.rb', line 109 def validate return nil end |