tosuto 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +14 -0
- data/lib/tosuto/api.rb +3 -3
- data/lib/tosuto/dining_option.rb +1 -2
- data/lib/tosuto/oauth_token.rb +2 -3
- data/lib/tosuto/order.rb +4 -6
- data/lib/tosuto/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26ea14837c62c32b1a17ca91c1d6968c843af6cf594a580af7252048c831e732
|
4
|
+
data.tar.gz: 43c5bfce2a6a530d706dbdd82bd42539e3a793c918530e0f79bed066b8237e93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 770e2cf6c5e4ecf8d9006a6c5d86041821ada201a12e426375fd4c235f0b25460b5bb4a6359e94feacd4b6c5a8adf9b61fcdd74e6ccb22e28f452f0bf337360a
|
7
|
+
data.tar.gz: fc6cd4591188db9741fa3c3bf3191f3c68fe2350e12ca54141c7994226de993df40846f3752993edd79d98a13bee8c3dbc3c981f53405f781ce1d79f7d872a0d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -58,6 +58,20 @@ if order.dining_option.take_out?
|
|
58
58
|
end
|
59
59
|
```
|
60
60
|
|
61
|
+
## Setting the Toast host URL
|
62
|
+
|
63
|
+
Tosuto defaults to the sandbox Toast host URL: `https://ws-sandbox-api.eng.toasttab.com`
|
64
|
+
|
65
|
+
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:
|
66
|
+
|
67
|
+
```rb
|
68
|
+
token = Tosuto::OauthToken.create(
|
69
|
+
client_id,
|
70
|
+
client_secret,
|
71
|
+
api: Tosuto::API.new("https://example.org")
|
72
|
+
)
|
73
|
+
```
|
74
|
+
|
61
75
|
## Development
|
62
76
|
|
63
77
|
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.
|
data/lib/tosuto/api.rb
CHANGED
@@ -5,7 +5,7 @@ require 'forwardable'
|
|
5
5
|
|
6
6
|
module Tosuto
|
7
7
|
class API
|
8
|
-
DEFAULT_HOST = ENV.fetch("TOAST_HOST", "ws-sandbox-api.eng.toasttab.com")
|
8
|
+
DEFAULT_HOST = ENV.fetch("TOAST_HOST", "https://ws-sandbox-api.eng.toasttab.com")
|
9
9
|
|
10
10
|
class Error < Error
|
11
11
|
extend Forwardable
|
@@ -56,7 +56,7 @@ module Tosuto
|
|
56
56
|
body: body,
|
57
57
|
headers: headers,
|
58
58
|
token: token,
|
59
|
-
restaurant_id: restaurant_id
|
59
|
+
restaurant_id: restaurant_id,
|
60
60
|
)
|
61
61
|
)
|
62
62
|
}
|
@@ -65,7 +65,7 @@ module Tosuto
|
|
65
65
|
private
|
66
66
|
|
67
67
|
def build_uri(endpoint, params = nil)
|
68
|
-
URI.parse("
|
68
|
+
URI.parse("#{@host}#{endpoint}").tap { |uri|
|
69
69
|
next if params.nil?
|
70
70
|
|
71
71
|
uri.query = Resource.encode_form_data(params)
|
data/lib/tosuto/dining_option.rb
CHANGED
data/lib/tosuto/oauth_token.rb
CHANGED
@@ -2,10 +2,9 @@ module Tosuto
|
|
2
2
|
class OauthToken < Resource
|
3
3
|
ENDPOINT = "/usermgmt/v1/oauth/token"
|
4
4
|
|
5
|
-
attr_accessor :access_token, :token_type, :expires_in, :expires_at, :scope
|
5
|
+
attr_accessor :access_token, :token_type, :expires_in, :expires_at, :scope
|
6
6
|
|
7
|
-
def self.create(client_id, client_secret, grant_type: "client_credentials")
|
8
|
-
api = API.new
|
7
|
+
def self.create(client_id, client_secret, grant_type: "client_credentials", api: API.new)
|
9
8
|
body = {
|
10
9
|
grant_type: grant_type,
|
11
10
|
client_id: client_id,
|
data/lib/tosuto/order.rb
CHANGED
@@ -14,8 +14,7 @@ module Tosuto
|
|
14
14
|
attr_collections checks: Check
|
15
15
|
attr_objects dining_option: DiningOption
|
16
16
|
|
17
|
-
def self.all(restaurant_id:, token:, date_range: nil, business_date: nil)
|
18
|
-
api = API.new
|
17
|
+
def self.all(restaurant_id:, token:, date_range: nil, business_date: nil, api: API.new)
|
19
18
|
params = {}
|
20
19
|
unless date_range.nil?
|
21
20
|
params["startDate"] = date_range.begin.utc.strftime("%Y-%m-%dT%H:%M:%S.%L%z")
|
@@ -39,8 +38,7 @@ module Tosuto
|
|
39
38
|
}
|
40
39
|
end
|
41
40
|
|
42
|
-
def self.get(guid:, restaurant_id:, token:)
|
43
|
-
api = API.new
|
41
|
+
def self.get(guid:, restaurant_id:, token:, api: API.new)
|
44
42
|
url = "#{ENDPOINT}/#{guid}"
|
45
43
|
response = api.request(
|
46
44
|
:get,
|
@@ -57,8 +55,8 @@ module Tosuto
|
|
57
55
|
set_attributes(hash)
|
58
56
|
end
|
59
57
|
|
60
|
-
def get_details(token:)
|
61
|
-
Order.get(guid: guid, restaurant_id: restaurant_id, token: token)
|
58
|
+
def get_details(token:, api: API.new)
|
59
|
+
Order.get(guid: guid, restaurant_id: restaurant_id, token: token, api: api)
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
data/lib/tosuto/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tosuto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Yoder
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -104,7 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.7.6
|
108
109
|
signing_key:
|
109
110
|
specification_version: 4
|
110
111
|
summary: A gem for accessing Toast's API
|