spei-python 0.46.0__py3-none-any.whl → 0.47.0__py3-none-any.whl

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.
@@ -5,6 +5,7 @@ from spei.resources.acuse import ( # noqa: F401
5
5
  ResultadoServidor,
6
6
  )
7
7
  from spei.resources.cda import CDA # noqa: F401
8
+ from spei.resources.ensesion import Ensesion, Institucion # noqa: F401
8
9
  from spei.resources.mensaje import Mensaje # noqa: F401
9
10
  from spei.resources.orden import Orden # noqa: F401
10
11
  from spei.resources.payments import TerceroATercero # noqa: F401
@@ -0,0 +1,50 @@
1
+ from typing import List
2
+
3
+ from pydantic import BaseModel
4
+
5
+ from spei import types
6
+ from spei.utils import to_snake_case # noqa: WPS347
7
+
8
+
9
+ class Institucion(BaseModel):
10
+ clave_cesif: str
11
+ ins_nombre: str
12
+ estado_receptivo: str
13
+ estado_institucion: str
14
+
15
+ @classmethod
16
+ def parse_xml(cls, institucion_info):
17
+ return cls(
18
+ clave_cesif=institucion_info.find('clave_cesif').text,
19
+ ins_nombre=institucion_info.find('ins_nombre').text,
20
+ estado_receptivo=institucion_info.find('estado_receptivo').text,
21
+ estado_institucion=institucion_info.find('estado_institucion').text,
22
+ )
23
+
24
+
25
+ class Ensesion(BaseModel):
26
+ categoria: types.CategoriaOrdenPago
27
+ fecha_operacion_banxico: int
28
+ inst_bancarias: List[Institucion]
29
+
30
+ @classmethod
31
+ def parse_xml(cls, mensaje_element):
32
+ ensesion_element = mensaje_element.find('ensesion')
33
+
34
+ ensesion_data = {
35
+ 'categoria': types.CategoriaOrdenPago.ensesion,
36
+ 'inst_bancarias': [],
37
+ }
38
+
39
+ for element in ensesion_element.getchildren():
40
+ tag = to_snake_case(element.tag)
41
+ if tag == 'inst_bancarias':
42
+ instituciones = element.xpath('//institucion')
43
+ for institucion_info in instituciones:
44
+ institucion = Institucion.parse_xml(institucion_info)
45
+ ensesion_data['inst_bancarias'].append(institucion)
46
+ continue
47
+ if tag in cls.__fields__:
48
+ ensesion_data[tag] = element.text
49
+
50
+ return cls(**ensesion_data)
spei/resources/mensaje.py CHANGED
@@ -16,20 +16,27 @@ class Mensaje(BaseModel):
16
16
  extra = Extra.allow
17
17
 
18
18
  @classmethod
19
- def parse_xml(cls, mensaje):
19
+ def parse_xml(cls, mensaje): # noqa: WPS210
20
+ parser = etree.XMLParser(recover=True)
20
21
  mensaje = etree.fromstring(mensaje) # noqa: S320
21
22
  body = mensaje.find(
22
23
  '{http://schemas.xmlsoap.org/soap/envelope/}Body',
23
24
  )
24
25
  ordenpago = body.find('{http://www.praxis.com.mx/}ordenpago')
25
26
  respuesta = body.find('{http://www.praxis.com.mx/}respuesta')
26
- ensesion = body.find('{http://www.praxis.com.mx/}ensesion')
27
27
 
28
28
  if ordenpago is not None:
29
29
  element = etree.fromstring( # noqa: S320
30
30
  bytes(ordenpago.text, encoding='cp850'),
31
+ parser,
31
32
  )
32
33
  categoria = element.attrib['categoria']
34
+
35
+ if categoria == CategoriaOrdenPago.ensesion:
36
+ return cls(
37
+ categoria=categoria, ensesion=element,
38
+ )
39
+
33
40
  return cls(categoria=categoria, ordenpago=element)
34
41
 
35
42
  if respuesta is not None:
@@ -39,6 +46,4 @@ class Mensaje(BaseModel):
39
46
  categoria = element.attrib['categoria']
40
47
  return cls(categoria=categoria, respuesta=element)
41
48
 
42
- return cls(
43
- ensesion=ensesion,
44
- )
49
+ raise NotImplementedError
spei/types/spei.py CHANGED
@@ -73,6 +73,7 @@ class PrioridadOrdenPago(str, Enum):
73
73
 
74
74
 
75
75
  class CategoriaOrdenPago(str, Enum):
76
+ ensesion = 'ENSESION'
76
77
  respuesta = 'RESPUESTA'
77
78
  cargar_odp = 'CARGAR_ODP'
78
79
  cargar_odp_respuesta = 'CARGAR_ODP_RESPUESTA'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spei-python
3
- Version: 0.46.0
3
+ Version: 0.47.0
4
4
  Summary:
5
5
  Author: tech
6
6
  Author-email: tech@fondeadora.com
@@ -16,10 +16,11 @@ spei/requests/acuse.py,sha256=uoik_Eo51zMEs9_mKHbKGFvyjvr-kwA-6y9dWw54a0Q,2249
16
16
  spei/requests/cda.py,sha256=RyVMnU19639BZyoccZeU39Rw8JmBLKmTkn8Zro9L7Ys,1156
17
17
  spei/requests/orden.py,sha256=iec7McxjUpJCB94_raStSSKMD1Od4AzrqoKj7uatGJk,1444
18
18
  spei/requests/respuesta.py,sha256=oH0EU4qJ7cPmYjMg5v_UBbZMf6ZdrXA7sZY7fOMtzs8,1724
19
- spei/resources/__init__.py,sha256=SFn2lP-ARYk8JNIkRQiBqyEpOxPRO9tLjldBfPLHYuU,415
19
+ spei/resources/__init__.py,sha256=cJL9KI0ZBKHcDN5me8yuvschQMW1HH_bpLS7TnLXZw4,487
20
20
  spei/resources/acuse.py,sha256=y7j2e99pJ7LYprZvhVpf_OTLONdtNJJ49uK_jddOCRg,5475
21
21
  spei/resources/cda.py,sha256=AHGPC6JUx9NYWAtJogxVDyXpISz_psOdfUiuD46h73g,2327
22
- spei/resources/mensaje.py,sha256=oTCqpP7GQFlnPSF8MJQJwqLjpPJxBn6yhf5W5sWO-8g,1426
22
+ spei/resources/ensesion.py,sha256=fky_ejeQ39x9kj8yMT3hi6ee4vQrAi6QtbjBJL-JA_c,1585
23
+ spei/resources/mensaje.py,sha256=aIgRzAPDrRWAuP6CaB2VOIrqjWpPnpYITw3P0tsbN18,1582
23
24
  spei/resources/orden.py,sha256=_m0pDnB51JA4GyxcmDtZVauuVvDLcKjAMgqXeMtrJKQ,6096
24
25
  spei/resources/payments.py,sha256=pt8xvwRUfcTq3jEFlnG28T4mE7MYpZSCkXgseqD22yY,8103
25
26
  spei/resources/respuesta.py,sha256=RKzkv52zLzm5BBjCyxrC75KZT9rUKFLwedd-JDZ3uNU,1188
@@ -30,9 +31,9 @@ spei/responses/respuesta.py,sha256=sbsoacmIqZdiFde0K5AuC7ypPD0lpi6HxpBA0C0K79Q,1
30
31
  spei/sice.py,sha256=gFypsZ0Z8jX-Ro0KOJ78PzoofkvH9L0p6WIEzvZQ0IY,1085
31
32
  spei/types/__init__.py,sha256=FKFSe-eTgKjf0qFSMqYZDkgYYIT3-5Je4Wc5QRNAp7U,643
32
33
  spei/types/sice.py,sha256=xFSoiLklRNWXoWwZXpSN8-SdkliNK23_MZbhcOc7a9s,222
33
- spei/types/spei.py,sha256=wutSaoK_2Jgebspc5Nh2p7mtWwWaveOWStCom_aLe0I,4668
34
+ spei/types/spei.py,sha256=KLs36lENOTotBkxV5RwEES7Cc73NA5Cd-nF6X-Mz6xE,4694
34
35
  spei/utils.py,sha256=Lje_sg6hLKQxsPmqf7ovVKKVcGZi7LlgNNg1MRtWnRo,247
35
36
  spei/validators.py,sha256=1b-brOmNesdiUi2X0LV0-Km4Sh6RGNeKNeAxshQXtOs,742
36
- spei_python-0.46.0.dist-info/METADATA,sha256=mgRtVNVNK-q_wGoXcOveLGhxaKtnMsMj3c6-oeYh9Zw,3812
37
- spei_python-0.46.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
38
- spei_python-0.46.0.dist-info/RECORD,,
37
+ spei_python-0.47.0.dist-info/METADATA,sha256=HgRSGsXmhvLNb7A0OVS77LkMudgZWGGrulCjqvH8wMY,3812
38
+ spei_python-0.47.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
39
+ spei_python-0.47.0.dist-info/RECORD,,