|
4 | 4 | DocScanClient,
|
5 | 5 | RequestedDocumentAuthenticityCheckBuilder,
|
6 | 6 | RequestedFaceMatchCheckBuilder,
|
| 7 | + RequestedIDDocumentComparisonCheckBuilder, |
7 | 8 | RequestedLivenessCheckBuilder,
|
8 | 9 | RequestedTextExtractionTaskBuilder,
|
9 | 10 | SdkConfigBuilder,
|
10 | 11 | SessionSpecBuilder,
|
11 | 12 | )
|
12 | 13 | from yoti_python_sdk.doc_scan.exception import DocScanException
|
| 14 | +from yoti_python_sdk.doc_scan.session.create.filter import ( |
| 15 | + RequiredIdDocumentBuilder, |
| 16 | + DocumentRestrictionBuilder, |
| 17 | + DocumentRestrictionsFilterBuilder, |
| 18 | +) |
13 | 19 |
|
14 | 20 | from .settings import YOTI_APP_BASE_URL, YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH
|
15 | 21 |
|
@@ -52,18 +58,34 @@ def create_session():
|
52 | 58 | .build()
|
53 | 59 | )
|
54 | 60 | .with_requested_check(
|
55 |
| - RequestedFaceMatchCheckBuilder().with_manual_check_fallback().build() |
| 61 | + RequestedFaceMatchCheckBuilder().with_manual_check_never().build() |
56 | 62 | )
|
| 63 | + .with_requested_check(RequestedIDDocumentComparisonCheckBuilder().build()) |
57 | 64 | .with_requested_task(
|
58 |
| - RequestedTextExtractionTaskBuilder().with_manual_check_always().build() |
| 65 | + RequestedTextExtractionTaskBuilder().with_manual_check_never().build() |
59 | 66 | )
|
60 | 67 | .with_sdk_config(sdk_config)
|
| 68 | + .with_required_document(build_required_id_document_restriction("PASSPORT")) |
| 69 | + .with_required_document( |
| 70 | + build_required_id_document_restriction("DRIVING_LICENCE") |
| 71 | + ) |
61 | 72 | .build()
|
62 | 73 | )
|
63 | 74 |
|
64 | 75 | return doc_scan_client.create_session(session_spec)
|
65 | 76 |
|
66 | 77 |
|
| 78 | +def build_required_id_document_restriction(document_type): |
| 79 | + document_restriction = ( |
| 80 | + DocumentRestrictionBuilder().with_document_types([document_type]).build() |
| 81 | + ) |
| 82 | + |
| 83 | + filter_builder = DocumentRestrictionsFilterBuilder().for_whitelist() |
| 84 | + filter_builder.with_document_restriction(document_restriction) |
| 85 | + |
| 86 | + return RequiredIdDocumentBuilder().with_filter(filter_builder.build()).build() |
| 87 | + |
| 88 | + |
67 | 89 | @app.route("/")
|
68 | 90 | def index():
|
69 | 91 | try:
|
|
0 commit comments