Skip to content

Commit 554d1c4

Browse files
authored
Add selfie support (#124)
* Update proof_of_life_document to include selfie step * Format * Update version to 2.0.8 * Refactor proof_of_life_document method to use list * Update version to 2.0.8 * Update version to 2.0.8.dev3 * Refactor proof_of_life_url property * Enhance proof_of_life_url property to handle missing documents * Add assertion for proof_of_life_url in test_verification_without_liveness * Update version to 2.0.8
1 parent 4481946 commit 554d1c4

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

mati/resources/verifications.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,17 @@ def proof_of_residency_document(self) -> Optional[VerificationDocument]:
8282
def proof_of_life_document(self) -> Optional[Liveness]:
8383
if not self.steps:
8484
return None
85-
pol = [pol for pol in self.steps if pol.id == 'liveness']
85+
pol = [pol for pol in self.steps if pol.id in ['liveness', 'selfie']]
8686
return pol[-1] if pol else None
8787

88+
@property
89+
def proof_of_life_url(self) -> Optional[str]:
90+
pol = self.proof_of_life_document
91+
if not pol:
92+
return None
93+
data = getattr(pol, 'data', {}) or {}
94+
return data.get('video_url') or data.get('selfie_photo_url')
95+
8896
@property
8997
def proof_of_life_errors(self) -> List[Errors]:
9098
return [
@@ -97,7 +105,7 @@ def proof_of_life_errors(self) -> List[Errors]:
97105
else None,
98106
)
99107
for pol in self.steps # type: ignore
100-
if pol.id == 'liveness' and pol.error
108+
if pol.id in ['liveness', 'selfie'] and pol.error
101109
]
102110

103111
@property

mati/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.0.7'
1+
__version__ = '2.0.8'

tests/resources/test_verifications.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def test_retrieve_full_verification(client: Client):
2121
assert verification.govt_id_validation.is_valid
2222
assert verification.proof_of_life_validation.is_valid
2323
assert verification.proof_of_residency_validation.is_valid
24+
assert verification.proof_of_life_url
2425
assert not verification.govt_id_document.errors
2526
assert not verification.proof_of_residency_document.errors
2627
assert not verification.proof_of_life_errors
@@ -37,6 +38,7 @@ def test_verification_without_liveness(client: Client):
3738
verification = client.verifications.retrieve('5d9fb1f5bfbfac001a349bfb')
3839
verification.steps = []
3940
assert not verification.proof_of_life_document
41+
assert not verification.proof_of_life_url
4042

4143

4244
@pytest.mark.vcr

0 commit comments

Comments
 (0)