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