def open(cls, location_id, employee_id, order_type_id, revenue_center_id, table_id, guest_count=None, name=None, auto_send=None): data = { 'employee': employee_id, 'order_type': order_type_id, 'revenue_center': revenue_center_id, 'table': table_id } if guest_count is not None: data['guest_count'] = guest_count if name is not None: data['name'] = name if auto_send is not None: data['auto_send'] = auto_send res = client.post(cls.list_url(location_id), data) return cls(location_id, **res)
def add_item(self, menu_item, quantity, price_level=None, comment=None, modifiers=None, discounts=None): data = {'menu_item': menu_item.id, 'quantity': quantity} if price_level: price_level_ids = [pl.id for pl in menu_item.price_levels] if price_level not in price_level_ids: raise error.APIError('Unknown price level for item {}'.format( menu_item.id)) data['price_level'] = price_level if comment: if not isinstance(comment, str): raise error.APIError('Comment must be an ascii string') if len(comment) > 20: raise error.APIError('Max comment length is 20 characters') data['comment'] = comment if modifiers: data['modifiers'] = modifiers if discounts: data['discounts'] = discounts res = client.post(TicketItem.list_url(self.location_id, self.id), data) self.refresh_from(**res)
def add_items(self, items): # TODO: all the stuff in add_item res = client.post( TicketItem.list_url(self.location_id, self.id), items ) self.refresh_from(**res)
def pay(self, type, amount, tip, **kwargs): if type not in Payment.types: msg = 'Unknown payment type: \'{}\'. Allowed types: {}'.format( type, Payment.types) raise error.APIError(msg) if type == '3rd_party': if 'tender_type' not in kwargs or 'payment_source' not in kwargs: msg = 'Missing tender_type or payment_source for payment' raise error.APIError(msg) else: if 'card_info' not in kwargs: # TODO: verify required card_info fields raise error.APIError('Missing card_info for payment') data = dict(type=type, amount=amount, tip=tip, **kwargs) res = client.post(Payment.list_url(self.location_id, self.id), data) self.refresh_from(**res.pop('ticket')) return res
def pay(self, type, amount, tip, **kwargs): if type not in Payment.types: msg = 'Unknown payment type: \'{}\'. Allowed types: {}'.format( type, Payment.types ) raise error.APIError(msg) if type == '3rd_party': if 'tender_type' not in kwargs or 'payment_source' not in kwargs: msg = 'Missing tender_type or payment_source for payment' raise error.APIError(msg) else: if 'card_info' not in kwargs: # TODO: verify required card_info fields raise error.APIError('Missing card_info for payment') data = dict(type=type, amount=amount, tip=tip, **kwargs) res = client.post(Payment.list_url(self.location_id, self.id), data) self.refresh_from(**res.pop('ticket')) return res
def add_item(self, menu_item, quantity, price_level=None, comment=None, modifiers=None, discounts=None): data = { 'menu_item': menu_item.id, 'quantity': quantity } if price_level: price_level_ids = [pl.id for pl in menu_item.price_levels] if price_level not in price_level_ids: raise error.APIError( 'Unknown price level for item {}'.format(menu_item.id) ) data['price_level'] = price_level if comment: if not isinstance(comment, str): raise error.APIError('Comment must be an ascii string') if len(comment) > 20: raise error.APIError('Max comment length is 20 characters') data['comment'] = comment if modifiers: data['modifiers'] = modifiers if discounts: data['discounts'] = discounts res = client.post( TicketItem.list_url(self.location_id, self.id), data ) self.refresh_from(**res)
def void(self): res = client.post(self.instance_url, {'void': True}) self.refresh_from(**res)
def add_items(self, items): # TODO: all the stuff in add_item res = client.post(TicketItem.list_url(self.location_id, self.id), items) self.refresh_from(**res)