|
| 1 | +from yoti_python_sandbox.doc_scan import ( |
| 2 | + ResponseConfigBuilder, |
| 3 | + SandboxDocumentFilterBuilder, |
| 4 | +) |
| 5 | +from yoti_python_sandbox.doc_scan.check import ( |
| 6 | + SandboxDocumentAuthenticityCheckBuilder, |
| 7 | + SandboxBreakdownBuilder, |
| 8 | + SandboxRecommendationBuilder, |
| 9 | + SandboxDocumentFaceMatchCheckBuilder, |
| 10 | + SandboxDocumentTextDataCheckBuilder, |
| 11 | + SandboxZoomLivenessCheckBuilder, |
| 12 | + SandboxDetail, |
| 13 | +) |
| 14 | +from yoti_python_sandbox.doc_scan.check_reports import SandboxCheckReportsBuilder |
| 15 | +from yoti_python_sandbox.doc_scan.client import DocScanSandboxClient |
| 16 | +from yoti_python_sandbox.doc_scan.task import ( |
| 17 | + SandboxDocumentTextDataExtractionTaskBuilder, |
| 18 | +) |
| 19 | +from yoti_python_sandbox.doc_scan.task_results import SandboxTaskResultsBuilder |
| 20 | + |
| 21 | + |
| 22 | +def doc_scan_example_snippet(): |
| 23 | + document_filter = ( |
| 24 | + SandboxDocumentFilterBuilder() |
| 25 | + .with_country_code("GBR") |
| 26 | + .with_document_type("PASSPORT") |
| 27 | + .build() |
| 28 | + ) |
| 29 | + |
| 30 | + response_config = ( |
| 31 | + ResponseConfigBuilder() |
| 32 | + .with_check_reports( |
| 33 | + ( |
| 34 | + SandboxCheckReportsBuilder() |
| 35 | + .with_async_report_delay(10) |
| 36 | + .with_document_authenticity_check( |
| 37 | + ( |
| 38 | + SandboxDocumentAuthenticityCheckBuilder() |
| 39 | + .with_breakdown( |
| 40 | + ( |
| 41 | + SandboxBreakdownBuilder() |
| 42 | + .with_sub_check("security_features") |
| 43 | + .with_result("NOT_AVAILABLE") |
| 44 | + .with_detail( |
| 45 | + SandboxDetail("some_detail", "some_detail_value") |
| 46 | + ) |
| 47 | + .build() |
| 48 | + ) |
| 49 | + ) |
| 50 | + .with_recommendation( |
| 51 | + ( |
| 52 | + SandboxRecommendationBuilder() |
| 53 | + .with_value("NOT_AVAILABLE") |
| 54 | + .with_reason("PICTURE_TOO_DARK") |
| 55 | + .with_recovery_suggestion("BETTER_LIGHTING") |
| 56 | + .build() |
| 57 | + ) |
| 58 | + ) |
| 59 | + .with_document_filter(document_filter) |
| 60 | + .build() |
| 61 | + ) |
| 62 | + ) |
| 63 | + .with_document_face_match_check( |
| 64 | + ( |
| 65 | + SandboxDocumentFaceMatchCheckBuilder() |
| 66 | + .with_breakdown( |
| 67 | + ( |
| 68 | + SandboxBreakdownBuilder() |
| 69 | + .with_sub_check("security_features") |
| 70 | + .with_result("PASS") |
| 71 | + .build() |
| 72 | + ) |
| 73 | + ) |
| 74 | + .with_recommendation( |
| 75 | + ( |
| 76 | + SandboxRecommendationBuilder() |
| 77 | + .with_value("APPROVE") |
| 78 | + .build() |
| 79 | + ) |
| 80 | + ) |
| 81 | + .with_document_filter(document_filter) |
| 82 | + .build() |
| 83 | + ) |
| 84 | + ) |
| 85 | + .with_document_text_data_check( |
| 86 | + ( |
| 87 | + SandboxDocumentTextDataCheckBuilder() |
| 88 | + .with_breakdown( |
| 89 | + ( |
| 90 | + SandboxBreakdownBuilder() |
| 91 | + .with_sub_check("document_in_date") |
| 92 | + .with_result("PASS") |
| 93 | + .build() |
| 94 | + ) |
| 95 | + ) |
| 96 | + .with_recommendation( |
| 97 | + ( |
| 98 | + SandboxRecommendationBuilder() |
| 99 | + .with_value("APPROVE") |
| 100 | + .build() |
| 101 | + ) |
| 102 | + ) |
| 103 | + .with_document_filter(document_filter) |
| 104 | + .with_document_field("full_name", "John Doe") |
| 105 | + .with_document_field("nationality", "GBR") |
| 106 | + .with_document_field("date_of_birth", "1986-06-01") |
| 107 | + .with_document_field("document_number", "123456789") |
| 108 | + .build() |
| 109 | + ) |
| 110 | + ) |
| 111 | + .with_liveness_check( |
| 112 | + ( |
| 113 | + SandboxZoomLivenessCheckBuilder() |
| 114 | + .with_breakdown( |
| 115 | + ( |
| 116 | + SandboxBreakdownBuilder() |
| 117 | + .with_sub_check("security_features") |
| 118 | + .with_result("PASS") |
| 119 | + .build() |
| 120 | + ) |
| 121 | + ) |
| 122 | + .with_recommendation( |
| 123 | + ( |
| 124 | + SandboxRecommendationBuilder() |
| 125 | + .with_value("APPROVE") |
| 126 | + .build() |
| 127 | + ) |
| 128 | + ) |
| 129 | + .build() |
| 130 | + ) |
| 131 | + ) |
| 132 | + .build() |
| 133 | + ) |
| 134 | + ) |
| 135 | + .with_task_results( |
| 136 | + ( |
| 137 | + SandboxTaskResultsBuilder() |
| 138 | + .with_text_extraction_task( |
| 139 | + ( |
| 140 | + SandboxDocumentTextDataExtractionTaskBuilder() |
| 141 | + .with_document_field("full_name", "John Doe") |
| 142 | + .with_document_field("nationality", "GBR") |
| 143 | + .with_document_field("date_of_birth", "1986-06-01") |
| 144 | + .with_document_field("document_number", "123456789") |
| 145 | + .with_document_filter(document_filter) |
| 146 | + .build() |
| 147 | + ) |
| 148 | + ) |
| 149 | + .build() |
| 150 | + ) |
| 151 | + ) |
| 152 | + .build() |
| 153 | + ) |
| 154 | + |
| 155 | + sandbox_client_sdk_id = "YourSandboxClientSdkIdFromHub" |
| 156 | + pem_file_path = "path/to/your/pem/file.pem" |
| 157 | + |
| 158 | + doc_scan_sandbox_client = DocScanSandboxClient(sandbox_client_sdk_id, pem_file_path) |
| 159 | + |
| 160 | + doc_scan_sandbox_client.configure_session_response("yourSessionId", response_config) |
0 commit comments