class Tosuto::DiningOption
Constants
- CARRYOUT_MATCH
- DSP_MATCH
- ENDPOINT
Attributes
behavior[RW]
entity_type[RW]
external_id[RW]
guid[RW]
name[RW]
Public Class Methods
new(hash)
click to toggle source
# File lib/tosuto/dining_option.rb, line 9 def initialize(hash) set_attributes(hash) end
Public Instance Methods
carryout?()
click to toggle source
# File lib/tosuto/dining_option.rb, line 31 def carryout? CARRYOUT_MATCH.any? { |carryout| name&.downcase&.match?(carryout) } end
delivery?()
click to toggle source
# File lib/tosuto/dining_option.rb, line 39 def delivery? behavior == 'DELIVERY' || (dsp? && !carryout?) end
dsp?()
click to toggle source
# File lib/tosuto/dining_option.rb, line 27 def dsp? DSP_MATCH.any? { |dsp| name&.downcase&.match?(dsp) } end
get_details(token:, restaurant_id:, api: API.new)
click to toggle source
# File lib/tosuto/dining_option.rb, line 13 def get_details(token:, restaurant_id:, api: API.new) url = "#{ENDPOINT}/#{guid}" response = api.request( :get, url, restaurant_id: restaurant_id, token: token, ) raise response.error unless response.success? set_attributes(response.json_body) self end
take_out?()
click to toggle source
# File lib/tosuto/dining_option.rb, line 35 def take_out? behavior == 'TAKE_OUT' && (carryout? || !dsp?) end