diff --git a/docs/scrython.cards/ArenaId.md b/docs/scrython.cards/ArenaId.md index 2c4dfd8..6a26da5 100644 --- a/docs/scrython.cards/ArenaId.md +++ b/docs/scrython.cards/ArenaId.md @@ -432,6 +432,22 @@ The power of the creature, if applicable Returns: string +``` +--- +### `preview()` + +``` +Preview information for this card, if any. + You may pass the name of a valid key to return the value of that key. + Such as a source_uri. + + Args: + key (string): A key for specific information about the preview. + + Returns: + dict: If provided no key, the entire dict is returned. + string: If provided a key, the value of that key is returned. + ``` --- ### `prices()` diff --git a/docs/scrython.cards/Collector.md b/docs/scrython.cards/Collector.md index a52a210..a216f95 100644 --- a/docs/scrython.cards/Collector.md +++ b/docs/scrython.cards/Collector.md @@ -429,6 +429,22 @@ The power of the creature, if applicable Returns: string +``` +--- +### `preview()` + +``` +Preview information for this card, if any. + You may pass the name of a valid key to return the value of that key. + Such as a source_uri. + + Args: + key (string): A key for specific information about the preview. + + Returns: + dict: If provided no key, the entire dict is returned. + string: If provided a key, the value of that key is returned. + ``` --- ### `prices()` diff --git a/docs/scrython.cards/Id.md b/docs/scrython.cards/Id.md index 25c7d79..064c3a3 100644 --- a/docs/scrython.cards/Id.md +++ b/docs/scrython.cards/Id.md @@ -432,6 +432,22 @@ The power of the creature, if applicable Returns: string +``` +--- +### `preview()` + +``` +Preview information for this card, if any. + You may pass the name of a valid key to return the value of that key. + Such as a source_uri. + + Args: + key (string): A key for specific information about the preview. + + Returns: + dict: If provided no key, the entire dict is returned. + string: If provided a key, the value of that key is returned. + ``` --- ### `prices()` diff --git a/docs/scrython.cards/Mtgo.md b/docs/scrython.cards/Mtgo.md index 9751c98..75a8db1 100644 --- a/docs/scrython.cards/Mtgo.md +++ b/docs/scrython.cards/Mtgo.md @@ -432,6 +432,22 @@ The power of the creature, if applicable Returns: string +``` +--- +### `preview()` + +``` +Preview information for this card, if any. + You may pass the name of a valid key to return the value of that key. + Such as a source_uri. + + Args: + key (string): A key for specific information about the preview. + + Returns: + dict: If provided no key, the entire dict is returned. + string: If provided a key, the value of that key is returned. + ``` --- ### `prices()` diff --git a/docs/scrython.cards/Multiverse.md b/docs/scrython.cards/Multiverse.md index b8de0b3..5c82f6f 100644 --- a/docs/scrython.cards/Multiverse.md +++ b/docs/scrython.cards/Multiverse.md @@ -432,6 +432,22 @@ The power of the creature, if applicable Returns: string +``` +--- +### `preview()` + +``` +Preview information for this card, if any. + You may pass the name of a valid key to return the value of that key. + Such as a source_uri. + + Args: + key (string): A key for specific information about the preview. + + Returns: + dict: If provided no key, the entire dict is returned. + string: If provided a key, the value of that key is returned. + ``` --- ### `prices()` diff --git a/docs/scrython.cards/Named.md b/docs/scrython.cards/Named.md index 76558ec..6872c17 100644 --- a/docs/scrython.cards/Named.md +++ b/docs/scrython.cards/Named.md @@ -434,6 +434,22 @@ The power of the creature, if applicable Returns: string +``` +--- +### `preview()` + +``` +Preview information for this card, if any. + You may pass the name of a valid key to return the value of that key. + Such as a source_uri. + + Args: + key (string): A key for specific information about the preview. + + Returns: + dict: If provided no key, the entire dict is returned. + string: If provided a key, the value of that key is returned. + ``` --- ### `prices()` diff --git a/docs/scrython.cards/Random.md b/docs/scrython.cards/Random.md index a0ab860..23038d4 100644 --- a/docs/scrython.cards/Random.md +++ b/docs/scrython.cards/Random.md @@ -430,6 +430,22 @@ The power of the creature, if applicable Returns: string +``` +--- +### `preview()` + +``` +Preview information for this card, if any. + You may pass the name of a valid key to return the value of that key. + Such as a source_uri. + + Args: + key (string): A key for specific information about the preview. + + Returns: + dict: If provided no key, the entire dict is returned. + string: If provided a key, the value of that key is returned. + ``` --- ### `prices()` diff --git a/scrython/cards/cards_object.py b/scrython/cards/cards_object.py index 96a9022..d89b8c3 100644 --- a/scrython/cards/cards_object.py +++ b/scrython/cards/cards_object.py @@ -728,4 +728,23 @@ class CardsObject(FoundationObject): """ super(CardsObject, self)._checkForKey('released_at') - return self.scryfallJson['released_at'] \ No newline at end of file + return self.scryfallJson['released_at'] + + def preview(self, key=None): + """Preview information for this card, if any. + You may pass the name of a valid key to return the value of that key. + Such as a source_uri. + + Args: + key (string): A key for specific information about the preview. + + Returns: + dict: If provided no key, the entire dict is returned. + string: If provided a key, the value of that key is returned. + """ + super(CardsObject, self)._checkForKey('preview') + + if key in self.scryfallJson['preview']: + return self.scryfallJson['preview'][key] + + return self.scryfallJson['preview'] \ No newline at end of file diff --git a/unittests/TestCards.py b/unittests/TestCards.py index 1db8b7a..3dca286 100644 --- a/unittests/TestCards.py +++ b/unittests/TestCards.py @@ -17,6 +17,7 @@ transform = Id(id='aae6fb12-b252-453b-bca7-1ea2a0d6c8dc'); time.sleep(0.1) vanguard = Id(id='87c1234b-3834-4bba-bef2-05707bb1e8e2'); time.sleep(0.1) alt_lang_card = Collector(code='ths', collector_number='75', lang='ja'); time.sleep(0.1) planeswalker = Id(id='4c565076-5db2-47ea-8ee0-4a4fd7bb353d'); time.sleep(0.1) +preview_check = Id(id='fb6b12e7-bb93-4eb6-bad1-b256a6ccff4e'); time.sleep(0.1) autocomplete = Autocomplete(q='Thal'); time.sleep(0.1) @@ -207,6 +208,10 @@ class TestCardObjects(unittest.TestCase): def test_oversized(self): self.assertIsInstance(non_online_card.oversized(), bool) + def test_preview(self): + self.assertIsInstance(preview_check.preview(), dict) + self.assertIsInstance(preview_check.preview('source'), str) + class TestAutocomplete(unittest.TestCase): def test_object(self):