Skip to content

Commit d5c6df3

Browse files
authored
Verifications instead of Identities (old) (#98)
* adding verification create * version * assert * format * bump * changes in verification upload documents * some fixes * version * BREAKING CHANGE, remove identities * fix lint * readme * group 1
1 parent fa0c450 commit d5c6df3

16 files changed

+356
-392
lines changed

README.md

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,70 @@ source venv/bin/activate
2020
make test
2121
```
2222

23-
## Create Identity
23+
## Create Verification
2424

2525
```python
2626
from mati import Client
2727

28-
client = Client()
29-
georg = client.identities.create(
30-
name='Georg Wilhelm Friedrich Hegel',
31-
occupation='Philosopher',
32-
dob='1770-08-27'
28+
client = Client('api_key', 'secret_key')
29+
verification = client.verifications.create(
30+
'some_flow_id',
31+
company_id='some_id',
3332
)
3433
```
34+
35+
## Upload documents
36+
```python
37+
from mati.types import (
38+
PageType,
39+
UserValidationFile,
40+
ValidationInputType,
41+
ValidationType,
42+
)
43+
44+
# Load documents
45+
front = open('ine_front.jpg', 'rb')
46+
back = open('ine_back.jpg', 'rb')
47+
live = open('liveness.mp4', 'rb')
48+
49+
# Create document with metadata
50+
user_validation_file = UserValidationFile(
51+
filename='ine_front.jpg',
52+
content=front,
53+
input_type=ValidationInputType.document_photo,
54+
validation_type=ValidationType.national_id,
55+
country='MX',
56+
group=0, #The group is important when create your metamap
57+
)
58+
user_validation_file_back = UserValidationFile(
59+
filename='ine_back.jpg',
60+
content=back,
61+
input_type=ValidationInputType.document_photo,
62+
validation_type=ValidationType.national_id,
63+
country='MX',
64+
page=PageType.back,
65+
group=0,
66+
)
67+
user_validation_live = UserValidationFile(
68+
filename='liveness.MOV',
69+
content=live,
70+
input_type=ValidationInputType.selfie_video,
71+
group=1,
72+
)
73+
74+
# Send documentation for validation
75+
resp = client.verifications.upload_validation_data(
76+
[
77+
user_validation_file,
78+
user_validation_file_back,
79+
user_validation_live,
80+
],
81+
verification.identity,
82+
)
83+
```
84+
85+
## Verification status
86+
Retrieve the verification when its complete
87+
```python
88+
verification = client.verifications.retrieve('verification_id')
89+
```

mati/client.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33

44
from requests import Response, Session
55

6-
from .resources import (
7-
AccessToken,
8-
Identity,
9-
Resource,
10-
UserValidationData,
11-
Verification,
12-
)
6+
from .resources import AccessToken, Resource, UserValidationData, Verification
137
from .version import __version__ as client_version
148

159
API_URL = 'https://api.getmati.com'
@@ -25,7 +19,6 @@ class Client:
2519

2620
# resources
2721
access_tokens: ClassVar = AccessToken
28-
identities: ClassVar = Identity
2922
user_validation_data: ClassVar = UserValidationData
3023
verifications: ClassVar = Verification
3124

mati/resources/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
__all__ = [
22
'AccessToken',
3-
'Identity',
43
'Resource',
54
'UserValidationData',
65
'Verification',
76
]
87

98
from .access_tokens import AccessToken
109
from .base import Resource
11-
from .identities import Identity
1210
from .user_verification_data import UserValidationData
1311
from .verifications import Verification

mati/resources/identities.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

mati/resources/verifications.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
from ..types.enums import (
66
DocumentScore,
77
Liveness,
8+
UserValidationFile,
89
VerificationDocument,
910
VerificationDocumentStep,
1011
)
1112
from .base import Resource
13+
from .user_verification_data import UserValidationData
1214

1315

1416
@dataclass
@@ -36,13 +38,33 @@ def __post_init__(self):
3638
docs.append(VerificationDocument(**doc))
3739
self.documents = docs
3840

41+
@classmethod
42+
def create(cls, flow_id: str, client=None, **metadata):
43+
client = client or cls._client
44+
resp = client.post(
45+
cls._endpoint, json=dict(flowId=flow_id, metadata=metadata)
46+
)
47+
return cast('Verification', cls._from_dict(resp))
48+
3949
@classmethod
4050
def retrieve(cls, verification_id: str, client=None) -> 'Verification':
4151
client = client or cls._client
4252
endpoint = f'{cls._endpoint}/{verification_id}'
4353
resp = client.get(endpoint)
4454
return cast('Verification', cls._from_dict(resp))
4555

56+
@classmethod
57+
def upload_validation_data(
58+
cls,
59+
user_validation_files: List[UserValidationFile],
60+
identity_id: str,
61+
client=None,
62+
) -> List[dict]:
63+
client = client or cls._client
64+
return UserValidationData.upload(
65+
identity_id, user_validation_files, client=client
66+
)
67+
4668
@property
4769
def is_pending(self) -> bool:
4870
return self.identity['status'] in ['running', 'pending']

mati/types/enums.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class ValidationType(SerializableEnum):
2424
national_id = 'national-id'
2525
passport = 'passport'
2626
proof_of_residency = 'proof-of-residency'
27+
liveness = 'video/mp4'
2728

2829

2930
@dataclass
@@ -109,8 +110,8 @@ class LivenessMedia:
109110
class Liveness:
110111
status: int
111112
id: str
112-
data: LivenessMedia
113-
error: Optional[Dict]
113+
data: Optional[LivenessMedia] = None
114+
error: Optional[Dict] = None
114115

115116

116117
@dataclass

mati/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.3.4' # pragma: no cover
1+
__version__ = '2.0.0' # pragma: no cover

tests/conftest.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,11 @@ def client() -> Generator:
213213

214214

215215
@pytest.fixture
216-
def identity(client: Client) -> Generator:
217-
yield client.identities.create(
216+
def verification(client: Client) -> Generator:
217+
yield client.verifications.create(
218+
'SOME_FLOW_ID',
218219
client=client,
219-
nombres='Georg Wilhelm',
220-
primer_apellido='Friedrich',
221-
segundo_apellido='Hegel',
222-
dob='1770-08-27',
220+
user='some_id',
223221
)
224222

225223

tests/resources/cassettes/test_create_identity.yaml

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)