Created
November 12, 2018 20:36
-
-
Save farnetani/c0f852f5d687496e7cb773df7a693c41 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def carregarDadosCNPJ(**kwargs): | |
# r = requests.get('https://www.receitaws.com.br/v1/cnpj/{cnpj}'.format(cnpj=kwargs['cnpj'])) | |
r = requests.get('https://www.receitaws.com.br/v1/cnpj/{cnpj}/days/10000'.format(cnpj=kwargs['cnpj']), headers = {'Authorization': 'Bearer token'}) | |
if r.status_code == 200: | |
data = r.json() | |
if data.get('status', None) == 'ERROR': | |
return False, data.get('message', None) | |
cliente = dict(cnpj=kwargs['cnpj'], | |
responsavel=kwargs['responsavel'], | |
telefone=kwargs['telefone'], | |
email=kwargs['email'], | |
razaosocial=data['nome'], | |
nomefantasia=data['fantasia'], | |
endereco=data['logradouro'], | |
numero=data['numero'], | |
complemento=data['complemento'], | |
bairro=data['bairro'], | |
cep=re.sub("\D", "", data['cep']), | |
cidade=data['municipio'], | |
uf=data['uf'], | |
gerado_web=True, | |
validado=False) | |
return True, cliente | |
else: | |
return False, None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment