From 5b6c8f5f290708658d85052d609e6661d6d25e89 Mon Sep 17 00:00:00 2001 From: NandaScott Date: Mon, 1 Apr 2019 12:54:30 -0400 Subject: [PATCH] Created tcgplayer endpoint object --- scrython/cards/tcgplayer_id.py | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 scrython/cards/tcgplayer_id.py diff --git a/scrython/cards/tcgplayer_id.py b/scrython/cards/tcgplayer_id.py new file mode 100644 index 0000000..a315b32 --- /dev/null +++ b/scrython/cards/tcgplayer_id.py @@ -0,0 +1,42 @@ +from .cards_object import CardsObject + +class TCGPlayerId(CardsObject): + """ + cards/id + Get a card by the TCGPlayer id. + + Args: + id (string): + The TCGPlayer Id of the card. + format (string, optional): + Defaults to 'json'. + Returns data in the specified method. + face (string, optional): + Defaults to empty string. + If you're using the `image` format, this will specify if you want the front or back face. + version (string, optional): + Defaults to empty string. + If you're using the `image` format, this will specify if you want the small, normal, + large, etc version of the image. + pretty (string, optional): + Defaults to empty string. + Returns a prettier version of the json object. + Note that this may break functionality with Scrython. + + Returns: + N/A + + Raises: + Exception: If the 'id' parameter is not provided. + Exception: If the object returned is an error. + + Examples: + >>> card = scrython.cards.TCGPlayerId(id="6147") + >>> card.name() + """ + def __init__(self, **kwargs): + if kwargs.get('id') is None: + raise Exception('No id provided to search by') + + self.url = 'cards/tcgplayer/{}?'.format(str(kwargs.get('id'))) + super(TCGPlayerId, self).__init__(self.url)