Skip to content

Commit

Permalink
Merge branch 'master' into imports
Browse files Browse the repository at this point in the history
  • Loading branch information
osantana committed Aug 29, 2017
2 parents 0fa33c0 + 244f42c commit 48d7d6e
Show file tree
Hide file tree
Showing 10 changed files with 5,263 additions and 5 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: help

help: ## This help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

update-wsdl: ## Update wsdl files
@curl -o 'correios/wsdls/AtendeCliente-production.wsdl' 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl'
@curl -o 'correios/wsdls/AtendeCliente-test.wsdl' 'https://apphom.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl'
@curl -o 'correios/wsdls/Rastro.wsdl' 'https://webservice.correios.com.br/service/rastro/Rastro.wsdl'
@curl -o 'correios/wsdls/CalcPrecoPrazo.asmx' 'http://ws.correios.com.br/calculador/CalcPrecoPrazo.asmx?WSDL'
@curl -o 'correios/wsdls/Rastro_schema1.xsd' 'https://webservice.correios.com.br/service/rastro/Rastro_schema1.xsd'
8 changes: 4 additions & 4 deletions correios/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ class Correios:

# 'environment': ('url', 'ssl_verification')
sigep_urls = {
'production': ("https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl", True),
'test': ("https://apphom.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl", False),
'production': (get_wsdl_path('AtendeCliente-production.wsdl'), True),
'test': (get_wsdl_path('AtendeCliente-test.wsdl'), False),
}
websro_url = "https://webservice.correios.com.br/service/rastro/Rastro.wsdl"
freight_url = "http://ws.correios.com.br/calculador/CalcPrecoPrazo.asmx?WSDL"
websro_url = get_wsdl_path('Rastro.wsdl')
freight_url = get_wsdl_path('CalcPrecoPrazo.asmx')

def __init__(self, username, password, timeout=8, environment="production"):
self.username = username
Expand Down
6 changes: 6 additions & 0 deletions correios/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,9 @@ def to_decimal(value: Union[Decimal, str, float], precision=2):

quantize = Decimal("0." + "0" * precision)
return value.quantize(quantize)


def get_wsdl_path(filename) -> str:
return os.path.abspath(
'correios/wsdls/{}'.format(filename)
)
2,010 changes: 2,010 additions & 0 deletions correios/wsdls/AtendeCliente-production.wsdl

Large diffs are not rendered by default.

2,014 changes: 2,014 additions & 0 deletions correios/wsdls/AtendeCliente-test.wsdl

Large diffs are not rendered by default.

1,022 changes: 1,022 additions & 0 deletions correios/wsdls/CalcPrecoPrazo.asmx

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions correios/wsdls/Rastro.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="rastro" targetNamespace="http://resource.webservice.correios.com.br/" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:tns="http://resource.webservice.correios.com.br/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema>
<xsd:import namespace="http://resource.webservice.correios.com.br/" schemaLocation="Rastro_schema1.xsd"/>
</xsd:schema>
</types>
<message name="buscaEventosListaResponse">
<part name="parameters" element="tns:buscaEventosListaResponse">
</part>
</message>
<message name="buscaEventosLista">
<part name="parameters" element="tns:buscaEventosLista">
</part>
</message>
<message name="buscaEventosResponse">
<part name="parameters" element="tns:buscaEventosResponse">
</part>
</message>
<message name="buscaEventos">
<part name="parameters" element="tns:buscaEventos">
</part>
</message>
<portType name="Service">
<operation name="buscaEventos">
<input message="tns:buscaEventos" wsam:Action="buscaEventos">
</input>
<output message="tns:buscaEventosResponse" wsam:Action="http://resource.webservice.correios.com.br/Service/buscaEventosResponse">
</output>
</operation>
<operation name="buscaEventosLista">
<input message="tns:buscaEventosLista" wsam:Action="buscaEventosLista">
</input>
<output message="tns:buscaEventosListaResponse" wsam:Action="http://resource.webservice.correios.com.br/Service/buscaEventosListaResponse">
</output>
</operation>
</portType>
<binding name="ServicePortBinding" type="tns:Service">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="buscaEventos">
<soap:operation soapAction="buscaEventos"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="buscaEventosLista">
<soap:operation soapAction="buscaEventosLista"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="rastro">
<port name="ServicePort" binding="tns:ServicePortBinding">
<soap:address location="http://webservice.correios.com.br:80/service/rastro"/>
</port>
</service>
</definitions>
125 changes: 125 additions & 0 deletions correios/wsdls/Rastro_schema1.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?><!--Generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, (build IBM 2.2.3-11/25/2013 12:35 PM(foreman)-)
See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> --><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://resource.webservice.correios.com.br/" version="1.0" targetNamespace="http://resource.webservice.correios.com.br/">

<xs:element name="buscaEventos" type="tns:buscaEventos"></xs:element>

<xs:element name="buscaEventosLista" type="tns:buscaEventosLista"></xs:element>

<xs:element name="buscaEventosListaResponse" type="tns:buscaEventosListaResponse"></xs:element>

<xs:element name="buscaEventosResponse" type="tns:buscaEventosResponse"></xs:element>

<xs:element name="destino" type="tns:destinos"></xs:element>

<xs:element name="endereco" type="tns:enderecoMobile"></xs:element>

<xs:element name="evento" type="tns:eventos"></xs:element>

<xs:element name="objeto" type="tns:objeto"></xs:element>

<xs:element name="rastro" type="tns:sroxml"></xs:element>

<xs:complexType name="buscaEventosLista">
<xs:sequence>
<xs:element name="usuario" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="senha" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="tipo" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="resultado" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="lingua" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="objetos" type="xs:string" minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="buscaEventosListaResponse">
<xs:sequence>
<xs:element name="return" type="tns:sroxml" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="sroxml">
<xs:sequence>
<xs:element name="versao" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="qtd" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="TipoPesquisa" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="TipoResultado" type="xs:string" minOccurs="0"></xs:element>
<xs:element ref="tns:objeto" minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="objeto">
<xs:sequence>
<xs:element name="numero" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="sigla" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="nome" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="categoria" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="erro" type="xs:string" minOccurs="0"></xs:element>
<xs:element ref="tns:evento" minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="eventos">
<xs:sequence>
<xs:element name="tipo" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="status" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="data" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="hora" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="descricao" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="detalhe" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="recebedor" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="documento" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="comentario" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="local" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="codigo" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="cidade" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="uf" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="sto" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="amazoncode" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="amazontimezone" type="xs:string" minOccurs="0"></xs:element>
<xs:element ref="tns:destino" minOccurs="0" maxOccurs="unbounded"></xs:element>
<xs:element ref="tns:endereco" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="destinos">
<xs:sequence>
<xs:element name="local" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="codigo" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="cidade" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="bairro" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="uf" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="enderecoMobile">
<xs:sequence>
<xs:element name="codigo" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="cep" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="logradouro" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="complemento" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="numero" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="localidade" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="uf" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="bairro" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="latitude" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="longitude" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="celular" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="buscaEventos">
<xs:sequence>
<xs:element name="usuario" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="senha" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="tipo" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="resultado" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="lingua" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="objetos" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="buscaEventosResponse">
<xs:sequence>
<xs:element name="return" type="tns:sroxml" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@vcr.use_cassette
def test_basic_client():
client = correios.Correios(username="sigep", password="XXXXXX", environment=correios.Correios.TEST)
assert client.sigep_url == "https://apphom.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl"
assert client.sigep_url == get_wsdl_path('AtendeCliente-test.wsdl')
assert not client.sigep_verify
assert client.username == "sigep"
assert client.password == "XXXXXX"
Expand Down
6 changes: 6 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,9 @@ def test_to_decimal_precision(v, p, r):
))
def test_to_integer(v, r):
assert to_integer(v) == r


def test_get_wsdl_file_path():
filepath = get_wsdl_path('fake')

assert 'correios/wsdls/fake' in filepath

0 comments on commit 48d7d6e

Please sign in to comment.