Created
October 17, 2016 01:48
-
-
Save jorgemdnt/223938e6642017147669524f8fb34f3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
from urllib import urlencode | |
from star_wars.exceptions import PersonagemNaoEncontradoException | |
# [...] StarWarsGatewaySWAPI | |
def buscar_personagem(self, nome): | |
recurso = 'people/?' | |
parametros_de_busca = urlencode({'search': nome}) | |
url_completa = self.URL + recurso + parametros_de_busca | |
response = self.client.get(url_completa) | |
conteudo = response.json() | |
if conteudo['count'] == 0: | |
raise PersonagemNaoEncontradoException(nome) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment