Skip to content

Commit a97b911

Browse files
authored
Kyc validations (#318)
* draft kyc validations * adding KycValidationRequest * format * expose resource * bump validations * fix imports * starting test and upgrade CV * bump validations * version and fix test * lint * queryable * update docs * fix test
1 parent 6c245ac commit a97b911

File tree

8 files changed

+159
-2
lines changed

8 files changed

+159
-2
lines changed

cuenca/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'FileBatch',
2020
'Identity',
2121
'IdentityEvent',
22+
'KYCValidation',
2223
'KYCVerification',
2324
'LimitedWallet',
2425
'LoginToken',
@@ -63,6 +64,7 @@
6364
FileBatch,
6465
Identity,
6566
IdentityEvent,
67+
KYCValidation,
6668
KYCVerification,
6769
LimitedWallet,
6870
LoginToken,

cuenca/resources/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'FileBatch',
1919
'Identity',
2020
'IdentityEvent',
21+
'KYCValidation',
2122
'KYCVerification',
2223
'LimitedWallet',
2324
'LoginToken',
@@ -55,6 +56,7 @@
5556
from .files import File
5657
from .identities import Identity
5758
from .identity_events import IdentityEvent
59+
from .kyc_validations import KYCValidation
5860
from .kyc_verifications import KYCVerification
5961
from .limited_wallets import LimitedWallet
6062
from .login_tokens import LoginToken
@@ -95,6 +97,7 @@
9597
FileBatch,
9698
Identity,
9799
IdentityEvent,
100+
KYCValidation,
98101
KYCVerification,
99102
LimitedWallet,
100103
LoginToken,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from typing import ClassVar, List, Optional, cast
2+
3+
from cuenca_validations.types import KYCValidationRequest
4+
5+
from ..http import Session, session as global_session
6+
from .base import Creatable, Queryable, Retrievable
7+
8+
9+
class KYCValidation(Creatable, Retrievable, Queryable):
10+
_resource: ClassVar = 'kyc_validations'
11+
platform_id: str
12+
attemps: Optional[int]
13+
verification_id: Optional[str]
14+
files_uri: Optional[List[str]]
15+
16+
class Config:
17+
schema_extra = {
18+
'example': {
19+
'id': 'KVNEUInh69SuKXXmK95sROwQ',
20+
'platform_id': 'PT8UEv02zBTcymd4Kd3MO6pg',
21+
'created_at': '2020-05-24T14:15:22Z',
22+
'verification_id': 'string',
23+
'files_uri': ['cuenca.com/files/id', 'cuenca.com/files/id2'],
24+
'attemps': '1',
25+
}
26+
}
27+
28+
@classmethod
29+
def create(
30+
cls, user_id: str, session: Session = global_session
31+
) -> 'KYCValidation':
32+
req = KYCValidationRequest(user_id=user_id)
33+
return cast(
34+
'KYCValidation', cls._create(**req.dict(), session=session)
35+
)

cuenca/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '0.14.5'
1+
__version__ = '0.14.6'
22
CLIENT_VERSION = __version__
33
API_VERSION = '2020-03-19'

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
requests==2.27.1
2-
cuenca-validations==0.11.3
2+
cuenca-validations==0.11.4
33
dataclasses>=0.7;python_version<"3.7"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
interactions:
2+
- request:
3+
body: '{"user_id": "USFOOBAR"}'
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Authorization:
10+
- DUMMY
11+
Connection:
12+
- keep-alive
13+
Content-Length:
14+
- '39'
15+
Content-Type:
16+
- application/json
17+
User-Agent:
18+
- cuenca-python/0.14.7.dev6
19+
X-Cuenca-Api-Version:
20+
- '2020-03-19'
21+
method: POST
22+
uri: https://sandbox.cuenca.com/kyc_validations
23+
response:
24+
body:
25+
string: '{"id":"KVWZUhh-t_RUOPvU3hOnhbsQ","created_at":"2022-09-26T23:14:28.686030","verification_id":"6332324ca3b3cd001c6bcbf9","platform_id":"PTS7Wx1-1KRCKHQRWXsqxbMQ","user_id":"USOiwY3bhaRO-Or9koIBaehg","files_uri":["''https://sandbox.cuenca.com/files/EFfX_JE_wES3KA5cuR075rVA","https://sandbox.cuenca.com/files/EFWUXd3zl6Q6Gmd1tD2S65fw","https://sandbox.cuenca.com/files/EF2_YXyrMLSba7wpz-DQGgsw"]}'
26+
headers:
27+
Connection:
28+
- keep-alive
29+
Content-Length:
30+
- '393'
31+
Content-Type:
32+
- application/json
33+
Date:
34+
- Mon, 26 Sep 2022 23:14:28 GMT
35+
X-Request-Time:
36+
- 'value: 27.792'
37+
x-amz-apigw-id:
38+
- ZFzI7GHfoAMF4jQ=
39+
x-amzn-Remapped-Connection:
40+
- keep-alive
41+
x-amzn-Remapped-Content-Length:
42+
- '393'
43+
x-amzn-Remapped-Date:
44+
- Mon, 26 Sep 2022 23:14:28 GMT
45+
x-amzn-Remapped-Server:
46+
- nginx/1.22.0
47+
x-amzn-RequestId:
48+
- 310039b7-a7dd-4980-bb0b-b5552c602d26
49+
status:
50+
code: 201
51+
message: Created
52+
version: 1
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Authorization:
10+
- DUMMY
11+
Connection:
12+
- keep-alive
13+
User-Agent:
14+
- cuenca-python/0.14.7.dev6
15+
X-Cuenca-Api-Version:
16+
- '2020-03-19'
17+
method: GET
18+
uri: https://sandbox.cuenca.com/kyc_validations/KVFOO
19+
response:
20+
body:
21+
string: '{"id":"KVWZUhh-t_RUOPvU3hOnhbsQ","platform_id":"PTS7Wx1-1KRCKHQRWXsqxbMQ","created_at":"2022-09-26T23:14:28.686000","verification_id":"6332324ca3b3cd001c6bcbf9","govt_id":null,"proof_of_address":null,"proof_of_life":null}'
22+
headers:
23+
Connection:
24+
- keep-alive
25+
Content-Length:
26+
- '221'
27+
Content-Type:
28+
- application/json
29+
Date:
30+
- Mon, 26 Sep 2022 23:15:11 GMT
31+
X-Request-Time:
32+
- 'value: 0.074'
33+
x-amz-apigw-id:
34+
- ZFzT4HnLIAMFe1w=
35+
x-amzn-Remapped-Connection:
36+
- keep-alive
37+
x-amzn-Remapped-Content-Length:
38+
- '221'
39+
x-amzn-Remapped-Date:
40+
- Mon, 26 Sep 2022 23:15:11 GMT
41+
x-amzn-Remapped-Server:
42+
- nginx/1.22.0
43+
x-amzn-RequestId:
44+
- 54f8a828-94f3-4303-8c95-95e22472cbab
45+
status:
46+
code: 200
47+
message: OK
48+
version: 1
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pytest
2+
3+
from cuenca import KYCValidation
4+
5+
6+
@pytest.mark.vcr
7+
def test_validation_create():
8+
kyc_validation: KYCValidation = KYCValidation.create(user_id="USFOOBAR")
9+
assert kyc_validation.id
10+
assert kyc_validation.verification_id
11+
12+
13+
@pytest.mark.vcr
14+
def test_validation_retrieve():
15+
kyc_validation = KYCValidation.retrieve('KVFOO')
16+
assert kyc_validation.id
17+
assert kyc_validation.verification_id

0 commit comments

Comments
 (0)