Repository: cuenca-mx/cuenca-python (language: python)

Issue:
Buscar usuarios por identidad
- agregar identity_id aquí https://github.com/cuenca-mx/cuenca-validations/blob/main/cuenca_validations/types/queries.py#L156-L159
- checar que user y identity son Queryable en CP


Discussion / hints:

Fix patch:
diff --git a/cuenca/version.py b/cuenca/version.py
index 92d48c8e..44d21ffc 100644
--- a/cuenca/version.py
+++ b/cuenca/version.py
@@ -1,3 +1,3 @@
-__version__ = '0.10.0'
+__version__ = '0.10.1'
 CLIENT_VERSION = __version__
 API_VERSION = '2020-03-19'
diff --git a/requirements.txt b/requirements.txt
index 14254e74..3f69a53d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,3 @@
 requests==2.27.1
-cuenca-validations==0.10.7
+cuenca-validations==0.10.9
 dataclasses>=0.7;python_version<"3.7"


Test patch:
diff --git a/tests/resources/cassettes/test_user_query_all_identity_id.yaml b/tests/resources/cassettes/test_user_query_all_identity_id.yaml
new file mode 100644
index 00000000..e4c8efc0
--- /dev/null
+++ b/tests/resources/cassettes/test_user_query_all_identity_id.yaml
@@ -0,0 +1,51 @@
+interactions:
+- request:
+    body: null
+    headers:
+      Accept:
+      - '*/*'
+      Accept-Encoding:
+      - gzip, deflate
+      Authorization:
+      - DUMMY
+      Connection:
+      - keep-alive
+      User-Agent:
+      - cuenca-python/0.10.1
+      X-Cuenca-Api-Version:
+      - '2020-03-19'
+    method: GET
+    uri: https://sandbox.cuenca.com/users?identity_uri=IDzqdGEBX_SMScteGcRDNtOg
+  response:
+    body:
+      string: '{"items":[{"id":"US48qRpnZOQuKoAF1j_mnZ7Q","created_at":"2022-05-05T18:35:14.597000","updated_at":"2022-05-19T23:40:30.372000","identity_uri":"/identities/IDzqdGEBX_SMScteGcRDNtOg","level":2,"phone_number":"+525566556655","email_address":"alan@cuenca.com","profession":"employee","terms_of_service":{"version":"2022-01-01","ip":"201.141.24.14","location":null},"status":"active","address":{"street":null,"ext_number":null,"postal_code":null,"state":null,"country":null,"city":null,"int_number":null,"full_name":"RTNO
+        1"},"govt_id":{"type":"ine","is_mx":true,"uri_front":"cuenca.com","uri_back":"cuenca.com","data":{}},"proof_of_address":null,"proof_of_life":null,"beneficiaries":null,"platform_id":"PTSFitwBYWROu-dAziDnSr4Q"},{"id":"USH19aFDPCTbetWNiltoqPyA","created_at":"2022-04-29T01:54:49.537000","updated_at":"2022-05-04T23:11:33.845000","identity_uri":"/identities/IDzqdGEBX_SMScteGcRDNtOg","level":3,"phone_number":"+525566778899","email_address":"yisus@cuenca.com","profession":null,"terms_of_service":{"version":"2022-01-01","ip":"10.0.23.99","location":null},"status":"active","address":null,"govt_id":{"type":"ine","is_mx":true,"uri_front":"cuenca.com","uri_back":"cuenca.com","data":{}},"proof_of_address":{"type":"proof_of_address","is_mx":true,"uri_front":"cuenca.com","uri_back":null,"data":{}},"proof_of_life":null,"beneficiaries":null,"platform_id":"PTW68GgAc_QPmNCmgajmctLg"}],"next_page_uri":null,"count":null,"fields":{"items":{"description":"List
+        of Users that match with query filters"},"next_page_uri":{"description":"URL
+        to fetch the next page of results"},"count":{"description":"Counter of Users
+        objects that match with query filters.  \nIncluded in response only if `count`
+        param was `true`"}}}'
+    headers:
+      Connection:
+      - keep-alive
+      Content-Length:
+      - '2006'
+      Content-Type:
+      - application/json
+      Date:
+      - Fri, 10 Jun 2022 01:24:50 GMT
+      x-amz-apigw-id:
+      - Te2HaHFyCYcFpfQ=
+      x-amzn-Remapped-Connection:
+      - keep-alive
+      x-amzn-Remapped-Content-Length:
+      - '2006'
+      x-amzn-Remapped-Date:
+      - Fri, 10 Jun 2022 01:24:50 GMT
+      x-amzn-Remapped-Server:
+      - nginx/1.22.0
+      x-amzn-RequestId:
+      - 9977aaa0-5fee-4616-bd99-f105a2246da6
+    status:
+      code: 200
+      message: OK
+version: 1
diff --git a/tests/resources/cassettes/test_user_query_by_identity_id.yaml b/tests/resources/cassettes/test_user_query_by_identity_id.yaml
new file mode 100644
index 00000000..5c16d646
--- /dev/null
+++ b/tests/resources/cassettes/test_user_query_by_identity_id.yaml
@@ -0,0 +1,52 @@
+interactions:
+- request:
+    body: null
+    headers:
+      Accept:
+      - '*/*'
+      Accept-Encoding:
+      - gzip, deflate
+      Authorization:
+      - DUMMY
+      Connection:
+      - keep-alive
+      User-Agent:
+      - cuenca-python/0.10.0
+      X-Cuenca-Api-Version:
+      - '2020-03-19'
+    method: GET
+    uri: https://sandbox.cuenca.com/users?limit=1&identity_uri=IDzqdGEBX_SMScteGcRDNtOg
+  response:
+    body:
+      string: '{"items":[{"id":"US1234","created_at":"2022-05-05T18:35:14.597000","updated_at":"2022-05-19T23:40:30.372000","identity_uri":"/identities/IDzqdGEBX_SMScteGcRDNtOg","level":2,"phone_number":"+525512345678","email_address":"alan@cuenca.com","profession":"employee","terms_of_service":{"version":"2022-01-01","ip":"201.141.24.14","location":null},"status":"active","address":{"street":null,"ext_number":null,"postal_code":null,"state":null,"country":null,"city":null,"int_number":null,"full_name":"RTNO
+        1"},"govt_id":{"type":"ine","is_mx":true,"uri_front": "cuenca.com", "uri_back":
+        "cuenca.com","data":{}},"proof_of_address":null,"proof_of_life":null,"beneficiaries":null,"platform_id":"PT12334"}],"next_page_uri":null,"count":null,"fields":{"items":{"description":"List
+        of Users that match with query filters"},"next_page_uri":{"description":"URL
+        to fetch the next page of results"},"count":{"description":"Counter of Users
+        objects that match with query filters.  \nIncluded in response only if `count`
+        param was `true`"}}}'
+    headers:
+      Connection:
+      - keep-alive
+      Content-Length:
+      - '1202'
+      Content-Type:
+      - application/json
+      Date:
+      - Mon, 06 Jun 2022 22:40:27 GMT
+      x-amz-apigw-id:
+      - TUlONEZzCYcFWcg=
+      x-amzn-Remapped-Connection:
+      - keep-alive
+      x-amzn-Remapped-Content-Length:
+      - '1202'
+      x-amzn-Remapped-Date:
+      - Mon, 06 Jun 2022 22:40:26 GMT
+      x-amzn-Remapped-Server:
+      - nginx/1.22.0
+      x-amzn-RequestId:
+      - 7fd67e4a-66bb-4746-9ad9-55ac5637ce95
+    status:
+      code: 200
+      message: OK
+version: 1
diff --git a/tests/resources/test_users.py b/tests/resources/test_users.py
index 0e7de03b..ae9e9c86 100644
--- a/tests/resources/test_users.py
+++ b/tests/resources/test_users.py
@@ -44,3 +44,19 @@ def test_user_identity_retrieve():
     assert user_id == user.id
     identity = user.identity
     assert identity.id is not None
+
+
+@pytest.mark.vcr
+def test_user_query_by_identity_id():
+    identity_id = 'IDzqdGEBX_SMScteGcRDNtOg'
+    user = User.first(identity_uri=identity_id)
+    assert identity_id in user.identity_uri
+
+
+@pytest.mark.vcr
+def test_user_query_all_identity_id():
+    identity_id = 'IDzqdGEBX_SMScteGcRDNtOg'
+    users = [user for user in User.all(identity_uri=identity_id)]
+    assert len(users) == 2
+    assert users[0].id != users[1].id
+    assert users[0].identity_uri == users[1].identity_uri