spei-python 0.15.3__tar.gz → 0.16.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {spei_python-0.15.3 → spei_python-0.16.0}/PKG-INFO +1 -1
- {spei_python-0.15.3 → spei_python-0.16.0}/pyproject.toml +2 -2
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/client.py +11 -3
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/requests/orden.py +7 -5
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/requests/respuesta.py +7 -5
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/resources/orden.py +3 -3
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/resources/respuesta.py +3 -3
- spei_python-0.16.0/spei/responses/__init__.py +7 -0
- spei_python-0.16.0/spei/responses/orden.py +29 -0
- spei_python-0.16.0/spei/responses/respuesta.py +29 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/README.md +0 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/README.md +0 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/__init__.py +0 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/errors.py +0 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/mappings.py +0 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/requests/__init__.py +0 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/resources/__init__.py +0 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/resources/mensaje.py +0 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/types.py +0 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/utils.py +0 -0
- {spei_python-0.15.3 → spei_python-0.16.0}/spei/validators.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "spei-python"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.16.0"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = ["gonz <gonzasestopal@gmail.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -32,7 +32,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
32
32
|
|
|
33
33
|
[tool.commitizen]
|
|
34
34
|
name = "cz_conventional_commits"
|
|
35
|
-
version = "0.
|
|
35
|
+
version = "0.16.0"
|
|
36
36
|
tag_format = "v$version"
|
|
37
37
|
bump_message = "bump: Semantic Release Bot: Release Version: $new_version 🤖🚀 [skip ci]"
|
|
38
38
|
version_files = [
|
|
@@ -8,10 +8,12 @@ from cryptography.hazmat.primitives.asymmetric import padding
|
|
|
8
8
|
from cryptography.hazmat.primitives.hashes import SHA256
|
|
9
9
|
|
|
10
10
|
from spei.requests import OrdenRequest
|
|
11
|
-
from spei.resources import Orden
|
|
11
|
+
from spei.resources import Orden
|
|
12
|
+
from spei.responses import RespuestaResponse
|
|
12
13
|
from spei.utils import format_data
|
|
13
14
|
|
|
14
15
|
logger = logging.getLogger('spei')
|
|
16
|
+
logger.setLevel(logging.DEBUG)
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
class BaseClient(object):
|
|
@@ -53,11 +55,17 @@ class BaseClient(object):
|
|
|
53
55
|
|
|
54
56
|
return base64.b64encode(signed_message)
|
|
55
57
|
|
|
56
|
-
def registra_orden(
|
|
58
|
+
def registra_orden(
|
|
59
|
+
self,
|
|
60
|
+
orden_data,
|
|
61
|
+
orden_cls=Orden,
|
|
62
|
+
respuesta_response_cls=RespuestaResponse,
|
|
63
|
+
):
|
|
57
64
|
checksum = self.generate_checksum(orden_data)
|
|
58
65
|
orden = orden_cls(op_firma_dig=checksum, **orden_data)
|
|
59
66
|
soap_request = OrdenRequest(orden)
|
|
67
|
+
logger.info(soap_request)
|
|
60
68
|
response = self.session.post(data=soap_request, url=self.host)
|
|
61
69
|
logger.info(response.text)
|
|
62
70
|
response.raise_for_status()
|
|
63
|
-
return
|
|
71
|
+
return respuesta_response_cls(response.text)
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from lxml import etree
|
|
2
2
|
|
|
3
|
+
from spei.resources import Orden
|
|
4
|
+
|
|
3
5
|
SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/'
|
|
4
6
|
PRAXIS_NS = 'http://www.praxis.com.mx/'
|
|
5
7
|
|
|
6
8
|
|
|
7
|
-
class
|
|
9
|
+
class OrdenPagoElement(object):
|
|
8
10
|
def __new__(cls, element):
|
|
9
11
|
ordenpago = etree.Element(etree.QName(PRAXIS_NS, 'ordenpago'))
|
|
10
12
|
mensaje = etree.tostring(
|
|
@@ -16,14 +18,14 @@ class OrdenPago(object):
|
|
|
16
18
|
return ordenpago
|
|
17
19
|
|
|
18
20
|
|
|
19
|
-
class
|
|
21
|
+
class BodyElement(object):
|
|
20
22
|
def __new__(cls, orden_pago):
|
|
21
23
|
body = etree.Element(etree.QName(SOAP_NS, 'Body'))
|
|
22
24
|
body.append(orden_pago)
|
|
23
25
|
return body
|
|
24
26
|
|
|
25
27
|
|
|
26
|
-
class
|
|
28
|
+
class EnvelopeElement(object):
|
|
27
29
|
def __new__(cls, body):
|
|
28
30
|
namespaces_uris = {
|
|
29
31
|
'soapenv': SOAP_NS,
|
|
@@ -38,8 +40,8 @@ class Envelope(object):
|
|
|
38
40
|
|
|
39
41
|
|
|
40
42
|
class OrdenRequest(object):
|
|
41
|
-
def __new__(cls, mensaje, as_string=True):
|
|
42
|
-
envelope =
|
|
43
|
+
def __new__(cls, mensaje: Orden, as_string=True):
|
|
44
|
+
envelope = EnvelopeElement(BodyElement(OrdenPagoElement(mensaje.build_xml())))
|
|
43
45
|
if not as_string:
|
|
44
46
|
return envelope
|
|
45
47
|
return etree.tostring(envelope, xml_declaration=True)
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from lxml import etree
|
|
2
2
|
|
|
3
|
+
from spei.resources import Respuesta
|
|
4
|
+
|
|
3
5
|
SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/'
|
|
4
6
|
PRAXIS_NS = 'http://www.praxis.com.mx/'
|
|
5
7
|
|
|
6
8
|
|
|
7
|
-
class
|
|
9
|
+
class RespuestaElement(object):
|
|
8
10
|
def __new__(cls, element):
|
|
9
11
|
respuesta = etree.Element(
|
|
10
12
|
etree.QName(PRAXIS_NS, 'respuesta'),
|
|
@@ -19,14 +21,14 @@ class Respuesta(object):
|
|
|
19
21
|
return respuesta
|
|
20
22
|
|
|
21
23
|
|
|
22
|
-
class
|
|
24
|
+
class BodyElement(object):
|
|
23
25
|
def __new__(cls, respuesta):
|
|
24
26
|
body = etree.Element(etree.QName(SOAP_NS, 'Body'))
|
|
25
27
|
body.append(respuesta)
|
|
26
28
|
return body
|
|
27
29
|
|
|
28
30
|
|
|
29
|
-
class
|
|
31
|
+
class EnvelopeElement(object):
|
|
30
32
|
def __new__(cls, body):
|
|
31
33
|
etree.register_namespace('S', SOAP_NS)
|
|
32
34
|
envelope = etree.Element(etree.QName(SOAP_NS, 'Envelope'))
|
|
@@ -35,8 +37,8 @@ class Envelope(object):
|
|
|
35
37
|
|
|
36
38
|
|
|
37
39
|
class RespuestaRequest(object):
|
|
38
|
-
def __new__(cls, mensaje, as_string=True):
|
|
39
|
-
envelope =
|
|
40
|
+
def __new__(cls, mensaje: Respuesta, as_string=True):
|
|
41
|
+
envelope = RespuestaElement(mensaje.build_xml())
|
|
40
42
|
if not as_string:
|
|
41
43
|
return envelope
|
|
42
44
|
return etree.tostring(envelope, xml_declaration=True)
|
|
@@ -131,12 +131,12 @@ class Orden(BaseModel):
|
|
|
131
131
|
return mensaje
|
|
132
132
|
|
|
133
133
|
@classmethod
|
|
134
|
-
def parse_xml(cls,
|
|
135
|
-
ordenpago =
|
|
134
|
+
def parse_xml(cls, mensaje_element):
|
|
135
|
+
ordenpago = mensaje_element.find('ordenpago')
|
|
136
136
|
|
|
137
137
|
orden_data = {
|
|
138
138
|
'id': ordenpago.attrib['Id'],
|
|
139
|
-
'categoria':
|
|
139
|
+
'categoria': mensaje_element.attrib['categoria'],
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
for element in ordenpago.getchildren():
|
|
@@ -33,11 +33,11 @@ class Respuesta(BaseModel):
|
|
|
33
33
|
return mensaje
|
|
34
34
|
|
|
35
35
|
@classmethod
|
|
36
|
-
def parse_xml(cls,
|
|
37
|
-
respuesta =
|
|
36
|
+
def parse_xml(cls, mensaje_element):
|
|
37
|
+
respuesta = mensaje_element.find('respuesta')
|
|
38
38
|
|
|
39
39
|
respuesta_data = {
|
|
40
|
-
'categoria':
|
|
40
|
+
'categoria': mensaje_element.attrib['categoria'],
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
for sub_element in respuesta.getchildren():
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from lxml import etree
|
|
2
|
+
|
|
3
|
+
from spei.resources import Orden
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class MensajeElement(object):
|
|
7
|
+
def __new__(cls, ordenpago, orden_cls: Orden = Orden):
|
|
8
|
+
mensaje = etree.fromstring( # noqa: S320
|
|
9
|
+
bytes(ordenpago.text, encoding='cp850'),
|
|
10
|
+
)
|
|
11
|
+
return orden_cls.parse_xml(mensaje)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class OrdenPagoElement(object):
|
|
15
|
+
def __new__(cls, body):
|
|
16
|
+
return body.find('{http://www.praxis.com.mx/}ordenpago')
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BodyElement(object):
|
|
20
|
+
def __new__(cls, mensaje):
|
|
21
|
+
return mensaje.find(
|
|
22
|
+
'{http://schemas.xmlsoap.org/soap/envelope/}Body',
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class OrdenResponse(object):
|
|
27
|
+
def __new__(cls, orden):
|
|
28
|
+
mensaje = etree.fromstring(orden) # noqa: S320
|
|
29
|
+
return MensajeElement(OrdenPagoElement(BodyElement(mensaje)))
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from lxml import etree
|
|
2
|
+
|
|
3
|
+
from spei.resources import Respuesta
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class MensajeElement(object):
|
|
7
|
+
def __new__(cls, respuesta, respuesta_cls: Respuesta = Respuesta):
|
|
8
|
+
mensaje = etree.fromstring( # noqa: S320
|
|
9
|
+
bytes(respuesta.text, encoding='cp850'),
|
|
10
|
+
)
|
|
11
|
+
return respuesta_cls.parse_xml(mensaje)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class RespuestaElement(object):
|
|
15
|
+
def __new__(cls, body):
|
|
16
|
+
return body.find('{http://www.praxis.com.mx/}respuesta')
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BodyElement(object):
|
|
20
|
+
def __new__(cls, mensaje):
|
|
21
|
+
return mensaje.find(
|
|
22
|
+
'{http://schemas.xmlsoap.org/soap/envelope/}Body',
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class RespuestaResponse(object):
|
|
27
|
+
def __new__(cls, respuesta):
|
|
28
|
+
mensaje = etree.fromstring(respuesta) # noqa: S320
|
|
29
|
+
return MensajeElement(RespuestaElement(BodyElement((mensaje))))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|