Doshii
A Doshii API wrapper gem. Refer to alphasandbox.doshii.co for Doshii's official API documentation.
Installation
Add this line to your application's Gemfile:
gem 'doshii'
or
gem 'doshii', :git => 'https://github.com/devrc-trise/doshii.git', :branch => 'develop'
And then execute:
$ bundle
Or install it yourself as:
$ gem install doshii
rock'n'roll
Usage
There are two ways to use Doshii:
- System wide shared configuration
- Per instance configuration
1. System wide shared configuration
Run this to create configuration file config/initializers/doshii.rb
:
$ rails g doshii:install
Change config/initializers/doshii.rb
as necessary. You might want to set values in system env or environment files to differentiate development, test and production setup:
Doshii.configure do |config|
# you might want to set these values in environment files
config.client_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
config.client_secret = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
config.base_url = 'https://alphasandbox.doshii.co'
config.verify_ssl = false
config.version = 'v1'
end
CHECKINS
DELETE /checkins/:checkinId
Doshii.checkin.delete :checkin_id
GET /checkins/:checkinId
Doshii.checkin.find :checkin_id
POST /checkins/:locationId
Doshii.checkin.create :location_id do |params|
params[:name] = 'John Smith'
params[:externalId] = 'ias2kk2'
params[:photoURL] = 'http://example.com/profile.png'
end
or
checkin_params = {
name: 'John Smith',
externalId: 'ias2kk2',
photoURL: 'http://example.com/profile.png'
}
Doshii.checkin.create :location_id do |param|
params.merge!(checkin_params)
end
POST /checkins/:checkinId/table
Doshii.checkin.create "#{:checkin_id}/table" do |params|
params[:name] = '3'
end
PUT /checkins/:checkinId
client.checkin.update :checkin_id do |params|
params[:status] = 'left'
end
LOCATIONS
GET /locations
Doshii.location.all
POST /locations
Doshii.location.create do |params|
params[:name] = 'Chickens R Us'
params[:mobility] = 'fixed'
params[:availability] = 'closed'
params[:address_line1] = '608 St Kilda Rd'
# see the official api page for complete list of available params
end
ORDERS
GET /orders/:orderId
Doshii.order.find :order_id
POST /orders/:checkinId
Doshii.order.create :checkin_id do |params|
params[:status] = 'pending'
params[:items] = [
{
name: 'Toasted Sourdough Bread & Eggs'
description: 'Just ye old classic'
# ...
}
# ...
]
# see the official api page for complete list of available params
end
PUT /orders/:orderId
# sample - consumer wants to pay
Doshii.order.update :order_id do |params|
params[:tip] = '0'
params[:status] = 'ready to pay'
params[:updatedAt] = '2015-05-20T23:32:58.526Z'
end
# sample - payment has been processed and order is updated to paid
Doshii.order.update :order_id do |params|
params[:tip] = '0'
params[:status] = 'ready to pay'
params[:updatedAt] = '2015-05-20T23:32:58.526Z'
params[:transactionId] = '123'
params[:invoiceId] = '123'
end
PRODUCTS
GET /products/:locationId
Doshii.product.find :location_id
TABLES
GET /tables/:tableId
Doshii.table.find :table_id
2. Per instance configuration
Pass configuration when defining new instance
client = Doshii::Client.new(
client_id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
client_secret: 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy',
base_url: 'https://alphasandbox.doshii.co', #default
verify_ssl: false, #default
version: 'v1' #default
)
CHECKINS
DELETE /checkins/:checkinId
client.delete_checkin :checkin_id
GET /checkins/:checkinId
client.get_checkin :checkin_id
POST /checkins/:locationId
client.create_checkin :location_id do |params|
params[:name] = 'John Smith'
params[:externalId] = 'ias2kk2'
params[:photoURL] = 'http://example.com/profile.png'
end
or
checkin_params = {
name: 'John Smith',
externalId: 'ias2kk2',
photoURL: 'http://example.com/profile.png'
}
client.create_checkin :location_id do |param|
params.merge!(checkin_params)
end
POST /checkins/:checkinId/table
client.allocate_table "#{:checkin_id}/table" do |params|
params[:name] = '3'
end
PUT /checkins/:checkinId
client.update_checkin :checkin_id do |params|
params[:status] = 'left'
end
LOCATIONS
GET /locations
client.list_locations
POST /locations
client.create_location do |params|
params[:name] = 'Chickens R Us'
params[:mobility] = 'fixed'
params[:availability] = 'closed'
params[:address_line1] = '608 St Kilda Rd'
# see the official api page for complete list of available params
end
ORDERS
GET /orders/:orderId
client.get_order :order_id
POST /orders/:checkinId
client.create_order :checkin_id do |params|
params[:status] = 'pending'
params[:items] = [
{
name: 'Toasted Sourdough Bread & Eggs'
description: 'Just ye old classic'
# ...
}
# ...
]
# see the official api page for complete list of available params
end
PUT /orders/:orderId
# sample - consumer wants to pay
client.update_order :order_id do |params|
params[:tip] = '0'
params[:status] = 'ready to pay'
params[:updatedAt] = '2015-05-20T23:32:58.526Z'
end
# sample - payment has been processed and order is updated to paid
client.update_order :order_id do |params|
params[:tip] = '0'
params[:status] = 'ready to pay'
params[:updatedAt] = '2015-05-20T23:32:58.526Z'
params[:transactionId] = '123'
params[:invoiceId] = '123'
end
PRODUCTS
GET /products/:locationId
client.list_products :location_id
TABLES
GET /tables/:tableId
client.get_table :table_id
Development
After checking out the repo, run bin/setup
to install dependencies. Then, 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
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
- Fork it ( https://github.com/[my-github-username]/doshii/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request