From 9c28e1396c63af383df9fb79a9f701ffc03aedcf Mon Sep 17 00:00:00 2001 From: Nanda Scott Date: Wed, 10 Jan 2018 20:02:33 -0500 Subject: [PATCH] Renamed classes and modules again. --- ...{cards_autocomplete.py => autocomplete.py} | 2 +- cards/{cards_named.py => named.py} | 36 ++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) rename cards/{cards_autocomplete.py => autocomplete.py} (97%) rename cards/{cards_named.py => named.py} (78%) diff --git a/cards/cards_autocomplete.py b/cards/autocomplete.py similarity index 97% rename from cards/cards_autocomplete.py rename to cards/autocomplete.py index 56247cb..18346d1 100644 --- a/cards/cards_autocomplete.py +++ b/cards/autocomplete.py @@ -1,7 +1,7 @@ import asyncio, aiohttp import json -class CardsAutocomplete(object): +class Autocomplete(object): """ cards/autocomplete Parameters: diff --git a/cards/cards_named.py b/cards/named.py similarity index 78% rename from cards/cards_named.py rename to cards/named.py index de8c890..2bb7e31 100644 --- a/cards/cards_named.py +++ b/cards/named.py @@ -1,9 +1,21 @@ import asyncio, aiohttp import json -class CardsNamed(object): +class Named(object): """ cards/named + Parameters: + exact: str The exact card name to search for, case insenstive. + fuzzy: str A fuzzy card name to search for. + set: str A set code to limit the search to one set. + format: str The data format to return: json, text, or image. Defaults to json. + face: str If using the image format and this parameter has the value back, + the back face of the card will be returned. + Will return a 404 if this card has no back face. + version: str The image version to return when using the image + format: small, normal, large, png, art_crop, or border_crop. Defaults to large. + pretty: bool If true, the returned JSON will be prettified. Avoid using for production code. + Attributes: object: str Returns the type of object it is. (card, error, etc) id: str The scryfall id of the card. @@ -36,8 +48,14 @@ class CardsNamed(object): """ - def __init__(self, cardname): - self.cardname = cardname + def __init__(self, exact=None, fuzzy=None, _set=None, _format=None, face=None, version=None, pretty=None): + self.exact = exact + self.fuzzy = fuzzy + self.set = _set + self.format = _format + self.face = face + self.version = version + self.pretty = pretty loop = asyncio.get_event_loop() self.session = aiohttp.ClientSession(loop=loop) @@ -45,7 +63,17 @@ class CardsNamed(object): async with self.session.get(url, **kwargs) as response: return await response.json() - self.scryfallJson = loop.run_until_complete(getRequest(url='https://api.scryfall.com/cards/named?', params={'fuzzy':self.cardname})) + self.scryfallJson = loop.run_until_complete(getRequest( + url='https://api.scryfall.com/cards/named?', + params={ + 'exact':self.exact, + 'fuzzy':self.fuzzy, + 'set':self.set, + 'format':self.format, + 'face':self.face, + 'version':self.version, + 'pretty':self.pretty + })) self.session.close()