Skip to content

Commit

Permalink
Verifications instead of Identities (old) (#98)
Browse files Browse the repository at this point in the history
* adding verification create

* version

* assert

* format

* bump

* changes in verification upload documents

* some fixes

* version

* BREAKING CHANGE, remove identities

* fix lint

* readme

* group 1
  • Loading branch information
alexviquez authored Sep 26, 2022
1 parent fa0c450 commit d5c6df3
Show file tree
Hide file tree
Showing 16 changed files with 356 additions and 392 deletions.
67 changes: 61 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,70 @@ source venv/bin/activate
make test
```

## Create Identity
## Create Verification

```python
from mati import Client

client = Client()
georg = client.identities.create(
name='Georg Wilhelm Friedrich Hegel',
occupation='Philosopher',
dob='1770-08-27'
client = Client('api_key', 'secret_key')
verification = client.verifications.create(
'some_flow_id',
company_id='some_id',
)
```

## Upload documents
```python
from mati.types import (
PageType,
UserValidationFile,
ValidationInputType,
ValidationType,
)

# Load documents
front = open('ine_front.jpg', 'rb')
back = open('ine_back.jpg', 'rb')
live = open('liveness.mp4', 'rb')

# Create document with metadata
user_validation_file = UserValidationFile(
filename='ine_front.jpg',
content=front,
input_type=ValidationInputType.document_photo,
validation_type=ValidationType.national_id,
country='MX',
group=0, #The group is important when create your metamap
)
user_validation_file_back = UserValidationFile(
filename='ine_back.jpg',
content=back,
input_type=ValidationInputType.document_photo,
validation_type=ValidationType.national_id,
country='MX',
page=PageType.back,
group=0,
)
user_validation_live = UserValidationFile(
filename='liveness.MOV',
content=live,
input_type=ValidationInputType.selfie_video,
group=1,
)

# Send documentation for validation
resp = client.verifications.upload_validation_data(
[
user_validation_file,
user_validation_file_back,
user_validation_live,
],
verification.identity,
)
```

## Verification status
Retrieve the verification when its complete
```python
verification = client.verifications.retrieve('verification_id')
```
9 changes: 1 addition & 8 deletions mati/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@

from requests import Response, Session

from .resources import (
AccessToken,
Identity,
Resource,
UserValidationData,
Verification,
)
from .resources import AccessToken, Resource, UserValidationData, Verification
from .version import __version__ as client_version

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

# resources
access_tokens: ClassVar = AccessToken
identities: ClassVar = Identity
user_validation_data: ClassVar = UserValidationData
verifications: ClassVar = Verification

Expand Down
2 changes: 0 additions & 2 deletions mati/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
__all__ = [
'AccessToken',
'Identity',
'Resource',
'UserValidationData',
'Verification',
]

from .access_tokens import AccessToken
from .base import Resource
from .identities import Identity
from .user_verification_data import UserValidationData
from .verifications import Verification
60 changes: 0 additions & 60 deletions mati/resources/identities.py

This file was deleted.

22 changes: 22 additions & 0 deletions mati/resources/verifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
from ..types.enums import (
DocumentScore,
Liveness,
UserValidationFile,
VerificationDocument,
VerificationDocumentStep,
)
from .base import Resource
from .user_verification_data import UserValidationData


@dataclass
Expand Down Expand Up @@ -36,13 +38,33 @@ def __post_init__(self):
docs.append(VerificationDocument(**doc))
self.documents = docs

@classmethod
def create(cls, flow_id: str, client=None, **metadata):
client = client or cls._client
resp = client.post(
cls._endpoint, json=dict(flowId=flow_id, metadata=metadata)
)
return cast('Verification', cls._from_dict(resp))

@classmethod
def retrieve(cls, verification_id: str, client=None) -> 'Verification':
client = client or cls._client
endpoint = f'{cls._endpoint}/{verification_id}'
resp = client.get(endpoint)
return cast('Verification', cls._from_dict(resp))

@classmethod
def upload_validation_data(
cls,
user_validation_files: List[UserValidationFile],
identity_id: str,
client=None,
) -> List[dict]:
client = client or cls._client
return UserValidationData.upload(
identity_id, user_validation_files, client=client
)

@property
def is_pending(self) -> bool:
return self.identity['status'] in ['running', 'pending']
Expand Down
5 changes: 3 additions & 2 deletions mati/types/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ValidationType(SerializableEnum):
national_id = 'national-id'
passport = 'passport'
proof_of_residency = 'proof-of-residency'
liveness = 'video/mp4'


@dataclass
Expand Down Expand Up @@ -109,8 +110,8 @@ class LivenessMedia:
class Liveness:
status: int
id: str
data: LivenessMedia
error: Optional[Dict]
data: Optional[LivenessMedia] = None
error: Optional[Dict] = None


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion mati/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.4' # pragma: no cover
__version__ = '2.0.0' # pragma: no cover
10 changes: 4 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,11 @@ def client() -> Generator:


@pytest.fixture
def identity(client: Client) -> Generator:
yield client.identities.create(
def verification(client: Client) -> Generator:
yield client.verifications.create(
'SOME_FLOW_ID',
client=client,
nombres='Georg Wilhelm',
primer_apellido='Friedrich',
segundo_apellido='Hegel',
dob='1770-08-27',
user='some_id',
)


Expand Down
73 changes: 0 additions & 73 deletions tests/resources/cassettes/test_create_identity.yaml

This file was deleted.

Loading

0 comments on commit d5c6df3

Please sign in to comment.