tosuto 0.3.0 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6206cec09a7b19a1b133e6ce2c4be6dd1cafbf3e2467f78625bfdd2004d78a2
4
- data.tar.gz: 44224408cad495a3f6ce8561137481d1281d2489d86229cfb0d3cb1728f82d27
3
+ metadata.gz: 65961f5a798b7c01bde52c6c3b02ae75fecefde2912342750e6bca9394c360d4
4
+ data.tar.gz: be149610b9018f33844d7bb2680d2bb50300f07dde80f37d531dcc75b31f857b
5
5
  SHA512:
6
- metadata.gz: 46a3056cb417c524cdd380c18fdd7f043d34c716813db98fe32e69747f4a486227f18262a26d2f84ec50dc7e75320d48829bb2714567686dc131ffdec87908ab
7
- data.tar.gz: c1f4182141f368d67a4e72707a42703d38f249a7e14ee3da6b5200a1e1f1c4e99091e6ed901c4de62ab16921618b677341096f50091312f0bd2b1eb1a9299f75
6
+ metadata.gz: 63e1239cdb08e468a1652c5e6c99d7f2c58fb44c57485cca6b8c98927b70c4a2b6f0c97df859e811cf464324c99da4b360ca785191038967e310937929739165
7
+ data.tar.gz: f67c396d70b53d5e3984642ae42b25d5da4868f0576cfef5628cbc76598c4fe2f5802a157580297147b25e35d1eee44caa11996c0a679a4ec5031414472722f7
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in tosuto.gemspec
4
4
  gemspec
5
+
6
+ gem 'pry-byebug'
data/Gemfile.lock CHANGED
@@ -1,13 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tosuto (0.3.0)
4
+ tosuto (0.4.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ byebug (11.1.3)
10
+ coderay (1.1.3)
9
11
  diff-lcs (1.3)
10
- rake (10.5.0)
12
+ method_source (1.0.0)
13
+ pry (0.13.1)
14
+ coderay (~> 1.1)
15
+ method_source (~> 1.0)
16
+ pry-byebug (3.9.0)
17
+ byebug (~> 11.0)
18
+ pry (~> 0.13.0)
19
+ rake (13.0.1)
11
20
  rspec (3.9.0)
12
21
  rspec-core (~> 3.9.0)
13
22
  rspec-expectations (~> 3.9.0)
@@ -27,9 +36,10 @@ PLATFORMS
27
36
 
28
37
  DEPENDENCIES
29
38
  bundler (~> 2.0)
30
- rake (~> 10.0)
39
+ pry-byebug
40
+ rake (~> 13.0)
31
41
  rspec (~> 3.0)
32
42
  tosuto!
33
43
 
34
44
  BUNDLED WITH
35
- 2.0.2
45
+ 2.2.28
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", "https://ws-sandbox-api.eng.toasttab.com")
8
+ DEFAULT_HOST = ENV.fetch("TOAST_HOST", "https://ws-sandbox.eng.toasttab.com")
9
9
 
10
10
  class Error < Error
11
11
  extend Forwardable
@@ -1,6 +1,14 @@
1
1
  module Tosuto
2
2
  class AppliedTaxRate < Resource
3
- attr_accessor :guid, :tax_rate, :rate, :name, :tax_amount, :type
3
+ attr_accessor :guid
4
+
5
+ attr_accessor(*%i[
6
+ name
7
+ rate
8
+ tax_amount
9
+ tax_rate
10
+ type
11
+ ])
4
12
 
5
13
  def initialize(hash)
6
14
  set_attributes(hash)
data/lib/tosuto/check.rb CHANGED
@@ -1,10 +1,30 @@
1
1
  module Tosuto
2
2
  class Check < Resource
3
- attr_accessor :guid, :external_id, :display_number, :payments, :applied_discounts,
4
- :void_date, :paid_date, :applied_loyalty_info, :voided, :payment_status, :amount,
5
- :tab_name, :tax_exempt, :opened_date, :total_amount, :void_business_date,
6
- :deleted, :closed_date, :deleted_date, :modified_date, :tax_amount,
7
- :applied_service_charges, :customer
3
+ attr_accessor :external_id, :guid
4
+
5
+ attr_accessor(*%i[
6
+ amount
7
+ applied_discounts
8
+ applied_loyalty_info
9
+ applied_service_charges
10
+ closed_date
11
+ customer
12
+ deleted
13
+ deleted_date
14
+ display_number
15
+ modified_date
16
+ opened_date
17
+ paid_date
18
+ payment_status
19
+ payments
20
+ tab_name
21
+ tax_amount
22
+ tax_exempt
23
+ total_amount
24
+ void_business_date
25
+ void_date
26
+ voided
27
+ ])
8
28
 
9
29
  attr_collections selections: MenuItemSelection
10
30
 
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tosuto/resource'
4
+
5
+ module Tosuto
6
+ class CurbsidePickupInfo < Resource
7
+ attr_accessor :entity_type, :guid
8
+
9
+ attr_accessor(*%i[
10
+ notes
11
+ transport_color
12
+ transport_description
13
+ ])
14
+
15
+ def initialize(hash)
16
+ set_attributes(hash)
17
+ end
18
+ end
19
+ end
@@ -1,8 +1,17 @@
1
1
  module Tosuto
2
2
  class DiningOption < Resource
3
- ENDPOINT = "/config/v2/diningOptions".freeze
3
+ ENDPOINT = '/config/v2/diningOptions'.freeze
4
4
 
5
- attr_accessor :guid, :entity_type, :external_id, :name, :behavior
5
+ CARRYOUT_MATCH = %w[carryout].freeze
6
+ DSP_MATCH = %w[delivery door grub postmates uber].freeze
7
+
8
+ attr_accessor :entity_type, :external_id, :guid
9
+
10
+ attr_accessor(*%i[
11
+ behavior
12
+ curbside
13
+ name
14
+ ])
6
15
 
7
16
  def initialize(hash)
8
17
  set_attributes(hash)
@@ -22,12 +31,20 @@ module Tosuto
22
31
  self
23
32
  end
24
33
 
34
+ def dsp?
35
+ DSP_MATCH.any? { |dsp| name&.downcase&.match?(dsp) }
36
+ end
37
+
38
+ def carryout?
39
+ CARRYOUT_MATCH.any? { |carryout| name&.downcase&.match?(carryout) }
40
+ end
41
+
25
42
  def take_out?
26
- behavior == "TAKE_OUT"
43
+ behavior == 'TAKE_OUT' && (carryout? || !dsp?)
27
44
  end
28
45
 
29
46
  def delivery?
30
- behavior == "DELIVERY"
47
+ behavior == 'DELIVERY' || (dsp? && !carryout?)
31
48
  end
32
49
  end
33
50
  end
@@ -1,10 +1,29 @@
1
1
  module Tosuto
2
2
  class MenuItemSelection < Resource
3
- attr_accessor :guid, :external_id, :deferred, :pre_discount_price, :void_reason,
4
- :option_group, :display_name, :applied_discounts, :modifiers, :seat_number,
5
- :void_date, :fulfillment_status, :selection_type, :price, :voided,
6
- :quantity, :unit_of_measure, :tax, :void_business_date, :created_date, :pre_modifier,
7
- :modified_date
3
+ attr_accessor :external_id, :guid
4
+
5
+ attr_accessor(*%i[
6
+ applied_discounts
7
+ created_date
8
+ deferred
9
+ display_name
10
+ fulfillment_status
11
+ modified_date
12
+ modifiers
13
+ option_group
14
+ pre_discount_price
15
+ pre_modifier
16
+ price
17
+ quantity
18
+ seat_number
19
+ selection_type
20
+ tax
21
+ unit_of_measure
22
+ void_business_date
23
+ void_date
24
+ void_reason
25
+ voided
26
+ ])
8
27
 
9
28
  attr_collections applied_taxes: AppliedTaxRate
10
29
 
@@ -1,27 +1,29 @@
1
1
  module Tosuto
2
2
  class OauthToken < Resource
3
- ENDPOINT = "/usermgmt/v1/oauth/token"
3
+ ENDPOINT = "/authentication/v1/authentication/login".freeze
4
4
 
5
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", api: API.new)
7
+ def self.create(client_id, client_secret, user_access_type: "TOAST_MACHINE_CLIENT", api: API.new)
8
8
  body = {
9
- grant_type: grant_type,
10
- client_id: client_id,
11
- client_secret: client_secret,
9
+ userAccessType: user_access_type,
10
+ clientId: client_id,
11
+ clientSecret: client_secret,
12
12
  }
13
- response = api.request(:post, ENDPOINT, body: encode_form_data(body))
13
+ response = api.request(:post, ENDPOINT, body: body)
14
14
  raise response.error unless response.success?
15
15
 
16
- return self.new(response.json_body)
16
+ return new(response.json_body)
17
17
  end
18
18
 
19
19
  def initialize(attributes = {})
20
- self.access_token = attributes['access_token']
21
- self.expires_in = attributes['expires_in'].to_i
20
+ return unless (token = attributes['token'])
21
+
22
+ self.access_token = token['accessToken']
23
+ self.expires_in = token['expiresIn'].to_i
22
24
  self.expires_at = Time.now + expires_in
23
- self.token_type = attributes['token_type']
24
- self.scope = attributes['scope']
25
+ self.token_type = token['tokenType']
26
+ self.scope = token['scope']
25
27
  end
26
28
 
27
29
  def expired?
data/lib/tosuto/order.rb CHANGED
@@ -1,17 +1,43 @@
1
1
  require 'date'
2
2
 
3
+ require 'tosuto/curbside_pickup_info'
4
+
3
5
  module Tosuto
4
6
  class Order < Resource
5
- ENDPOINT = "/orders/v2/orders"
7
+ ENDPOINT = "/orders/v2/orders".freeze
8
+
9
+ attr_accessor :external_id, :guid
6
10
 
7
- attr_accessor :guid, :external_id, :revenue_center, :server, :source, :void_date,
8
- :duration, :business_date, :paid_date, :restaurant_service, :voided,
9
- :estimated_fulfillment_date, :table, :required_prep_time, :approval_status,
10
- :delivery_info, :service_area, :number_of_guests, :opened_date,
11
- :void_business_date, :deleted, :closed_date, :deleted_date, :modified_date,
12
- :promised_date, :pricing_features, :restaurant_id
11
+ attr_accessor(*%i[
12
+ approval_status
13
+ business_date
14
+ closed_date
15
+ deleted
16
+ deleted_date
17
+ delivery_info
18
+ duration
19
+ estimated_fulfillment_date
20
+ modified_date
21
+ number_of_guests
22
+ opened_date
23
+ paid_date
24
+ pricing_features
25
+ promised_date
26
+ required_prep_time
27
+ restaurant_id
28
+ restaurant_service
29
+ revenue_center
30
+ server
31
+ service_area
32
+ source
33
+ table
34
+ void_business_date
35
+ void_date
36
+ voided
37
+ ])
13
38
 
14
39
  attr_collections checks: Check
40
+ attr_objects curbside_pickup_info: CurbsidePickupInfo
15
41
  attr_objects dining_option: DiningOption
16
42
 
17
43
  def self.all(restaurant_id:, token:, date_range: nil, business_date: nil, api: API.new)
@@ -1,3 +1,3 @@
1
1
  module Tosuto
2
- VERSION = "0.3.0"
2
+ VERSION = '0.4.3'.freeze
3
3
  end
data/tosuto.gemspec CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 2.0"
30
- spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rake", "~> 13.0"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
32
  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.3.0
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Yoder
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-07 00:00:00.000000000 Z
11
+ date: 2021-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +75,7 @@ files:
75
75
  - lib/tosuto/api.rb
76
76
  - lib/tosuto/applied_tax_rate.rb
77
77
  - lib/tosuto/check.rb
78
+ - lib/tosuto/curbside_pickup_info.rb
78
79
  - lib/tosuto/dining_option.rb
79
80
  - lib/tosuto/menu_item_selection.rb
80
81
  - lib/tosuto/oauth_token.rb
@@ -89,7 +90,7 @@ metadata:
89
90
  homepage_uri: https://github.com/RadiusNetworks/tosuto
90
91
  source_code_uri: https://github.com/RadiusNetworks/tosuto
91
92
  changelog_uri: https://github.com/RadiusNetworks/tosuto
92
- post_install_message:
93
+ post_install_message:
93
94
  rdoc_options: []
94
95
  require_paths:
95
96
  - lib
@@ -104,9 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  - !ruby/object:Gem::Version
105
106
  version: '0'
106
107
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.7.6
109
- signing_key:
108
+ rubygems_version: 3.0.8
109
+ signing_key:
110
110
  specification_version: 4
111
111
  summary: A gem for accessing Toast's API
112
112
  test_files: []