diff --git a/cuenca/resources/user_lists_validation.py b/cuenca/resources/user_lists_validation.py index e69266c9..1fbe2b78 100644 --- a/cuenca/resources/user_lists_validation.py +++ b/cuenca/resources/user_lists_validation.py @@ -17,6 +17,18 @@ class UserListsValidation(Creatable, Retrievable): curp: Optional[Curp] = None account_number: Optional[str] = None status: Optional[VerificationStatus] = None + response: Optional[dict] = None + + @property + def ppe_matches(self) -> list[dict]: + if not self.response or 'persons' not in self.response: + return [] + + return [ + person + for person in self.response['persons'] + if person.get('lista') == 'PPE' + ] @classmethod def create( diff --git a/cuenca/version.py b/cuenca/version.py index 04511fde..063421fa 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.0' +__version__ = '2.1.2' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/tests/resources/cassettes/test_create_user_validation_with_response.yaml b/tests/resources/cassettes/test_create_user_validation_with_response.yaml new file mode 100644 index 00000000..5f138612 --- /dev/null +++ b/tests/resources/cassettes/test_create_user_validation_with_response.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: '{"curp": "LOBR810330HTCPLM05", "account_number": null, "names": "Jos\u00e9 + Ram\u00f3n", "first_surname": "L\u00f3pez", "second_surname": "Beltr\u00e1n"}' + headers: + Authorization: + - DUMMY + Content-Length: + - '152' + Content-Type: + - application/json + User-Agent: + - cuenca-python/2.1.0 + X-Cuenca-Api-Version: + - '2020-03-19' + method: POST + uri: https://sandbox.cuenca.com/user_lists_validations + response: + body: + string: "{\"id\":\"UVhK66y6cdS52zpxfs0y2feg\",\"created_at\":\"2025-03-05T23:34:16.818000\",\"platform_id\":\"PTvAEqw3XtSC2oRTfKg4FAGQ\",\"curp\":\"LOBR810330HTCPLM05\",\"names\":\"Jose + Ramon\",\"first_surname\":\"Lopez\",\"second_surname\":\"Beltran\",\"status\":\"rejected\",\"lists\":[\"PPE\"],\"response\":{\"resumen\":{\"id_resultado\":\"1\",\"num_registros\":\"3\",\"num_conex_dia\":\"642\"},\"persons\":[{\"id_persona\":\"QEQ0281541\",\"peso1\":\"100\",\"peso2\":\"0\",\"nombre\":\"Jos\xE9 + Ram\xF3n\",\"paterno\":\"L\xF3pez\",\"materno\":\"Beltr\xE1n\",\"curp\":\"LOBR810330HTCPLM05\",\"rfc\":\"LOBR810330RB6\",\"fecha_nacimiento\":\"30/03/1981\",\"sexo\":\"Masculino\",\"lista\":\"PPE\",\"estatus\":\"Inactivo\",\"dependencia\":null,\"puesto\":\"OTRO\",\"area\":null,\"iddispo\":\"6\",\"idrel\":\"QEQ0281252\",\"parentesco\":\"HIJO\",\"razonsoc\":null,\"rfcmoral\":null,\"issste\":null,\"imss\":null,\"ingresos\":null,\"nombrecomp\":\"Jos\xE9 + Ram\xF3n L\xF3pez Beltr\xE1n\",\"apellidos\":\"L\xF3pez Beltr\xE1n\",\"entidad\":null,\"curp_ok\":\"1\",\"fecha_cargo_ini\":\"05/12/2018\",\"fecha_cargo_fin\":null,\"domicilio_a\":null,\"colonia\":null,\"cp\":null,\"ciudad\":null,\"email\":null,\"pais\":null,\"buscado_en\":null,\"ciudadania\":null,\"gafi\":null},{\"id_persona\":\"QEQ0328670\",\"peso1\":\"100\",\"peso2\":\"0\",\"nombre\":\"Jos\xE9 + Ram\xF3n\",\"paterno\":\"L\xF3pez\",\"materno\":\"Beltr\xE1n\",\"curp\":null,\"rfc\":null,\"fecha_nacimiento\":null,\"sexo\":\"Masculino\",\"lista\":\"VENC\",\"estatus\":\"3 + a\xF1os\",\"dependencia\":null,\"puesto\":\"OTRO\",\"area\":null,\"iddispo\":\"6\",\"idrel\":\"QEQ0304602\",\"parentesco\":\"PRIMO\",\"razonsoc\":null,\"rfcmoral\":null,\"issste\":null,\"imss\":null,\"ingresos\":null,\"nombrecomp\":\"Jos\xE9 + Ram\xF3n L\xF3pez Beltr\xE1n\",\"apellidos\":\"L\xF3pez Beltr\xE1n\",\"entidad\":null,\"curp_ok\":\"0\",\"fecha_cargo_ini\":\"30/04/2021\",\"fecha_cargo_fin\":null,\"domicilio_a\":null,\"colonia\":null,\"cp\":null,\"ciudad\":null,\"email\":null,\"pais\":null,\"buscado_en\":null,\"ciudadania\":null,\"gafi\":null},{\"id_persona\":\"QEQ0232657\",\"peso1\":\"100\",\"peso2\":\"0\",\"nombre\":\"Jos\xE9 + Ram\xF3n\",\"paterno\":\"L\xF3pez\",\"materno\":\"Beltr\xE1n\",\"curp\":\"LOBR810330HTCPLM05\",\"rfc\":\"LOBR810330RB6\",\"fecha_nacimiento\":\"30/03/1981\",\"sexo\":\"Masculino\",\"lista\":\"VENC\",\"estatus\":\"7 + a\xF1os\",\"dependencia\":null,\"puesto\":\"OTRO\",\"area\":null,\"iddispo\":\"6\",\"idrel\":\"QEQ0180416\",\"parentesco\":\"HIJO\",\"razonsoc\":null,\"rfcmoral\":null,\"issste\":null,\"imss\":null,\"ingresos\":null,\"nombrecomp\":\"Jos\xE9 + Ram\xF3n L\xF3pez Beltr\xE1n\",\"apellidos\":\"L\xF3pez Beltr\xE1n\",\"entidad\":null,\"curp_ok\":\"1\",\"fecha_cargo_ini\":\"18/05/2016\",\"fecha_cargo_fin\":null,\"domicilio_a\":null,\"colonia\":null,\"cp\":null,\"ciudad\":null,\"email\":null,\"pais\":null,\"buscado_en\":null,\"ciudadania\":null,\"gafi\":null}]},\"identity_id\":\"IDxIOd5v3-SSWQ39qDAOdRNg\"}" + headers: + Connection: + - keep-alive + Content-Length: + - '2511' + Content-Type: + - application/json + Date: + - Fri, 07 Mar 2025 23:04:56 GMT + X-Request-Time: + - 'value: 0.621' + x-amz-apigw-id: + - HFA_zE-JCYcERmw= + x-amzn-Remapped-Connection: + - keep-alive + x-amzn-Remapped-Content-Length: + - '2511' + x-amzn-Remapped-Date: + - Fri, 07 Mar 2025 23:04:56 GMT + x-amzn-Remapped-Server: + - nginx/1.26.2 + x-amzn-RequestId: + - 88c7aef2-2e7e-4f43-8632-568f339de896 + status: + code: 201 + message: Created +version: 1 diff --git a/tests/resources/test_user_lists_validation.py b/tests/resources/test_user_lists_validation.py index 08f0cff0..d0a64337 100644 --- a/tests/resources/test_user_lists_validation.py +++ b/tests/resources/test_user_lists_validation.py @@ -5,10 +5,24 @@ from cuenca.resources import UserListsValidation +@pytest.mark.vcr +def test_create_user_validation_with_response(): + user_validation = UserListsValidation.create( + curp='LOBR810330HTCPLM05', + names='José Ramón', + first_surname='López', + second_surname='Beltrán', + ) + assert user_validation.status == VerificationStatus.rejected + assert len(user_validation.ppe_matches) == 1 + assert user_validation.ppe_matches[0]['parentesco'] == 'HIJO' + + @pytest.mark.vcr def test_create_user_validation(user_lists_request): user_validation = UserListsValidation.create(**user_lists_request) assert user_validation.status == VerificationStatus.succeeded + assert len(user_validation.ppe_matches) == 0 assert user_validation.id