Tosuto
Gem for interfacing with Toast's API.
Installation
Add this line to your application's Gemfile:
gem 'tosuto'
And then execute:
$ bundle
Or install it yourself as:
$ gem install tosuto
Usage
Get a token
token = Tosuto::OauthToken.create(client_id, client_secret)
Get all orders created on a date
orders = Tosuto::Order.all(
restaurant_id: restaurant_id,
token: token,
business_date: Date.today,
)
order = orders.first.get_details(token: token)
Get an order by guid
order = Tosuto::Orders.get(
guid: guid,
restaurant_id: restaurant_id,
token: token,
)
Get an order's dining option
order = Tosuto::Orders.get(
guid: guid,
restaurant_id: restaurant_id,
token: token,
)
order.dining_option.get_details(token: token, restaurant_id: order.restaurant_id)
if order.dining_option.take_out?
puts "This is a take-out order"
end
Setting the Toast host URL
Tosuto defaults to the sandbox Toast host URL: https://ws-sandbox-api.eng.toasttab.com
This can be overridden globally by setting the TOAST_HOST
environment variable. Or, to set the Toast host URL on a per-request basis just pass in a Tosuto::API
object with the preferred host:
token = Tosuto::OauthToken.create(
client_id,
client_secret,
api: Tosuto::API.new("https://example.org")
)
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/radiusnetworks/tosuto. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Tosuto project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.