Skip to content

Commit 7641faf

Browse files
authored
Merge pull request #10 from getyoti/1.1.0-release
1.1.0 release
2 parents 5dfad7f + 36f5485 commit 7641faf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1554
-99
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
exclude: protobuf/
21
repos:
32
- repo: https://github.com/ambv/black
43
rev: stable

README.md

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,51 +26,12 @@ pip install yoti-sandbox
2626

2727
Please do not open the pem file as this might corrupt the key and you will need to create a new application.
2828

29-
## Profile Token Creation
29+
## Code Examples
3030

31-
```python
32-
import json
33-
34-
from yoti_python_sandbox import SandboxClientBuilder
35-
from yoti_python_sandbox import SandboxAgeVerificationBuilder
36-
from yoti_python_sandbox import YotiTokenRequestBuilder
37-
38-
sdk_id = "CLIENT_SDK_ID"
39-
pem_file_location = "/path/to/your-pem-file.pem"
40-
41-
client = (SandboxClientBuilder()
42-
.for_application(sdk_id)
43-
.with_pem_file(pem_file_location)
44-
.build())
45-
46-
age_verification = (SandboxAgeVerificationBuilder()
47-
.with_date_of_birth("1989-01-02")
48-
.with_age_over(18)
49-
.build())
50-
51-
token_request = (YotiTokenRequestBuilder()
52-
.with_remember_me_id("some_remember_me_id")
53-
.with_given_names("Some Given Names")
54-
.with_family_name("Some Family Name")
55-
.with_full_name("Some Full Name")
56-
.with_date_of_birth("1989-01-02")
57-
.with_age_verification(age_verification)
58-
.with_gender("Some Gender")
59-
.with_phone_number("Some Phone Number")
60-
.with_nationality("Some Nationality")
61-
.with_postal_address("Some Postal Address")
62-
.with_structured_postal_address(json.dumps({ "building_number": 1, "address_line1": "Some Address" }))
63-
.with_base64_selfie("Some Base64 Encoded Selfie")
64-
.with_email_address("Some Email Address")
65-
.with_document_details("PASSPORT USA 1234abc")
66-
.build())
67-
68-
token_response = client.setup_sharing_profile(token_request)
69-
70-
# Use the share_token to get Activity Details like normal
71-
share_token = token_response.token
72-
```
31+
In the examples folder there are snippets for:
32+
- [Yoti App](/examples/profile.py)
33+
- [Doc Scan](/examples/doc_scan.py)
7334

7435
## Additional Information
7536

76-
For more information about the Yoti Sandbox, please visit https://developers.yoti.com/yoti/sandbox-app
37+
For more information about the Yoti Sandbox, please visit https://developers.yoti.com/yoti/sandbox-app

examples/doc_scan.py

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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)

examples/profile.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import json
2+
3+
from yoti_python_sandbox import SandboxAgeVerificationBuilder
4+
from yoti_python_sandbox import SandboxClientBuilder
5+
from yoti_python_sandbox import YotiTokenRequestBuilder
6+
7+
8+
def profile_example_snippet():
9+
sandbox_client_sdk_id = "CLIENT_SDK_ID"
10+
pem_file_path = "/path/to/your-pem-file.pem"
11+
12+
client = (
13+
SandboxClientBuilder()
14+
.for_application(sandbox_client_sdk_id)
15+
.with_pem_file(pem_file_path)
16+
.build()
17+
)
18+
19+
age_verification = (
20+
SandboxAgeVerificationBuilder()
21+
.with_date_of_birth("1989-01-02")
22+
.with_age_over(18)
23+
.build()
24+
)
25+
26+
some_base64_encoded_selfie = (
27+
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk"
28+
"+A8AAQUBAScY42YAAAAASUVORK5CYII= "
29+
)
30+
31+
token_request = (
32+
YotiTokenRequestBuilder()
33+
.with_remember_me_id("some_remember_me_id")
34+
.with_given_names("Some Given Names")
35+
.with_family_name("Some Family Name")
36+
.with_full_name("Some Full Name")
37+
.with_date_of_birth("1989-01-02")
38+
.with_age_verification(age_verification)
39+
.with_gender("Some Gender")
40+
.with_phone_number("Some Phone Number")
41+
.with_nationality("Some Nationality")
42+
.with_postal_address("Some Postal Address")
43+
.with_structured_postal_address(
44+
json.dumps({"building_number": 1, "address_line1": "Some Address"})
45+
)
46+
.with_base64_selfie(some_base64_encoded_selfie)
47+
.with_email_address("Some Email Address")
48+
.with_document_details("PASSPORT USA 1234abc")
49+
.build()
50+
)
51+
52+
token_response = client.setup_sharing_profile(token_request)
53+
54+
# Use the share_token to get Activity Details like normal
55+
share_token = token_response.token

requirements.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
yoti==2.10.1
2-
cryptography>=2.7.0
1+
yoti==2.12.0
2+
cryptography>=2.7.0

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ cryptography==2.8 # via -r requirements.in, pyopenssl, yoti
1212
deprecated==1.2.6 # via yoti
1313
future==0.18.2 # via yoti
1414
idna==2.9 # via requests
15+
iso8601==0.1.12 # via yoti
1516
protobuf==3.11.3 # via yoti
1617
pycparser==2.20 # via cffi
1718
pyopenssl==19.1.0 # via yoti
1819
requests==2.23.0 # via yoti
1920
six==1.14.0 # via cryptography, protobuf, pyopenssl
2021
urllib3==1.25.8 # via requests
2122
wrapt==1.12.1 # via deprecated
22-
yoti==2.10.1 # via -r requirements.in
23+
yoti==2.12.0 # via -r requirements.in
2324

2425
# The following packages are considered to be unsafe in a requirements file:
2526
# setuptools

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
url="https://github.com/getyoti/yoti-python-sdk-sandbox",
2424
author="Yoti",
2525
author_email="websdk@yoti.com",
26-
install_requires=[
27-
"yoti>=2.10.2"
28-
"cryptography>=2.8.0",
29-
],
26+
install_requires=["yoti>=2.12.0" "cryptography>=2.8.0",],
3027
extras_require={
3128
"dev": [
3229
"pre-commit==1.17.0",

yoti_python_sandbox/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"YOTI_API_URL": "https://api.yoti.com",
1010
"YOTI_API_PORT": 443,
1111
"YOTI_API_VERSION": "v1",
12-
"YOTI_API_VERIFY_SSL": "true"
12+
"YOTI_API_VERIFY_SSL": "true",
1313
}
1414

1515
DEFAULT_SANDBOX_URL = DEFAULTS["YOTI_API_URL"] + "/sandbox/v1"
@@ -29,5 +29,5 @@
2929
__version__,
3030
SandboxClientBuilder,
3131
SandboxAgeVerificationBuilder,
32-
YotiTokenRequestBuilder
32+
YotiTokenRequestBuilder,
3333
]

yoti_python_sandbox/age_verification.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ def to_attribute(self):
3535
"""
3636
return (
3737
SandboxAttribute.builder()
38-
.with_name(config.ATTRIBUTE_DATE_OF_BIRTH)
39-
.with_value(self.__date_of_birth)
40-
.with_derivation(self.__supported_age_derivation)
41-
.with_anchors(self.__anchors)
42-
.build()
38+
.with_name(config.ATTRIBUTE_DATE_OF_BIRTH)
39+
.with_value(self.__date_of_birth)
40+
.with_derivation(self.__supported_age_derivation)
41+
.with_anchors(self.__anchors)
42+
.build()
4343
)
4444

4545
@staticmethod

yoti_python_sandbox/anchor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,8 @@ def build(self):
156156
:rtype: SandboxAnchor
157157
"""
158158
return SandboxAnchor(
159-
self.__type, self.__sub_type, self.__value, self.__unix_microsecond_timestamp
159+
self.__type,
160+
self.__sub_type,
161+
self.__value,
162+
self.__unix_microsecond_timestamp,
160163
)

0 commit comments

Comments
 (0)