Updated search to be more consistent
This commit is contained in:
parent
75a3b1ce21
commit
d99a786642
|
@ -94,14 +94,29 @@ class Search(FoundationObject):
|
||||||
|
|
||||||
return self.scryfallJson['total_cards']
|
return self.scryfallJson['total_cards']
|
||||||
|
|
||||||
def data(self):
|
def data(self, index=None, key=None):
|
||||||
"""The data returned from the query
|
"""The data returned from the query
|
||||||
|
|
||||||
|
You may reference any keys that could be accessed in a card object.
|
||||||
|
There are far too many to list here, but you may find a list if applicable
|
||||||
|
keys in the documentation.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
index (integer, optional): Defaults to None. Access a specific index.
|
||||||
|
key (string, optional): Defaults to None. Returns the value of the given key. Requires the `index` argument.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list: A list of card objects
|
List: The full list of data.
|
||||||
|
Dictionary: If given an index.
|
||||||
|
String: If given an index and key.
|
||||||
"""
|
"""
|
||||||
super(Search, self)._checkForKey('data')
|
super(Search, self)._checkForKey('data')
|
||||||
|
|
||||||
|
if index is not None:
|
||||||
|
if key is not None:
|
||||||
|
super(Search, self)._checkForTupleKey('data', index, key)
|
||||||
|
return self.scryfallJson['data'][index][key]
|
||||||
|
|
||||||
return self.scryfallJson['data']
|
return self.scryfallJson['data']
|
||||||
|
|
||||||
def next_page(self):
|
def next_page(self):
|
||||||
|
@ -124,19 +139,6 @@ class Search(FoundationObject):
|
||||||
|
|
||||||
return len(self.scryfallJson['data'])
|
return len(self.scryfallJson['data'])
|
||||||
|
|
||||||
def data_tuple(self, num):
|
|
||||||
"""Accesses an object at the specified index
|
|
||||||
|
|
||||||
Args:
|
|
||||||
num (int): The index of the object in the `data` key
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict: The card object at the specified index
|
|
||||||
"""
|
|
||||||
super(Search, self)._checkForKey('data')
|
|
||||||
|
|
||||||
return self.scryfallJson['data'][num]
|
|
||||||
|
|
||||||
def has_more(self):
|
def has_more(self):
|
||||||
"""Determines if there are more pages of results.
|
"""Determines if there are more pages of results.
|
||||||
|
|
||||||
|
@ -145,4 +147,4 @@ class Search(FoundationObject):
|
||||||
"""
|
"""
|
||||||
super(Search, self)._checkForKey('has_more')
|
super(Search, self)._checkForKey('has_more')
|
||||||
|
|
||||||
return self.scryfallJson['has_more']
|
return self.scryfallJson['has_more']
|
||||||
|
|
Loading…
Reference in New Issue