grocy-cli/grocy/recipe.py

55 lines
1.5 KiB
Python
Raw Normal View History

2019-06-16 23:54:10 -05:00
from grocy.request import Request
from grocy.conf import Configuration
from grocy.entity import Entity
2019-06-16 23:54:10 -05:00
import logging
class Recipe(object):
GET_RECIPES_FULFILLMENT_URL_TEMPLATE = '{domain}/api/recipes/fulfillment'
GET_RECIPE_FULFILLMENT_URL_TEMPLATE = '{domain}/api/recipes/{recipeId}/fulfillment'
GET_RECIPES_POS_FULFILLMENT_URL_TEMPLATE = '{domain}/api/recipes/pos/fulfillment'
GET_RECIPE_POS_FULFILLMENT_URL_TEMPLATE = '{domain}/api/recipes/{recipeId}/pos/{recipeId}/fulfillment'
2019-06-16 23:54:10 -05:00
def __init__(self, id=None):
2019-06-16 23:54:10 -05:00
self.conf = Configuration()
self.conf.load()
self.id = id
2019-06-16 23:54:10 -05:00
def get_ingredient_requirements(self, recipe_id=None):
logger = logging.getLogger('recipe.get_ingredient_requirements')
def get_fulfillments(self):
2019-06-16 23:54:10 -05:00
logger = logging.getLogger('recipe.get_requirements')
if self.id:
url = self.GET_RECIPE_FULFILLMENT_URL_TEMPLATE.format(domain=self.conf.domain, recipeId=self.id)
else:
url = self.GET_RECIPES_FULFILLMENT_URL_TEMPLATE.format(domain=self.conf.domain)
2019-06-16 23:54:10 -05:00
request = Request('get', url)
try:
return request.send()
except Exception as e:
logger.error(e)
raise e
def get(self):
# Get list of available ingredients
if self.id:
entity = Entity(name='recipes')
recipe = entity.get(id=self.id)
if type(recipe) is list:
pass