Official library for AssetZen.
gem 'assetzen'
gem install assetzen
You will need to create an application in order to use the API. You will also need to get and store a user access grant in order to make API calls. This is not handled by the library as it is specific to the application, as you will need to provide a callback in your application to redirect the user once they approve authorization, and a secure storage mechanism for the granted tokens.
require 'assetzen'
@client = AssetZen::API::Client.new do |config|
config.credentials = some_method_to_get_credentials
end
images = @client.images(q: 'food')
@client = some_method_to_get_client # see previous example
image = @client.images(q: 'food').sample # Sample random match
url = image.signed_link(width: 800, height: 600)
image_tag href: url
@client = some_method_to_get_client # see first example
image = @client.image('example') # get image with ID 'example'
image.title = "My new image title"
image.save