olist / correios Goto Github PK
View Code? Open in Web Editor NEWA client library for Brazilian Correios APIs and services (SIGEP & SRO).
License: Apache License 2.0
A client library for Brazilian Correios APIs and services (SIGEP & SRO).
License: Apache License 2.0
Hi,
I'm having this error when I try to query any CEPs. I ran update-correios-wsdl, but this error continues.
Here is the StackTrace:
Traceback (most recent call last):
File "/home/lucas/anaconda3/lib/python3.6/site-packages/zeep/xsd/valueobjects.py", line 138, in getattribute
return self.values[key]
KeyError: 'id'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/lucas/anaconda3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/home/lucas/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/lucas/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/run/media/lucas/COMMON/programas/python/labengsoft/mainapp/views.py", line 58, in enderecoByCepView
endereco = serializers.serialize ('json', [ Endereco.getEnderecoByCep(str(cep)) ])
File "/run/media/lucas/COMMON/programas/python/labengsoft/mainapp/models.py", line 186, in getEnderecoByCep
zip = cliente.find_zipcode(ZipCode(cep))
File "/home/lucas/anaconda3/lib/python3.6/site-packages/correios/client.py", line 153, in find_zipcode
return self.model_builder.build_zip_address(zip_address_data)
File "/home/lucas/anaconda3/lib/python3.6/site-packages/correios/models/builders.py", line 98, in build_zip_address
id=zip_address_data.id,
File "/home/lucas/anaconda3/lib/python3.6/site-packages/zeep/xsd/valueobjects.py", line 142, in getattribute
self.class.name, key))
AttributeError: enderecoERP instance has no attribute 'id'
Any advice?
Thanks.
Olá, há um serviço de pedágio aqui?
Preciso de duas interfaces.
Olá, quando tento enviar um pacote do tipo caixa recebo erro ERP-041. Segue dados do pacote:
PACKAGE_BOX_TEST = {
'package_type': Package.TYPE_BOX,
'width': 16, 'height': 16, 'length': 16,
'weight': 2500, 'service': data.SERVICE_PAC
}
O mesmo ocorre para serviço SEDEX.
Traceback:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-14-f33a7ad6df60> in <module>()
----> 1 cs.get_tracking_code_events(['DU05508759BR'])[0].events
/home/luiz/devel/olist/correios-tracking-service/tracking_service/services.py in get_tracking_code_events(self, codes)
52 try:
53 from correios.models.posting import TrackingCode
---> 54 tracking_code = self.correios.get_tracking_code_events(code)
55 except InvalidTrackingCodeError as exc:
56 logger.exception(exc, 'tracking_code:', code)
/home/luiz/devel/olist/correios/correios/client.py in get_tracking_code_events(self, tracking_list)
356
357 response = self.websro.buscaEventosLista(self.username, self.password, "L", "T", "101", tuple(tracking_codes.keys()))
--> 358 return self.model_builder.load_tracking_events(tracking_codes, response)
/home/luiz/devel/olist/correios/correios/client.py in load_tracking_events(self, tracking_codes, response)
126 for tracked_object in response.objeto:
127 tracking_code = tracking_codes[tracked_object.numero]
--> 128 tracking_code.category = tracked_object.categoria
129 tracking_code.name = tracked_object.nome
130 tracking_code.initials = tracked_object.sigla
AttributeError: 'objeto' object has no attribute 'categoria'
Example of tracking codes that causes this problem:
PJ25750601BR
PJ25750604BR
PJ25750600BR
PJ25750603BR
PJ25750599BR
PJ25750602BR
PJ25750584BR
PJ25750583BR
DU05508760BR
DU05508759BR
O que vocês acham de usar uma lib como essa para facilitar o mapeamento das entidades dos Correios?
Ola' pessoal. Ao tentar acesso via API, com todas os dados necessarios preenchidos (usuario, senha, codigo adm, contrato, codigo de servico, cartao, CNPJ), recebemos essa mensagem:
error: correios.exceptions.ClientError: Não foi possível obter as etiquetas solicitadas.
Esse erro pode estar relacionado a algum problema interno da API? Existe algum usuario de teste?
when using the method find_zipcode from client.py, an exception is being raised whenever a valid zipcode is entered.
// invalid zipcodes
client.find_zipcode(ZipCode('01310-92'))
*** correios.exceptions.InvalidZipCodeError: Invalid zipcode 01310-92
client.find_zipcode(ZipCode('99999-999'))
*** correios.exceptions.ClientError: CEP INVÁLIDO
// valid zipcode
client.find_zipcode(ZipCode('01310-920'))
*** zeep.exceptions.XMLParseError: Unexpected element 'uf', expected 'id'
any advice?
thanks in advance
Olá.
Muito obrigado pela lib.
Fiquei na dúvida se há alguma possibilidade de receber uma notificação quando há atualização de status da encomenda nos correios.
Caso contrário, poderia fazer sentido subir um worker para consultas periódicas?
Obrigado.
It would be nice to include some examples:
It would be nice to use zeep instead of suds
!
Zeep has support to aiohttp
and this is so cool!
What do you think about this?
import logging
from requests import Session
from zeep import Client, Transport
logger = logging.getLogger(__name__)
class SoapClient(Client):
def __init__(
self,
wsdl,
cert=None,
verify=True,
timeout=8,
username=None,
password=None,
*args,
**kwargs
):
session = Session()
session.cert = cert
session.verify = verify
session.timeout = timeout
session.auth = (username, password)
session.headers.update({"Content-Type": "text/xml;charset=UTF-8"})
transport = Transport(
operation_timeout=timeout,
session=session
)
super().__init__(wsdl=wsdl, transport=transport, **kwargs)
We are having problems with wsdl reading time.
When creating an instance of the Mail class, the flow is reading the wsdl in the mail endpoint.
It would be better if reading this wsdl could be local file, it would improve the response time to instantiate the object.
Car@s,
Nós precisamos utilizar o código 03220 (Sedex Contrato), que não consta em correios.modeles.data.
Vocês poderiam me ajudar a estender o data.py?
https://github.com/olist/correios/blob/master/correios/models/data.py
The IATA coefficient is set with value 6.0 and should be 6000.
The calculus of cubic weight is here
Call "solicitaXmlPlp" remote method and parse/build the response to construct a PostingList object.
Este código esta funcionando em PHP 5, 5.6, 7.0, 7.1 ou até mesmo em 7.2 ?
São muitas dúvidas e nada pessoal... (Já deixo claro)
Este código esta nas normativas novas dos correios (2017) e que pelo visto já existe novas normativas em (2018)...
Bom, este não é o único que visualizamos que aparentemente esta tudo correto.
Mas, tenho que ser este USUÁRIO questionador, já que estamos enfrentando tantos problemas seja eles em PHP, AJAX ou qualquer impulso anterior á 2017.
E assim vem as dúvidas...
Espero que tenhamos uma resposta satisfatória e um UPGRADE.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.