class Tosuto::Order

Constants

ENDPOINT

Attributes

approval_status[RW]
business_date[RW]
closed_date[RW]
deleted[RW]
deleted_date[RW]
delivery_info[RW]
duration[RW]
estimated_fulfillment_date[RW]
external_id[RW]
guid[RW]
modified_date[RW]
number_of_guests[RW]
opened_date[RW]
paid_date[RW]
pricing_features[RW]
promised_date[RW]
required_prep_time[RW]
restaurant_id[RW]
restaurant_service[RW]
revenue_center[RW]
server[RW]
service_area[RW]
source[RW]
table[RW]
void_business_date[RW]
void_date[RW]
voided[RW]

Public Class Methods

all(restaurant_id:, token:, date_range: nil, business_date: nil, api: API.new) click to toggle source
# File lib/tosuto/order.rb, line 17
def self.all(restaurant_id:, token:, date_range: nil, business_date: nil, api: API.new)
  params = {}
  unless date_range.nil?
    params["startDate"] = date_range.begin.utc.strftime("%Y-%m-%dT%H:%M:%S.%L%z")
    params["endDate"] = date_range.end.utc.strftime("%Y-%m-%dT%H:%M:%S.%L%z")
  end
  unless business_date.nil?
    params["businessDate"] = business_date.strftime("%Y%m%d")
  end

  response = api.request(
    :get,
    ENDPOINT,
    params: params,
    restaurant_id: restaurant_id,
    token: token
  )
  raise response.error unless response.success?

  response.json_body.map { |guid|
    Order.new(guid: guid, restaurant_id: restaurant_id)
  }
end
get(guid:, restaurant_id:, token:, api: API.new) click to toggle source
# File lib/tosuto/order.rb, line 41
def self.get(guid:, restaurant_id:, token:, api: API.new)
  url = "#{ENDPOINT}/#{guid}"
  response = api.request(
    :get,
    url,
    restaurant_id: restaurant_id,
    token: token
  )
  raise response.error unless response.success?

  return new(response.json_body.merge(restaurant_id: restaurant_id))
end
new(hash) click to toggle source
# File lib/tosuto/order.rb, line 54
def initialize(hash)
  set_attributes(hash)
end

Public Instance Methods

get_details(token:, api: API.new) click to toggle source
# File lib/tosuto/order.rb, line 58
def get_details(token:, api: API.new)
  Order.get(guid: guid, restaurant_id: restaurant_id, token: token, api: api)
end