Refactored rulings.
This commit is contained in:
parent
5bb912da76
commit
d92aad46b6
|
@ -2,6 +2,8 @@ from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Mtgo(RulingsObject):
|
class Mtgo(RulingsObject):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.id = kwargs.get('id')
|
if kwargs.get('id') is None:
|
||||||
self.url = 'cards/mtgo/{}/rulings'.format(self.id)
|
raise TypeError('No id provided to search by')
|
||||||
|
|
||||||
|
self.url = 'cards/mtgo/{}/rulings'.format(str(kwargs.get('id')))
|
||||||
super(Mtgo, self).__init__(self.url)
|
super(Mtgo, self).__init__(self.url)
|
||||||
|
|
|
@ -2,6 +2,8 @@ from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Multiverse(RulingsObject):
|
class Multiverse(RulingsObject):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.id = str(kwargs.get('id'))
|
if kwargs.get('id') is None:
|
||||||
self.url = 'cards/multiverse/{}/rulings'.format(self.id)
|
raise TypeError('No id provided to search by')
|
||||||
|
|
||||||
|
self.url = 'cards/multiverse/{}/rulings'.format(str(kwargs.get('id')))
|
||||||
super(Multiverse, self).__init__(self.url)
|
super(Multiverse, self).__init__(self.url)
|
||||||
|
|
|
@ -3,8 +3,6 @@ import aiohttp
|
||||||
|
|
||||||
class RulingsObject(object):
|
class RulingsObject(object):
|
||||||
def __init__(self, _url, **kwargs):
|
def __init__(self, _url, **kwargs):
|
||||||
self.pretty = kwargs.get('pretty', 'None')
|
|
||||||
self.format = kwargs.get('format', 'None')
|
|
||||||
self._url = 'https://api.scryfall.com/' + _url
|
self._url = 'https://api.scryfall.com/' + _url
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
self.session = aiohttp.ClientSession(loop=loop)
|
self.session = aiohttp.ClientSession(loop=loop)
|
||||||
|
@ -16,8 +14,8 @@ class RulingsObject(object):
|
||||||
self.scryfallJson = loop.run_until_complete(getRequest(
|
self.scryfallJson = loop.run_until_complete(getRequest(
|
||||||
url = self._url,
|
url = self._url,
|
||||||
params={
|
params={
|
||||||
'format': self.format,
|
'format': kwargs.get('format', 'json'),
|
||||||
'pretty': self.pretty
|
'pretty': kwargs.get('pretty', 'false')
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if self.scryfallJson['object'] == 'error':
|
if self.scryfallJson['object'] == 'error':
|
||||||
|
|
|
@ -2,6 +2,8 @@ from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Id(RulingsObject):
|
class Id(RulingsObject):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.id = str(kwargs.get('id'))
|
if kwargs.get('id') is None:
|
||||||
self.url = 'cards/{}/rulings'.format(self.id)
|
raise TypeError('No id provided to search by')
|
||||||
|
|
||||||
|
self.url = 'cards/{}/rulings'.format(str(kwargs.get('id')))
|
||||||
super(Id, self).__init__(self.url)
|
super(Id, self).__init__(self.url)
|
||||||
|
|
|
@ -2,7 +2,5 @@ from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Code(RulingsObject):
|
class Code(RulingsObject):
|
||||||
def __init__(self, code, collector_number):
|
def __init__(self, code, collector_number):
|
||||||
self.code = code.lower()
|
self.url = 'cards/{}/{}/rulings'.format(code.lower(), str(collector_number))
|
||||||
self.number = str(collector_number)
|
|
||||||
self.url = 'cards/{}/{}/rulings'.format(self.code, self.number)
|
|
||||||
super(Code, self).__init__(self.url)
|
super(Code, self).__init__(self.url)
|
||||||
|
|
Loading…
Reference in New Issue