Configuring the Ruby API client library
The following guide shows you how to configure Bootic’s official Ruby API client.
If your Ruby project uses Bundler for dependency management, make sure to include the gem in your
1. Configure the client.
You must first create an OAuth Application in Bootic’s developer portal. Once done that, use the application’s
client_secret to configure your client instance.
BooticClient.configure do |c| c.client_id = 'MY_CLIENT_ID' c.client_secret = 'MY_CLIENT_SECRET' c.logger = Logger.new(STDOUT) # optional c.logging = true # optional c.cache_store = Rails.cache # optional end
We recommend that you setup caching for production usage, for example using Memcache. See the client library’s documentation for more information.
2. Instantiate the client
Server to server scripts.
The following creates a Bootic client instance for server-to-server scripts.
client = BooticClient.client(:client_credentials, scope: 'admin')
User tokens (web apps)
If you’re using the client in the context of a web app or you have a user’s access token:
client = BooticClient.client(:authorized, access_token: session[:access_token], scope: 'admin') do |new_token| # optionally store new token for later use session[:access_token] = new_token end
You can read this guide for a full tutorial on using the library in a Ruby on Rails web application.
3. Use it!
Now you have a fully authorized instance of the API client, which you can use to interact with the Bootic API.
# root resource root = client.root # your default shop shop = root.shops.first # list your products shop.products.full_set.each do |product| puts product.title end
Read the Ruby guides in this section to learn more, or read the library’s documentation for more details.