1
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
2
|
|
|
# ############################################################################# |
3
|
|
|
# |
4
|
|
|
# The MIT License (MIT) |
5
|
|
|
# |
6
|
|
|
# Copyright (c) 2016 Trocafone |
7
|
|
|
# |
8
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy |
9
|
|
|
# of this software and associated documentation files (the "Software"), to deal |
10
|
|
|
# in the Software without restriction, including without limitation the rights |
11
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
12
|
|
|
# copies of the Software, and to permit persons to whom the Software is |
13
|
|
|
# furnished to do so, subject to the following conditions: |
14
|
|
|
# |
15
|
|
|
# The above copyright notice and this permission notice shall be included in |
16
|
|
|
# all copies or substantial portions of the Software. |
17
|
|
|
# |
18
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
21
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
23
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
24
|
|
|
# SOFTWARE. |
25
|
|
|
# |
26
|
|
|
############################################################################### |
27
|
|
|
|
28
|
1 |
|
from correios_lib.base import EntityBase |
29
|
1 |
|
from correios_lib.validators import CEP, Email, Date |
30
|
1 |
|
from voluptuous import * |
|
|
|
|
31
|
|
|
|
32
|
|
|
|
33
|
1 |
|
class Destinatario(EntityBase): |
34
|
|
|
''' Reference to wsdl: ''' |
35
|
|
|
|
36
|
1 |
|
def get_schema(self): |
37
|
1 |
|
return Schema({ |
|
|
|
|
38
|
|
|
Required('nome'): All(Coerce(str), Length(max=60)), |
|
|
|
|
39
|
|
|
Required('logradouro'): All(Coerce(str), Length(max=72)), |
|
|
|
|
40
|
|
|
Required('numero'): All(Coerce(str), Length(max=8)), |
|
|
|
|
41
|
|
|
Optional('complemento'): All(Coerce(str), Length(max=30)), |
|
|
|
|
42
|
|
|
Required('bairro'): All(Coerce(str), Length(max=50)), |
|
|
|
|
43
|
|
|
Optional('referencia'): All(Coerce(str), Length(max=60)), |
|
|
|
|
44
|
|
|
Required('cidade'): All(Coerce(str), Length(max=36)), |
|
|
|
|
45
|
|
|
Required('uf'): All(Coerce(str), Length(min=2, max=2)), |
|
|
|
|
46
|
|
|
Required('cep'): All(CEP, Length(min=8, max=9)), |
|
|
|
|
47
|
|
|
Optional('ddd'): All(Coerce(str), Length(min=2, max=2)), |
|
|
|
|
48
|
|
|
Optional('telefone'): All(Coerce(str), Length(min=8, max=12)), |
|
|
|
|
49
|
|
|
Optional('email'): All(Email, Length(max=72)) |
|
|
|
|
50
|
|
|
}, extra=REMOVE_EXTRA) |
|
|
|
|
51
|
|
|
|
52
|
|
|
|
53
|
1 |
|
class Coleta(EntityBase): |
|
|
|
|
54
|
|
|
|
55
|
1 |
|
def get_schema(self): |
56
|
1 |
|
return Schema({ |
|
|
|
|
57
|
|
|
Required('tipo'): Any('CA', 'C', 'A'), |
|
|
|
|
58
|
|
|
Optional('numero'): Coerce(int), |
|
|
|
|
59
|
|
|
Optional('id_cliente'): All(Length(max=30)), |
|
|
|
|
60
|
|
|
Optional('ag'): Date, |
|
|
|
|
61
|
|
|
Optional('cartao'): Coerce(str), |
|
|
|
|
62
|
|
|
Optional('valor_declarado'): float, |
|
|
|
|
63
|
|
|
Optional('servico_adicional'): All(Coerce(str), Length(max=20)), |
|
|
|
|
64
|
|
|
Optional('descricao'): All(Coerce(str), Length(max=255)), |
|
|
|
|
65
|
|
|
Optional('ar'): Coerce(bool), |
|
|
|
|
66
|
|
|
Optional('cklist'): Any(2, 4, 5, 7), |
|
|
|
|
67
|
|
|
Optional('documento'): [str], |
|
|
|
|
68
|
|
|
Required('remetente'): Remetente, |
|
|
|
|
69
|
|
|
Optional('obj_col'): [Objeto], |
|
|
|
|
70
|
|
|
Optional('produto'): Produto |
|
|
|
|
71
|
|
|
}, extra=REMOVE_EXTRA) |
|
|
|
|
72
|
|
|
|
73
|
|
|
|
74
|
1 |
|
class Objeto(EntityBase): |
|
|
|
|
75
|
|
|
|
76
|
1 |
|
def get_schema(self): |
77
|
1 |
|
return Schema({ |
|
|
|
|
78
|
|
|
Required('item'): 1, |
|
|
|
|
79
|
|
|
Optional('id'): All(Coerce(str), Length(max=30)), |
|
|
|
|
80
|
|
|
Optional('desc'): All(Coerce(str), Length(max=255)), |
|
|
|
|
81
|
|
|
Optional('entrega'): All(Coerce(str), Length(max=13)), |
|
|
|
|
82
|
|
|
Optional('num'): All(Coerce(str), Length(max=13)), |
|
|
|
|
83
|
|
|
}, extra=REMOVE_EXTRA) |
|
|
|
|
84
|
|
|
|
85
|
|
|
|
86
|
1 |
|
class Produto(EntityBase): |
|
|
|
|
87
|
|
|
|
88
|
1 |
|
def get_schema(self): |
89
|
1 |
|
return Schema({ |
|
|
|
|
90
|
|
|
Optional('codigo'): Coerce(int), |
|
|
|
|
91
|
|
|
Optional('tipo'): Coerce(int), |
|
|
|
|
92
|
|
|
Optional('qtd'): Coerce(int) |
|
|
|
|
93
|
|
|
}, extra=REMOVE_EXTRA) |
|
|
|
|
94
|
|
|
|
95
|
|
|
|
96
|
1 |
|
class Remetente(EntityBase): |
|
|
|
|
97
|
|
|
|
98
|
1 |
|
def get_schema(self): |
99
|
1 |
|
return Schema({ |
|
|
|
|
100
|
|
|
Required('nome'): All(Coerce(str), Length(max=60)), |
|
|
|
|
101
|
|
|
Required('logradouro'): All(Coerce(str), Length(max=72)), |
|
|
|
|
102
|
|
|
Required('numero'): All(Coerce(str), Length(max=8)), |
|
|
|
|
103
|
|
|
Optional('complemento'): All(Coerce(str), Length(max=30)), |
|
|
|
|
104
|
|
|
Required('bairro'): All(Coerce(str), Length(max=50)), |
|
|
|
|
105
|
|
|
Optional('referencia'): All(Coerce(str), Length(max=60)), |
|
|
|
|
106
|
|
|
Required('cidade'): All(Coerce(str), Length(max=36)), |
|
|
|
|
107
|
|
|
Required('uf'): All(Coerce(str), Length(min=2, max=2)), |
|
|
|
|
108
|
|
|
Required('cep'): All(CEP, Length(min=8, max=9)), |
|
|
|
|
109
|
|
|
Required('ddd'): All(Coerce(str), Length(min=2, max=2)), |
|
|
|
|
110
|
|
|
Required('telefone'): All(Coerce(str), Length(min=8, max=12)), |
|
|
|
|
111
|
|
|
Required('email'): All(Email, Length(max=72)), |
|
|
|
|
112
|
|
|
Optional('celular'): All(Coerce(str), Length(max=9)), |
|
|
|
|
113
|
|
|
Optional('ddd_celular'): All(Coerce(str), Length(max=3)), |
|
|
|
|
114
|
|
|
Optional('sms'): Any('S', 'N'), |
|
|
|
|
115
|
|
|
Optional('identificacao'): All(Coerce(str), Length(max=14)) |
|
|
|
|
116
|
|
|
}, extra=REMOVE_EXTRA) |
|
|
|
|
117
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.