Refactored cards.
This commit is contained in:
parent
91a5f04113
commit
5bb912da76
|
@ -3,8 +3,11 @@ import urllib.parse
|
|||
|
||||
class Autocomplete(CardsObject):
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('q') is None:
|
||||
raise TypeError('No query provided to search by')
|
||||
|
||||
self.dict = {
|
||||
'q': kwargs.get('query', ''),
|
||||
'q': kwargs.get('q'),
|
||||
'pretty': kwargs.get('pretty', 'false'),
|
||||
'format': kwargs.get('format', 'json')
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ from .cards_object import CardsObject
|
|||
|
||||
class Id(CardsObject):
|
||||
def __init__(self, **kwargs):
|
||||
self.id = kwargs.get('id')
|
||||
self.url = 'cards/' + str(self.id)
|
||||
if kwargs.get('id') is None:
|
||||
raise TypeError('No id provided to search by')
|
||||
|
||||
self.url = 'cards/' + str(kwargs.get('id'))
|
||||
super(Id, self).__init__(self.url)
|
||||
|
|
|
@ -2,7 +2,8 @@ from .cards_object import CardsObject
|
|||
|
||||
class Collector(CardsObject):
|
||||
def __init__(self, **kwargs):
|
||||
self.code = kwargs.get('code')
|
||||
self.collector_number = kwargs.get('collector_number')
|
||||
self.url = 'cards/{}/{}'.format(self.code, str(self.collector_number))
|
||||
if kwargs.get('code') is None:
|
||||
raise TypeError('No code provided to search by')
|
||||
|
||||
self.url = 'cards/{}/{}'.format(kwargs.get('code'), str(kwargs.get('collector_number')))
|
||||
super(Collector, self).__init__(self.url)
|
||||
|
|
|
@ -3,6 +3,7 @@ import urllib.parse
|
|||
|
||||
class Mtgo(CardsObject):
|
||||
def __init__(self, **kwargs):
|
||||
self.mtgoid = kwargs.get('id')
|
||||
self.url = 'cards/mtgo/' + str(self.mtgoid)
|
||||
if kwargs.get('id') is None:
|
||||
raise TypeError('No id provided to search by')
|
||||
self.url = 'cards/mtgo/' + str(kwargs.get('id'))
|
||||
super(Mtgo, self).__init__(self.url)
|
||||
|
|
|
@ -2,6 +2,7 @@ from .cards_object import CardsObject
|
|||
|
||||
class Multiverse(CardsObject):
|
||||
def __init__(self, **kwargs):
|
||||
self.multiverseid = kwargs.get('id')
|
||||
self.url = 'cards/multiverse/' + self.multiverseid
|
||||
if kwargs.get('id') is None:
|
||||
raise TypeError('No id provided to search by')
|
||||
self.url = 'cards/multiverse/' + kwargs.get('id')
|
||||
super(Multiverse, self).__init__(self.url)
|
||||
|
|
|
@ -3,19 +3,11 @@ import urllib.parse
|
|||
|
||||
class Named(CardsObject):
|
||||
def __init__(self, **kwargs):
|
||||
self.exact = kwargs.get('exact')
|
||||
self.fuzzy = kwargs.get('fuzzy')
|
||||
self.set = kwargs.get('set', 'None')
|
||||
self.dict = {}
|
||||
|
||||
if self.exact is not None:
|
||||
self.dict['exact'] = self.exact
|
||||
|
||||
if self.fuzzy is not None:
|
||||
self.dict['fuzzy'] = self.fuzzy
|
||||
|
||||
if self.set is not None:
|
||||
self.dict['set'] = self.set
|
||||
self.dict = {
|
||||
'exact':kwargs.get('exact', ''),
|
||||
'fuzzy':kwargs.get('fuzzy', ''),
|
||||
'set':kwargs.get('set', 'none')
|
||||
}
|
||||
|
||||
self.args = urllib.parse.urlencode(self.dict)
|
||||
self.url = 'cards/named?' + self.args
|
||||
|
|
|
@ -3,19 +3,16 @@ import urllib.parse
|
|||
|
||||
class Search(CardsObject):
|
||||
def __init__(self, **kwargs):
|
||||
self.q = kwargs.get('q', 'None')
|
||||
self.order = kwargs.get('order', 'None')
|
||||
self.unique = kwargs.get('unique', 'False')
|
||||
self.dir = kwargs.get('dir', 'Auto')
|
||||
self.include_extras = kwargs.get('include_extras', 'False')
|
||||
self.page = kwargs.get('page', '1')
|
||||
if kwargs.get('q') is None:
|
||||
raise TypeError('No query is specified.')
|
||||
|
||||
self.dict = {
|
||||
'q':self.q,
|
||||
'order':self.order,
|
||||
'unique':self.unique,
|
||||
'dir':self.dir,
|
||||
'include_extras':self.include_extras,
|
||||
'page':self.page
|
||||
'q':kwargs.get('q'),
|
||||
'order':kwargs.get('order', 'none'),
|
||||
'unique':kwargs.get('unique', 'none'),
|
||||
'dir':kwargs.get('dir', 'none'),
|
||||
'include_extras':kwargs.get('include_extras', 'false'),
|
||||
'page':kwargs.get('page', '1')
|
||||
}
|
||||
|
||||
self.args = urllib.parse.urlencode(self.dict)
|
||||
|
|
Loading…
Reference in New Issue