class OmnivoreIO::Ticket

Attributes

client[RW]

Public Class Methods

new(client, attributes={}) click to toggle source
# File lib/omnivore-io/api/ticket.rb, line 29
def initialize(client, attributes={})
  self.client = client
  self.items = []
  attributes.each do |key, value|
    if self.respond_to? "#{key}=".to_sym
      self.send "#{key}=".to_sym, value
    end
  end
  if embedded = attributes['_embedded']
    (embedded['items'] || []).each do |item_json|
      self.items << OmnivoreIO::TicketItem.new(item_json)
    end
    self.order_type = OmnivoreIO::OrderType.new(nil, embedded['order_type'])
  end
end

Public Instance Methods

as_json(options={}) click to toggle source
Calls superclass method
# File lib/omnivore-io/api/ticket.rb, line 57
def as_json(options={})
  json = super
  json[:items] = self.items.map{ |item| item.as_json }
  json[:order_type] = self.order_type.as_json
  json
end
open!() click to toggle source
# File lib/omnivore-io/api/ticket.rb, line 45
def open!
  payload = {
    "employee" => self.employee,
    "order_type" => self.order_type,
    "revenue_center" => self.revenue_center,
    "guest_count" => self.guest_count,
    "name" => self.name,
    "auto_send" => self.auto_send
  }
  self.merge! self.client.open_ticket(self.location_id, payload)
end