class Zootool::ZootoolApi
A wrapper that provides access to the Zootool
API.
Attributes
The API key for your Zootool
application. Set when creating a new ZootoolApi
.
Public Class Methods
Initializes the ZootoolApi
object for making requests. You must specify your Zootool
Application API key for requests to return data successfully.
Example:
api = Zootool::ZootoolApi.new('your_api_key_goes_here')
# File lib/zootool/zootool_api.rb, line 23 def initialize api_key @api_key = api_key end
Public Instance Methods
Provides a simple way to get a specific item by its uid. This is just shorthand for the longer api.items.info method.
Example:
api = Zootool::ZootoolApi.new('apikey') item_by_uid = api.item('1kf7s')
# File lib/zootool/zootool_api.rb, line 51 def item uid self.items.info(uid) end
Provides a simple way to get items.
Example:
api = Zootool::ZootoolApi.new('apikey') items = api.items.popular('week') item_by_uid = api.items.info('1kf7s')
# File lib/zootool/zootool_api.rb, line 63 def items Zootool::ItemsQuery.new(self) end
Makes a request to the specified path and returns a Hash containing the result of the HTTP request.
# File lib/zootool/zootool_api.rb, line 70 def request(path) url = "#{Zootool::API_URL}#{path}&apikey=#{@api_key}" self.class.get(url).parsed_response end
Provides a simple way to get Zootool
items and info for users.
Returns a UsersQuery
that provides methods to easily access the items and other info for users. The methods of the returned UsersQuery
return a
Example:
api = Zootool::ZootoolApi.new('your_api_key') user_items = api.users('rmauer').items all_items = api.users.items all_paged = api.users.items(:limit => 5, :offset => 10)
# File lib/zootool/zootool_api.rb, line 39 def users username=nil Zootool::UsersQuery.new(self,username) end