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