Skip to content

Commit

Permalink
Merge pull request #22 from clvrk/dev
Browse files Browse the repository at this point in the history
Added support for keys in list functions
  • Loading branch information
firstaidguyheru authored Apr 14, 2021
2 parents 6fca2db + 02932ee commit f6cfaf7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions cocktaildb/cocktaildb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ class UnsubscriptableKey(Exception):
def __init__(self, message):
super(UnsubscriptableKey, self).__init__(message)

async def categories():
async def categories(key: str = None):
# Returns a list of categories

category_url = 'https://www.thecocktaildb.com/api/json/v1/1/list.php?c=list'
key = key or 1
category_url = f'https://www.thecocktaildb.com/api/json/v1/{key}/list.php?c=list'
data_categories = await Reqs.get(category_url)

l = [categories['strCategory'] for categories in data_categories['drinks']]
Expand All @@ -23,6 +24,7 @@ async def categories():
async def glasses():
# Returns a list of glasses

key = key or 1
category_url = 'www.thecocktaildb.com/api/json/v1/1/list.php?g=list'
data_glasses = await Reqs.get(category_url)

Expand All @@ -33,6 +35,7 @@ async def glasses():
async def ingredients():
# Returns a list of ingredients

key = key or 1
ingrs_url = 'https://www.thecocktaildb.com/api/json/v1/1/list.php?i=list'
data_ingrs = await Reqs.get(ingrs_url)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
author='clvrk',
author_email="[email protected]",
url="https://github.com/clvrk/cocktail-wrapper",
version='1.0.6',
version='1.0.7',
packages=['cocktaildb'],
python_requires=">= 3.6",
include_package_data=True,
Expand Down

0 comments on commit f6cfaf7

Please sign in to comment.