spei-python 0.39.1__tar.gz → 0.40.1__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.
Files changed (39) hide show
  1. {spei_python-0.39.1 → spei_python-0.40.1}/PKG-INFO +1 -1
  2. {spei_python-0.39.1 → spei_python-0.40.1}/pyproject.toml +2 -2
  3. {spei_python-0.39.1 → spei_python-0.40.1}/spei/checksum/generator.py +2 -0
  4. spei_python-0.40.1/spei/mappings.py +37 -0
  5. {spei_python-0.39.1 → spei_python-0.40.1}/spei/requests/acuse.py +9 -5
  6. {spei_python-0.39.1 → spei_python-0.40.1}/spei/resources/acuse.py +31 -19
  7. {spei_python-0.39.1 → spei_python-0.40.1}/spei/resources/payments.py +64 -0
  8. spei_python-0.39.1/spei/mappings.py +0 -37
  9. spei_python-0.39.1/spei/resources/reversals.py +0 -66
  10. {spei_python-0.39.1 → spei_python-0.40.1}/README.md +0 -0
  11. {spei_python-0.39.1 → spei_python-0.40.1}/spei/README.md +0 -0
  12. {spei_python-0.39.1 → spei_python-0.40.1}/spei/__init__.py +0 -0
  13. {spei_python-0.39.1 → spei_python-0.40.1}/spei/cep_generator.py +0 -0
  14. {spei_python-0.39.1 → spei_python-0.40.1}/spei/checksum/__init__.py +0 -0
  15. {spei_python-0.39.1 → spei_python-0.40.1}/spei/checksum/factory.py +0 -0
  16. {spei_python-0.39.1 → spei_python-0.40.1}/spei/checksum/types.py +0 -0
  17. {spei_python-0.39.1 → spei_python-0.40.1}/spei/client.py +0 -0
  18. {spei_python-0.39.1 → spei_python-0.40.1}/spei/errors/__init__.py +0 -0
  19. {spei_python-0.39.1 → spei_python-0.40.1}/spei/errors/sice.py +0 -0
  20. {spei_python-0.39.1 → spei_python-0.40.1}/spei/errors/spei.py +0 -0
  21. {spei_python-0.39.1 → spei_python-0.40.1}/spei/requests/__init__.py +0 -0
  22. {spei_python-0.39.1 → spei_python-0.40.1}/spei/requests/cda.py +0 -0
  23. {spei_python-0.39.1 → spei_python-0.40.1}/spei/requests/orden.py +0 -0
  24. {spei_python-0.39.1 → spei_python-0.40.1}/spei/requests/respuesta.py +0 -0
  25. {spei_python-0.39.1 → spei_python-0.40.1}/spei/resources/__init__.py +0 -0
  26. {spei_python-0.39.1 → spei_python-0.40.1}/spei/resources/cda.py +0 -0
  27. {spei_python-0.39.1 → spei_python-0.40.1}/spei/resources/mensaje.py +0 -0
  28. {spei_python-0.39.1 → spei_python-0.40.1}/spei/resources/orden.py +0 -0
  29. {spei_python-0.39.1 → spei_python-0.40.1}/spei/resources/respuesta.py +0 -0
  30. {spei_python-0.39.1 → spei_python-0.40.1}/spei/responses/__init__.py +0 -0
  31. {spei_python-0.39.1 → spei_python-0.40.1}/spei/responses/acuse.py +0 -0
  32. {spei_python-0.39.1 → spei_python-0.40.1}/spei/responses/orden.py +0 -0
  33. {spei_python-0.39.1 → spei_python-0.40.1}/spei/responses/respuesta.py +0 -0
  34. {spei_python-0.39.1 → spei_python-0.40.1}/spei/sice.py +0 -0
  35. {spei_python-0.39.1 → spei_python-0.40.1}/spei/types/__init__.py +0 -0
  36. {spei_python-0.39.1 → spei_python-0.40.1}/spei/types/sice.py +0 -0
  37. {spei_python-0.39.1 → spei_python-0.40.1}/spei/types/spei.py +0 -0
  38. {spei_python-0.39.1 → spei_python-0.40.1}/spei/utils.py +0 -0
  39. {spei_python-0.39.1 → spei_python-0.40.1}/spei/validators.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spei-python
3
- Version: 0.39.1
3
+ Version: 0.40.1
4
4
  Summary:
5
5
  Author: tech
6
6
  Author-email: tech@fondeadora.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "spei-python"
3
- version = "0.39.1"
3
+ version = "0.40.1"
4
4
  description = ""
5
5
  authors = ["tech <tech@fondeadora.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.39.1"
35
+ version = "0.40.1"
36
36
  tag_format = "v$version"
37
37
  bump_message = "bump: Semantic Release Bot: Release Version: $new_version 🤖🚀 [skip ci]"
38
38
  version_files = [
@@ -26,6 +26,8 @@ class ChecksumGenerator(object):
26
26
  return day + month + year
27
27
 
28
28
  def _clave_to_bytearray(self, clave: str) -> bytearray:
29
+ if not clave:
30
+ clave = ''
29
31
  return int.to_bytes(int(clave), 4, 'big')
30
32
 
31
33
  def _monto_to_bytearray(self, amount: int) -> bytearray:
@@ -0,0 +1,37 @@
1
+ from types import MappingProxyType
2
+
3
+ from spei.resources import payments
4
+ from spei.types import CategoriaOrdenPago, TipoPagoOrdenPago
5
+
6
+ ORDEN_RESPONSES = MappingProxyType({
7
+ CategoriaOrdenPago.odps_liquidadas_abonos: CategoriaOrdenPago.odps_liquidadas_abonos_respuesta, # noqa: E501
8
+ CategoriaOrdenPago.odps_liquidadas_cargos: CategoriaOrdenPago.odps_liquidadas_cargos_respuesta, # noqa: E501
9
+ CategoriaOrdenPago.odps_canceladas_local: CategoriaOrdenPago.odps_canceladas_local_respuesta, # noqa: E501
10
+ CategoriaOrdenPago.odps_canceladas_x_banxico: CategoriaOrdenPago.odps_canceladas_x_banxico_respuesta, # noqa: E501
11
+ })
12
+
13
+ ORDEN_PAYMENT_TYPES = MappingProxyType({
14
+ TipoPagoOrdenPago.devolucion_no_acreditada: payments.DevolucionNoAcreditada,
15
+ TipoPagoOrdenPago.tercero_a_tercero: payments.TerceroATercero,
16
+ TipoPagoOrdenPago.tercero_a_ventanilla: payments.TerceroAVentilla,
17
+ TipoPagoOrdenPago.tercero_a_tercero_vostro: payments.TerceroATerceroVostro,
18
+ TipoPagoOrdenPago.tercero_a_participante: payments.TerceroAParticipante,
19
+ TipoPagoOrdenPago.participante_a_tercero: payments.ParticipanteATercero,
20
+ TipoPagoOrdenPago.participante_a_tercero_vostro: payments.ParticipanteATerceroVostro,
21
+ TipoPagoOrdenPago.participante_a_participante: payments.ParticipanteAParticipante,
22
+ TipoPagoOrdenPago.tercero_a_tercero_fsw: payments.TerceroATerceroFSW,
23
+ TipoPagoOrdenPago.tercero_a_tercero_vostro_fsw: payments.TerceroATerceroVostroFSW,
24
+ TipoPagoOrdenPago.participante_a_tercero_fsw: payments.ParticipanteATerceroFSW,
25
+ TipoPagoOrdenPago.participante_a_tercero_vostro_fsw: payments.TerceroATerceroFSW,
26
+ TipoPagoOrdenPago.nomina: payments.Nomina,
27
+ TipoPagoOrdenPago.pago_factura: payments.PagoFactura,
28
+ TipoPagoOrdenPago.devolucion_extemporanea_no_acreditada: payments.DevolucionExtemporaneaNoAcreditada,
29
+ TipoPagoOrdenPago.devolucion_acreditada: payments.DevolucionAcreditada,
30
+ TipoPagoOrdenPago.devolucion_extemporanea_acreditada: payments.DevolucionExtemporaneaAcreditada,
31
+ TipoPagoOrdenPago.cobros_presenciales_de_una_ocasion: payments.CobrosPresencialesUnaOcasion,
32
+ TipoPagoOrdenPago.cobros_no_presenciales_de_una_ocasion: payments.CobrosNoPresencialesUnaOcasion,
33
+ TipoPagoOrdenPago.cobros_no_presenciales_recurrentes: payments.CobrosNoPresencialesRecurrentes,
34
+ TipoPagoOrdenPago.cobros_no_presenciales_a_nombre_de_tercero: payments.CobrosNoPresencialesNoRecurrentesTercero,
35
+ TipoPagoOrdenPago.devolucion_especial_acreditada: payments.DevolucionEspecialAcreditada,
36
+ TipoPagoOrdenPago.devolucion_extemporanea_especial_acreditada: payments.DevolucionEspecialAcreditada,
37
+ })
@@ -1,6 +1,9 @@
1
+ from typing import List
2
+
1
3
  from lxml import etree
2
4
 
3
5
  from spei.resources import Acuse
6
+ from spei.types.sice import TipoRespuestaAcuse
4
7
 
5
8
  SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/'
6
9
  XML_SCHEMA_NS = 'http://www.w3.org/2001/XMLSchema'
@@ -9,12 +12,13 @@ XML_XSD_NS = 'http://www.w3.org/2001/XMLSchema-instance'
9
12
 
10
13
 
11
14
  class MensajeElement(object):
12
- def __new__(cls, acuse: Acuse):
15
+ def __new__(cls, acuses: List[Acuse], tipo_respuesta: TipoRespuestaAcuse):
13
16
  mensaje = etree.Element(
14
17
  'mensajeRespuestaCDA',
15
- tipoRespuesta=acuse.tipo_respuesta,
18
+ tipoRespuesta=tipo_respuesta,
16
19
  )
17
- mensaje.append(acuse.build_xml())
20
+ for acuse in acuses:
21
+ mensaje.append(acuse.build_xml())
18
22
  return mensaje
19
23
 
20
24
 
@@ -57,8 +61,8 @@ class EnvelopeElement(object):
57
61
 
58
62
 
59
63
  class AcuseRequest(object):
60
- def __new__(cls, acuse: Acuse, as_string=True):
61
- respuesta_element = RespuestaElement(ReturnElement(MensajeElement(acuse)))
64
+ def __new__(cls, tipo_respuesta: TipoRespuestaAcuse, acuses: List[Acuse] = (), as_string=True): # noqa: E501
65
+ respuesta_element = RespuestaElement(ReturnElement(MensajeElement(acuses, tipo_respuesta))) # noqa: E501
62
66
  envelope = EnvelopeElement(BodyElement(respuesta_element))
63
67
  if not as_string:
64
68
  return envelope
@@ -1,4 +1,4 @@
1
- from typing import Union
1
+ from typing import Any, Union
2
2
 
3
3
  from lxml import etree
4
4
  from pydantic import BaseModel
@@ -24,9 +24,9 @@ class ResultadoServidor(BaseModel):
24
24
  use_enum_values = True
25
25
 
26
26
 
27
- class MensajeRespuesta(object):
28
- def __new__(cls, mensaje):
29
- return mensaje
27
+ class MensajeRespuesta(BaseModel):
28
+ tipo_respuesta: TipoRespuestaAcuse
29
+ respuesta: Any
30
30
 
31
31
  @classmethod
32
32
  def parse_xml(cls, mensaje):
@@ -42,14 +42,21 @@ class MensajeRespuesta(object):
42
42
 
43
43
  xml_element = respuesta_element.find('xml')
44
44
 
45
- return etree.fromstring( # noqa: S320
45
+ respuesta = etree.fromstring( # noqa: S320
46
46
  bytes(xml_element.text, encoding='utf-8'),
47
47
  )
48
+ respuesta_element = respuesta.xpath('//*[local-name()="mensajeRespuestaCDA"]')[0] # noqa: E501
49
+ tipo_respuesta = respuesta_element.attrib['tipoRespuesta']
50
+
51
+ return cls(
52
+ tipo_respuesta=tipo_respuesta,
53
+ respuesta=respuesta_element,
54
+ )
48
55
 
49
56
 
50
57
  class Acuse(BaseModel):
51
58
  cda_id: str
52
- mensaje_id: str
59
+ mensaje_id: Any = None
53
60
  tipo_respuesta: TipoRespuestaAcuse
54
61
  resultado_enlace_cep: ResultadoServidor
55
62
  resultado_banxico: ResultadoBanxico = None
@@ -59,8 +66,9 @@ class Acuse(BaseModel):
59
66
 
60
67
  @classmethod
61
68
  def parse_synchronous_xml(cls, mensaje_element):
69
+ tipo_respuesta = mensaje_element.attrib['tipoRespuesta']
62
70
  acuse_element = mensaje_element.find('{http://www.praxis.com.mx/EnvioCda/}acuseCda') # noqa: E501
63
- cda_data = cls._find_mensaje_attributes(mensaje_element, acuse_element)
71
+ cda_data = cls._find_mensaje_attributes(acuse_element, tipo_respuesta)
64
72
  resultado_element = acuse_element.find('{http://www.praxis.com.mx/EnvioCda/}resultadoEnlaceCep') # noqa: E501
65
73
  codigo = resultado_element.find('{http://www.praxis.com.mx/EnvioCda/}codigo')
66
74
  descripcion = resultado_element.find('{http://www.praxis.com.mx/EnvioCda/}descripcion') # noqa: E501
@@ -71,11 +79,17 @@ class Acuse(BaseModel):
71
79
  return cls._build_acuse(acuse_element, cda_data, enlace_cep_data)
72
80
 
73
81
  def build_xml(self):
74
- acuse = etree.Element(
75
- 'acuse',
76
- idCda=self.cda_id,
77
- idMensaje=self.mensaje_id,
78
- )
82
+ if self.mensaje_id:
83
+ acuse = etree.Element(
84
+ 'acuse',
85
+ idCda=self.cda_id,
86
+ idMensaje=self.mensaje_id,
87
+ )
88
+ else:
89
+ acuse = etree.Element(
90
+ 'acuse',
91
+ idCda=self.cda_id,
92
+ )
79
93
 
80
94
  etree.SubElement(
81
95
  acuse,
@@ -101,10 +115,8 @@ class Acuse(BaseModel):
101
115
  return acuse
102
116
 
103
117
  @classmethod
104
- def parse_xml(cls, mensaje_element):
105
- acuse_element = mensaje_element.find('acuse')
106
-
107
- cda_data = cls._find_mensaje_attributes(mensaje_element, acuse_element)
118
+ def parse_xml(cls, acuse_element, tipo_respuesta):
119
+ cda_data = cls._find_mensaje_attributes(acuse_element, tipo_respuesta)
108
120
  enlace_cep_data = cls._find_enlace_cep_attributes(acuse_element)
109
121
  banxico_data = cls._find_banxico_attributes(acuse_element)
110
122
 
@@ -127,11 +139,11 @@ class Acuse(BaseModel):
127
139
  }
128
140
 
129
141
  @classmethod
130
- def _find_mensaje_attributes(cls, mensaje_element, acuse_element):
142
+ def _find_mensaje_attributes(cls, acuse_element, tipo_respuesta):
131
143
  return {
132
- 'tipo_respuesta': mensaje_element.attrib['tipoRespuesta'],
144
+ 'tipo_respuesta': tipo_respuesta,
133
145
  'cda_id': acuse_element.attrib['idCda'],
134
- 'mensaje_id': acuse_element.attrib['idMensaje'],
146
+ 'mensaje_id': acuse_element.get('idMensaje'),
135
147
  }
136
148
 
137
149
  @classmethod
@@ -303,3 +303,67 @@ class CobrosNoPresencialesNoRecurrentesTercero(Orden):
303
303
 
304
304
  op_cert_comer_env: int
305
305
  op_digito_ver_comer: int
306
+
307
+
308
+ class DevolucionNoAcreditada(Orden):
309
+ op_cd_clave = types.TipoDevolucionOrdenPago
310
+
311
+
312
+ class DevolucionExtemporaneaNoAcreditada(Orden):
313
+ op_tc_clave_ord: types.TipoCuentaOrdenPago
314
+ op_cuenta_ord: str
315
+
316
+ op_concepto_pag_2: str
317
+ op_ref_numerica: str
318
+
319
+ op_cd_clave: types.TipoDevolucionOrdenPago
320
+
321
+ op_folio_ori: int = None
322
+ paq_folio_ori: int = None
323
+
324
+ op_fecha_oper_ori: int
325
+ op_rastreo_ori: str
326
+ op_monto_intereses: float
327
+ op_monto_ori: float
328
+
329
+
330
+ class DevolucionAcreditada(Orden):
331
+ op_rastreo_ori: str
332
+
333
+
334
+ class DevolucionExtemporaneaAcreditada(Orden):
335
+ op_cuenta_ord: str
336
+
337
+ op_concepto_pag_2: str
338
+ op_ref_numerica: str
339
+
340
+ op_folio_ori: int = None
341
+ paq_folio_ori: int = None
342
+
343
+ op_fecha_oper_ori: int
344
+ op_rastreo_ori: str
345
+ op_monto_ori: float
346
+
347
+
348
+ class DevolucionEspecialAcreditada(Orden):
349
+ op_rastreo_ori: str
350
+ op_monto_ori: float
351
+
352
+ op_indica_ben_rec: int = None
353
+
354
+
355
+ class DevolucionExtemporaneaEspecialAcreditada(Orden):
356
+ op_tc_clave_ord: types.TipoCuentaOrdenPago
357
+ op_cuenta_ord: str
358
+
359
+ op_concepto_pag_2: str
360
+ op_ref_numerica: str
361
+
362
+ op_folio_ori: int = None
363
+ paq_folio_ori: int = None
364
+
365
+ op_fecha_oper_ori: int
366
+ op_rastreo_ori: str
367
+ op_monto_ori: float
368
+
369
+ op_indica_ben_rec: int = None
@@ -1,37 +0,0 @@
1
- from types import MappingProxyType
2
-
3
- from spei.resources import orden
4
- from spei.types import CategoriaOrdenPago, TipoPagoOrdenPago
5
-
6
- ORDEN_RESPONSES = MappingProxyType({
7
- CategoriaOrdenPago.odps_liquidadas_abonos: CategoriaOrdenPago.odps_liquidadas_abonos_respuesta, # noqa: E501
8
- CategoriaOrdenPago.odps_liquidadas_cargos: CategoriaOrdenPago.odps_liquidadas_cargos_respuesta, # noqa: E501
9
- CategoriaOrdenPago.odps_canceladas_local: CategoriaOrdenPago.odps_canceladas_local_respuesta, # noqa: E501
10
- CategoriaOrdenPago.odps_canceladas_x_banxico: CategoriaOrdenPago.odps_canceladas_x_banxico_respuesta, # noqa: E501
11
- })
12
-
13
- ORDEN_PAYMENT_TYPES = MappingProxyType({
14
- TipoPagoOrdenPago.devolucion_no_acreditada: orden.DevolucionNoAcreditada,
15
- TipoPagoOrdenPago.tercero_a_tercero: orden.TerceroATercero,
16
- TipoPagoOrdenPago.tercero_a_ventanilla: orden.TerceroAVentilla,
17
- TipoPagoOrdenPago.tercero_a_tercero_vostro: orden.TerceroATerceroVostro,
18
- TipoPagoOrdenPago.tercero_a_participante: orden.TerceroAParticipante,
19
- TipoPagoOrdenPago.participante_a_tercero: orden.ParticipanteATercero,
20
- TipoPagoOrdenPago.participante_a_tercero_vostro: orden.ParticipanteATerceroVostro,
21
- TipoPagoOrdenPago.participante_a_participante: orden.ParticipanteAParticipante,
22
- TipoPagoOrdenPago.tercero_a_tercero_fsw: orden.TerceroATerceroFSW,
23
- TipoPagoOrdenPago.tercero_a_tercero_vostro_fsw: orden.TerceroATerceroVostroFSW,
24
- TipoPagoOrdenPago.participante_a_tercero_fsw: orden.ParticipanteATerceroFSW,
25
- TipoPagoOrdenPago.participante_a_tercero_vostro_fsw: orden.TerceroATerceroFSW,
26
- TipoPagoOrdenPago.nomina: orden.Nomina,
27
- TipoPagoOrdenPago.pago_factura: orden.PagoFactura,
28
- TipoPagoOrdenPago.devolucion_extemporanea_no_acreditada: orden.DevolucionExtemporaneaNoAcreditada,
29
- TipoPagoOrdenPago.devolucion_acreditada: orden.DevolucionAcreditada,
30
- TipoPagoOrdenPago.devolucion_extemporanea_acreditada: orden.DevolucionExtemporaneaAcreditada,
31
- TipoPagoOrdenPago.cobros_presenciales_de_una_ocasion: orden.CobrosPresencialesUnaOcasion,
32
- TipoPagoOrdenPago.cobros_no_presenciales_de_una_ocasion: orden.CobrosNoPresencialesUnaOcasion,
33
- TipoPagoOrdenPago.cobros_no_presenciales_recurrentes: orden.CobrosNoPresencialesRecurrentes,
34
- TipoPagoOrdenPago.cobros_no_presenciales_a_nombre_de_tercero: orden.CobrosNoPresencialesNoRecurrentesTercero,
35
- TipoPagoOrdenPago.devolucion_especial_acreditada: orden.DevolucionEspecialAcreditada,
36
- TipoPagoOrdenPago.devolucion_extemporanea_especial_acreditada: orden.DevolucionEspecialAcreditada,
37
- })
@@ -1,66 +0,0 @@
1
- from spei import types
2
- from spei.resources.orden import Orden
3
-
4
-
5
- class DevolucionNoAcreditada(Orden):
6
- op_cd_clave = types.TipoDevolucionOrdenPago
7
-
8
-
9
- class DevolucionExtemporaneaNoAcreditada(Orden):
10
- op_tc_clave_ord: types.TipoCuentaOrdenPago
11
- op_cuenta_ord: str
12
-
13
- op_concepto_pag_2: str
14
- op_ref_numerica: str
15
-
16
- op_cd_clave: types.TipoDevolucionOrdenPago
17
-
18
- op_folio_ori: int = None
19
- paq_folio_ori: int = None
20
-
21
- op_fecha_oper_ori: int
22
- op_rastreo_ori: str
23
- op_monto_intereses: float
24
- op_monto_ori: float
25
-
26
-
27
- class DevolucionAcreditada(Orden):
28
- op_rastreo_ori: str
29
-
30
-
31
- class DevolucionExtemporaneaAcreditada(Orden):
32
- op_cuenta_ord: str
33
-
34
- op_concepto_pag_2: str
35
- op_ref_numerica: str
36
-
37
- op_folio_ori: int = None
38
- paq_folio_ori: int = None
39
-
40
- op_fecha_oper_ori: int
41
- op_rastreo_ori: str
42
- op_monto_ori: float
43
-
44
-
45
- class DevolucionEspecialAcreditada(Orden):
46
- op_rastreo_ori: str
47
- op_monto_ori: float
48
-
49
- op_indica_ben_rec: int = None
50
-
51
-
52
- class DevolucionExtemporaneaEspecialAcreditada(Orden):
53
- op_tc_clave_ord: types.TipoCuentaOrdenPago
54
- op_cuenta_ord: str
55
-
56
- op_concepto_pag_2: str
57
- op_ref_numerica: str
58
-
59
- op_folio_ori: int = None
60
- paq_folio_ori: int = None
61
-
62
- op_fecha_oper_ori: int
63
- op_rastreo_ori: str
64
- op_monto_ori: float
65
-
66
- op_indica_ben_rec: int = None
File without changes
File without changes
File without changes