tosuto 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a313d9c4f75ea9922782b51700cdb7bc86356c684208f95ab00309c1de68a7cc
4
- data.tar.gz: 8621253d05767588e09adb8009dd5a4ddb28baf79fd80b6dd5a9fc15b9b3aea5
3
+ metadata.gz: 26ea14837c62c32b1a17ca91c1d6968c843af6cf594a580af7252048c831e732
4
+ data.tar.gz: 43c5bfce2a6a530d706dbdd82bd42539e3a793c918530e0f79bed066b8237e93
5
5
  SHA512:
6
- metadata.gz: 30a132fbdd429d57e0cb10b6a93db365dfcde83a05870cdcd6388fb0a042fdf4b56046c45504e3c0f5054a5bb1adbf95853ecb0a72dd29e7982e482311bae47b
7
- data.tar.gz: 9b25643ecd0a146645126788ce46e3094ed9c3fae9e00e0d363a74f781c867bc38a3d02f8dd44beac6c904fd0ee9116b5c345f2ce79e14a96f1e79b09f0b8e71
6
+ metadata.gz: 770e2cf6c5e4ecf8d9006a6c5d86041821ada201a12e426375fd4c235f0b25460b5bb4a6359e94feacd4b6c5a8adf9b61fcdd74e6ccb22e28f452f0bf337360a
7
+ data.tar.gz: fc6cd4591188db9741fa3c3bf3191f3c68fe2350e12ca54141c7994226de993df40846f3752993edd79d98a13bee8c3dbc3c981f53405f781ce1d79f7d872a0d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tosuto (0.1.0)
4
+ tosuto (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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("https://#{@host}#{endpoint}").tap { |uri|
68
+ URI.parse("#{@host}#{endpoint}").tap { |uri|
69
69
  next if params.nil?
70
70
 
71
71
  uri.query = Resource.encode_form_data(params)
@@ -8,8 +8,7 @@ module Tosuto
8
8
  set_attributes(hash)
9
9
  end
10
10
 
11
- def get_details(token:, restaurant_id:)
12
- api = API.new
11
+ def get_details(token:, restaurant_id:, api: API.new)
13
12
  url = "#{ENDPOINT}/#{guid}"
14
13
  response = api.request(
15
14
  :get,
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Tosuto
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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-21 00:00:00.000000000 Z
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
- rubygems_version: 3.0.6
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