2018-10-24 01:39:07 +00:00
|
|
|
import sys
|
|
|
|
sys.path.append('..')
|
|
|
|
from scrython.foundation import FoundationObject
|
2018-02-17 01:43:56 +00:00
|
|
|
|
2018-10-24 01:39:07 +00:00
|
|
|
class CatalogsObject(FoundationObject):
|
2018-10-22 14:19:38 +00:00
|
|
|
"""
|
|
|
|
Master object for all catalog objects.
|
2018-02-21 23:13:55 +00:00
|
|
|
|
2018-10-24 02:43:36 +00:00
|
|
|
Args:
|
|
|
|
format (string, optional):
|
|
|
|
Defaults to 'json'.
|
|
|
|
Returns data in the specified method.
|
|
|
|
pretty (string, optional):
|
|
|
|
Defaults to empty string.
|
|
|
|
Returns a prettier version of the json object.
|
|
|
|
Note that this may break functionality with Scrython.
|
2018-10-22 14:19:38 +00:00
|
|
|
"""
|
2018-02-17 01:43:56 +00:00
|
|
|
|
2018-10-22 14:19:38 +00:00
|
|
|
def object(self):
|
2018-10-24 02:43:36 +00:00
|
|
|
"""Returns the type of object it is
|
|
|
|
(card, error, etc)
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
string
|
|
|
|
"""
|
2018-10-24 01:39:07 +00:00
|
|
|
super(CatalogsObject, self)._checkForKey('object')
|
2018-02-17 01:43:56 +00:00
|
|
|
|
2018-10-22 14:19:38 +00:00
|
|
|
return self.scryfallJson['object']
|
2018-02-17 01:43:56 +00:00
|
|
|
|
2018-10-22 14:19:38 +00:00
|
|
|
def uri(self):
|
2018-10-24 02:43:36 +00:00
|
|
|
"""The API URI for the endpoint you've called.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
string
|
|
|
|
"""
|
2018-10-24 01:39:07 +00:00
|
|
|
super(CatalogsObject, self)._checkForKey('uri')
|
2018-02-17 01:43:56 +00:00
|
|
|
|
2018-10-22 14:19:38 +00:00
|
|
|
return self.scryfallJson['uri']
|
2018-02-17 01:43:56 +00:00
|
|
|
|
2018-10-22 14:19:38 +00:00
|
|
|
def total_values(self):
|
2018-10-24 02:43:36 +00:00
|
|
|
"""The number of items in `data()`
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
integer
|
|
|
|
"""
|
2018-10-24 01:39:07 +00:00
|
|
|
super(CatalogsObject, self)._checkForKey('total_values')
|
2018-02-17 01:43:56 +00:00
|
|
|
|
2018-10-22 14:19:38 +00:00
|
|
|
return self.scryfallJson['total_values']
|
2018-02-17 01:43:56 +00:00
|
|
|
|
2018-10-22 14:19:38 +00:00
|
|
|
def data(self):
|
2018-10-24 02:43:36 +00:00
|
|
|
"""A list of all types returned by the endpoint
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
list
|
|
|
|
"""
|
2018-10-24 01:39:07 +00:00
|
|
|
super(CatalogsObject, self)._checkForKey('data')
|
2018-02-17 01:43:56 +00:00
|
|
|
|
2018-10-22 14:19:38 +00:00
|
|
|
return self.scryfallJson['data']
|