def __init__(self, hass, config): """Set up main service.""" conf = config[DOMAIN] from pizzapi import Address, Customer, Store self.hass = hass self.customer = Customer(conf.get(ATTR_FIRST_NAME), conf.get(ATTR_LAST_NAME), conf.get(ATTR_EMAIL), conf.get(ATTR_PHONE), conf.get(ATTR_ADDRESS)) self.address = Address(*self.customer.address.split(','), country=conf.get(ATTR_COUNTRY)) self.country = conf.get(ATTR_COUNTRY) self.closest_store = Store()
class Dominos(): """Main Dominos service.""" def __init__(self, hass, config): """Set up main service.""" conf = config[DOMAIN] from pizzapi import Address, Customer, Store self.hass = hass self.customer = Customer(conf.get(ATTR_FIRST_NAME), conf.get(ATTR_LAST_NAME), conf.get(ATTR_EMAIL), conf.get(ATTR_PHONE), conf.get(ATTR_ADDRESS)) self.address = Address(*self.customer.address.split(','), country=conf.get(ATTR_COUNTRY)) self.country = conf.get(ATTR_COUNTRY) self.closest_store = Store() def handle_order(self, call): """Handle ordering pizza.""" entity_ids = call.data.get(ATTR_ORDER_ENTITY, None) target_orders = [ order for order in self.hass.data[DOMAIN]['entities'] if order.entity_id in entity_ids ] for order in target_orders: order.place() @Throttle(MIN_TIME_BETWEEN_STORE_UPDATES) def update_closest_store(self): """Update the shared closest store (if open).""" from pizzapi.address import StoreException try: self.closest_store = self.address.closest_store() except StoreException: self.closest_store = False def get_menu(self): """Return the products from the closest stores menu.""" if self.closest_store is False: _LOGGER.warning('Cannot get menu. Store may be closed') return menu = self.closest_store.get_menu() product_entries = [] for product in menu.products: item = {} if isinstance(product.menu_data['Variants'], list): variants = ', '.join(product.menu_data['Variants']) else: variants = product.menu_data['Variants'] item['name'] = product.name item['variants'] = variants product_entries.append(item) return product_entries
def __init__(self, hass, config): """Set up main service.""" conf = config[DOMAIN] self.hass = hass self.customer = Customer( conf.get(ATTR_FIRST_NAME), conf.get(ATTR_LAST_NAME), conf.get(ATTR_EMAIL), conf.get(ATTR_PHONE), conf.get(ATTR_ADDRESS), ) self.address = Address(*self.customer.address.split(","), country=conf.get(ATTR_COUNTRY)) self.country = conf.get(ATTR_COUNTRY) try: self.closest_store = self.address.closest_store() except StoreException: self.closest_store = None
def orderPizza(): print "starting to order the pizza" file = open("info.json").read() values = json.loads(file) customer = Customer(values["first_name"], values["last_name"], values["email"], values["phone_number"], values["address"]) address = Address(*customer.address.split(',')) store = address.closest_store() print "ordering from store" + str(store.get_details()) order = Order(store, customer, address) order.add_item(values["pizza_code"]) card = PaymentObject(values["cc_number"], values["cc_expiration"], values["cc_security"], values["cc_zip"]) order.pay_with() print "congrats! order was succesful"
def getCustomerAndAddress(): firstName = input('First name: ') lastName = input('Last name: ') email = input('Email: ') phone = input('Phone #: ') streetAddr = input('Street address: ') city = input('City: ') state = input('State: ') zipcode = input('Zipcode: ') addr = streetAddr + ',' + city + ',' + state + ',' + zipcode customer = Customer(firstName, lastName, email, phone, addr) address = Address(streetAddr, city, state, zipcode) return customer, address
def __init__(self, hass, config): """Set up main service.""" conf = config[DOMAIN] from pizzapi import Address, Customer from pizzapi.address import StoreException self.hass = hass self.customer = Customer( conf.get(ATTR_FIRST_NAME), conf.get(ATTR_LAST_NAME), conf.get(ATTR_EMAIL), conf.get(ATTR_PHONE), conf.get(ATTR_ADDRESS)) self.address = Address( *self.customer.address.split(','), country=conf.get(ATTR_COUNTRY)) self.country = conf.get(ATTR_COUNTRY) try: self.closest_store = self.address.closest_store() except StoreException: self.closest_store = None
class Dominos(): """Main Dominos service.""" def __init__(self, hass, config): """Set up main service.""" conf = config[DOMAIN] from pizzapi import Address, Customer from pizzapi.address import StoreException self.hass = hass self.customer = Customer( conf.get(ATTR_FIRST_NAME), conf.get(ATTR_LAST_NAME), conf.get(ATTR_EMAIL), conf.get(ATTR_PHONE), conf.get(ATTR_ADDRESS)) self.address = Address( *self.customer.address.split(','), country=conf.get(ATTR_COUNTRY)) self.country = conf.get(ATTR_COUNTRY) try: self.closest_store = self.address.closest_store() except StoreException: self.closest_store = None def handle_order(self, call): """Handle ordering pizza.""" entity_ids = call.data.get(ATTR_ORDER_ENTITY, None) target_orders = [order for order in self.hass.data[DOMAIN]['entities'] if order.entity_id in entity_ids] for order in target_orders: order.place() @Throttle(MIN_TIME_BETWEEN_STORE_UPDATES) def update_closest_store(self): """Update the shared closest store (if open).""" from pizzapi.address import StoreException try: self.closest_store = self.address.closest_store() return True except StoreException: self.closest_store = None return False def get_menu(self): """Return the products from the closest stores menu.""" self.update_closest_store() if self.closest_store is None: _LOGGER.warning('Cannot get menu. Store may be closed') return [] menu = self.closest_store.get_menu() product_entries = [] for product in menu.products: item = {} if isinstance(product.menu_data['Variants'], list): variants = ', '.join(product.menu_data['Variants']) else: variants = product.menu_data['Variants'] item['name'] = product.name item['variants'] = variants product_entries.append(item) return product_entries
from pizzapi import address, store, menu, Address import config as credentials print('Make sure that you have set up your config file correctly!') while True: address = Address(credentials.credentials['addressLine'], credentials.credentials['city'], credentials.credentials['state'], credentials.credentials['zip']) store = address.closest_store() menu = store.get_menu() query = input("Enter a search term to find item codes(capitalize first letter): ") menu.search(Name=query)
class Dominos: """Main Dominos service.""" def __init__(self, opp, config): """Set up main service.""" conf = config[DOMAIN] self.opp = opp self.customer = Customer( conf.get(ATTR_FIRST_NAME), conf.get(ATTR_LAST_NAME), conf.get(ATTR_EMAIL), conf.get(ATTR_PHONE), conf.get(ATTR_ADDRESS), ) self.address = Address(*self.customer.address.split(","), country=conf.get(ATTR_COUNTRY)) self.country = conf.get(ATTR_COUNTRY) try: self.closest_store = self.address.closest_store() except StoreException: self.closest_store = None def handle_order(self, call): """Handle ordering pizza.""" entity_ids = call.data.get(ATTR_ORDER_ENTITY) target_orders = [ order for order in self.opp.data[DOMAIN]["entities"] if order.entity_id in entity_ids ] for order in target_orders: order.place() @Throttle(MIN_TIME_BETWEEN_STORE_UPDATES) def update_closest_store(self): """Update the shared closest store (if open).""" try: self.closest_store = self.address.closest_store() return True except StoreException: self.closest_store = None return False def get_menu(self): """Return the products from the closest stores menu.""" self.update_closest_store() if self.closest_store is None: _LOGGER.warning("Cannot get menu. Store may be closed") return [] menu = self.closest_store.get_menu() product_entries = [] for product in menu.products: item = {} if isinstance(product.menu_data["Variants"], list): variants = ", ".join(product.menu_data["Variants"]) else: variants = product.menu_data["Variants"] item["name"] = product.name item["variants"] = variants product_entries.append(item) return product_entries