initial commit
This commit is contained in:
38
order.py
Normal file
38
order.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import json
|
||||
|
||||
MILK_TYPES = ["Cream", "Half-and-half", "Whole-milk", "Part-Skim", "Skim", "Non-Dairy"]
|
||||
|
||||
SYRUP_TYPES = ["Vanilla", "Almond", "Raspberry", "Chocolate"]
|
||||
|
||||
ALCOHOL_TYPES = ["Whisky", "Rum", "Kahlua", "Aquavit"]
|
||||
|
||||
ADDITION_HEADER = "Accept-Additions"
|
||||
|
||||
|
||||
class Order(object):
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.milk = "None"
|
||||
self.syrup = "None"
|
||||
self.alcohol = "None"
|
||||
print(f"Configuring order - {name}")
|
||||
|
||||
def configure(self, header):
|
||||
additions = []
|
||||
for k, v in header.items():
|
||||
if ADDITION_HEADER in k:
|
||||
additions = v
|
||||
print(additions)
|
||||
addition_list = additions.split(';')
|
||||
for ad in addition_list:
|
||||
print(ad)
|
||||
if ad.strip() in MILK_TYPES:
|
||||
self.milk = ad
|
||||
elif ad.strip() in SYRUP_TYPES:
|
||||
self.syrup = ad
|
||||
elif ad.strip() in ALCOHOL_TYPES:
|
||||
self.alcohol = ad
|
||||
|
||||
def json_dump(self):
|
||||
return json.dumps([{'name': self.name}, {'milk': self.milk}, {'syrup': self.syrup}, {'alcohol': self.alcohol}])
|
||||
Reference in New Issue
Block a user