Skip to content

Commit ebe324a

Browse files
authored
Merge pull request #49 from Kaevan89/update-python-sdk
Update python sdk
2 parents f7b4651 + fb14624 commit ebe324a

30 files changed

+2657
-517
lines changed

.gitignore

+170-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,171 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
143
.coverage
2-
tests/__pycache__/
3-
veryfi/__pycache__/
4-
.idea/*
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
.idea/
169+
170+
# VSCode
171+
.vscode/

tests/test_line_items.py tests/_documents/test_line_items.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import responses
22

3-
from veryfi import *
3+
from veryfi import Client
44

55

66
@responses.activate

tests/_documents/test_tags.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import responses
2+
3+
from veryfi import Client
4+
5+
6+
@responses.activate
7+
def test_tags():
8+
mock_doc_id = 169985445
9+
mock_resp = {"id": 6673474, "name": "tag_123"}
10+
client = Client(client_id="v", client_secret="w", username="o", api_key="c")
11+
responses.put(
12+
f"{client.versioned_url}/partner/documents/{mock_doc_id}/tags/",
13+
json=mock_resp,
14+
status=200,
15+
)
16+
d = client.add_tag(mock_doc_id, "tag_123")
17+
assert d == mock_resp
18+
19+
20+
@responses.activate
21+
def test_replace_multiple_tags():
22+
mock_doc_id = 169985445
23+
mock_resp = {"id": 6673474, "tags": ["tag_1", "tag_2", "tag_3"]}
24+
client = Client(client_id="v", client_secret="w", username="o", api_key="c")
25+
responses.put(
26+
f"{client.versioned_url}/partner/documents/{mock_doc_id}/",
27+
json=mock_resp,
28+
status=200,
29+
)
30+
d = client.replace_tags(mock_doc_id, ["tag_1", "tag_2", "tag_3"])
31+
assert d == mock_resp
32+
33+
34+
@responses.activate
35+
def test_add_multiple_tags():
36+
mock_doc_id = 169985445
37+
mock_resp = {"id": 6673474, "tags": ["tag_1", "tag_2", "tag_3"]}
38+
client = Client(client_id="v", client_secret="w", username="o", api_key="c")
39+
responses.post(
40+
f"{client.versioned_url}/partner/documents/{mock_doc_id}/tags/",
41+
json=mock_resp,
42+
status=200,
43+
)
44+
d = client.add_tags(mock_doc_id, ["tag_1", "tag_2", "tag_3"])
45+
assert d == mock_resp

tests/test_a_docs.py

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import pytest
2+
import responses
3+
4+
from veryfi import Client
5+
6+
7+
@responses.activate
8+
def test_process_a_doc():
9+
mock = {
10+
"pdf_url": "https://scdn.veryfi.com/other-documents/919ba4778c039560/cf1363b8-a38f-47e8-b9ee-8105342121cd/7179c430-eb38-4251-b015-9ceb20129371.pdf?Expires=1727203608&Signature=ZSfZmJRLtJ6DeIRioIQSExufnR4fDvADq1Fs-x~WnbU1JueQ1PLtY~7b~Krk7eda6EAQkMBa2wamDDcE2lCvrutHCS3jUbhlFFhSuQd1XljbYjBlWOdxYyXpYMmluDlaWlkgm41vA92UD3LSsBPBLrBasotjqNYLGnTg87guXTtUG1rSWlK2FhHxzborReNdrpXUcDMs4-kkQ46tTDgFH~mCPkh5F9DSpm-UsyJ6SmJgm1SWfw09KbQizyp4lIwte1yumKXtORtTCKv5WFWRUFUWD6Kv1eIkh5XJ5jfMzSfaTEikZlYF4t08Lbp5Apk5-alOW-1yYIwqb5RqZhQ26w__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ",
11+
"id": 4559535,
12+
"external_id": None,
13+
"created_date": "2024-09-24 18:31:48",
14+
"updated_date": "2024-09-24 18:31:48",
15+
"img_thumbnail_url": "https://scdn.veryfi.com/other-documents/919ba4778c039560/cf1363b8-a38f-47e8-b9ee-8105342121cd/thumbnail.png?Expires=1727203608&Signature=SIRru1E-r1VT5KmufOC9A3UXlWzpgaZWUn0GhSj~veGagGAISV7sztEA7bER~kZlVnowRBSu19UaR8VeGfQ39uzUxEVlzdxPgjITt7IEgfGa~B-0EUI8izLDfRoOMkdRrOknLJKpCq87hz8fMn6wfKSgWxGgyCFKuvO2zcdla~fmtcTOrR4OMAPA3TX4Y4ZRnwCfUDQwNMw72Zihh9bxulzgjM6Cqffc7wta6wC84rYRlztPgGQj51ARcewG5s-IouvrJKoTAONLJZaq8CEc-iMh~TRzKf4MiI5HoheBFmjKb2NdoJFDpHR~~aLW8RxWkEV87JtglILAumkjrY7jjw__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ",
16+
"blueprint_name": "us_driver_license",
17+
"template_name": "us_driver_license",
18+
"address": "892 MOMONA ST HONOLULU, HI 96820",
19+
"birth_date": "1981-06-03",
20+
"expiration_date": "2008-06-03",
21+
"eyes_color": "BRO",
22+
"first_name": None,
23+
"height": "5-10",
24+
"issue_date": "1998-06-18",
25+
"last_name": "McLovin",
26+
"license_class": "3",
27+
"license_number": "01-47-87441",
28+
"sex": "M",
29+
"state": "HAWAII",
30+
"weight": "150",
31+
}
32+
client = Client(client_id="v", client_secret="w", username="o", api_key="c")
33+
responses.add(
34+
responses.POST,
35+
f"{client.versioned_url}/partner/any-documents/",
36+
json=mock,
37+
status=200,
38+
)
39+
d = client.process_any_document(
40+
blueprint_name="us_driver_license",
41+
file_path="tests/assets/receipt_public.jpg",
42+
delete_after_processing=True,
43+
boost_mode=True,
44+
)
45+
assert d == mock
46+
47+
48+
@responses.activate
49+
def test_process_document_url():
50+
mock = {
51+
"pdf_url": "https://scdn.veryfi.com/other-documents/919ba4778c039560/cf1363b8-a38f-47e8-b9ee-8105342121cd/7179c430-eb38-4251-b015-9ceb20129371.pdf?Expires=1727203608&Signature=ZSfZmJRLtJ6DeIRioIQSExufnR4fDvADq1Fs-x~WnbU1JueQ1PLtY~7b~Krk7eda6EAQkMBa2wamDDcE2lCvrutHCS3jUbhlFFhSuQd1XljbYjBlWOdxYyXpYMmluDlaWlkgm41vA92UD3LSsBPBLrBasotjqNYLGnTg87guXTtUG1rSWlK2FhHxzborReNdrpXUcDMs4-kkQ46tTDgFH~mCPkh5F9DSpm-UsyJ6SmJgm1SWfw09KbQizyp4lIwte1yumKXtORtTCKv5WFWRUFUWD6Kv1eIkh5XJ5jfMzSfaTEikZlYF4t08Lbp5Apk5-alOW-1yYIwqb5RqZhQ26w__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ",
52+
"id": 4559535,
53+
"external_id": None,
54+
"created_date": "2024-09-24 18:31:48",
55+
"updated_date": "2024-09-24 18:31:48",
56+
"img_thumbnail_url": "https://scdn.veryfi.com/other-documents/919ba4778c039560/cf1363b8-a38f-47e8-b9ee-8105342121cd/thumbnail.png?Expires=1727203608&Signature=SIRru1E-r1VT5KmufOC9A3UXlWzpgaZWUn0GhSj~veGagGAISV7sztEA7bER~kZlVnowRBSu19UaR8VeGfQ39uzUxEVlzdxPgjITt7IEgfGa~B-0EUI8izLDfRoOMkdRrOknLJKpCq87hz8fMn6wfKSgWxGgyCFKuvO2zcdla~fmtcTOrR4OMAPA3TX4Y4ZRnwCfUDQwNMw72Zihh9bxulzgjM6Cqffc7wta6wC84rYRlztPgGQj51ARcewG5s-IouvrJKoTAONLJZaq8CEc-iMh~TRzKf4MiI5HoheBFmjKb2NdoJFDpHR~~aLW8RxWkEV87JtglILAumkjrY7jjw__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ",
57+
"blueprint_name": "us_driver_license",
58+
"template_name": "us_driver_license",
59+
"address": "892 MOMONA ST HONOLULU, HI 96820",
60+
"birth_date": "1981-06-03",
61+
"expiration_date": "2008-06-03",
62+
"eyes_color": "BRO",
63+
"first_name": None,
64+
"height": "5-10",
65+
"issue_date": "1998-06-18",
66+
"last_name": "McLovin",
67+
"license_class": "3",
68+
"license_number": "01-47-87441",
69+
"sex": "M",
70+
"state": "HAWAII",
71+
"weight": "150",
72+
}
73+
74+
client = Client(client_id="v", client_secret="w", username="o", api_key="c")
75+
responses.add(
76+
responses.POST,
77+
f"{client.versioned_url}/partner/any-documents/",
78+
json=mock,
79+
status=200,
80+
)
81+
d = client.process_any_document_url(
82+
blueprint_name="us_driver_license",
83+
file_url="http://cdn-dev.veryfi.com/testing/veryfi-python/receipt_public.jpg",
84+
delete_after_processing=True,
85+
max_pages_to_process=1,
86+
boost_mode=True,
87+
)
88+
assert d == mock
89+
90+
91+
@responses.activate
92+
def test_get_documents():
93+
mock = [
94+
{
95+
"pdf_url": "https://scdn.veryfi.com/other-documents/919ba4778c039560/cf1363b8-a38f-47e8-b9ee-8105342121cd/7179c430-eb38-4251-b015-9ceb20129371.pdf?Expires=1727203608&Signature=ZSfZmJRLtJ6DeIRioIQSExufnR4fDvADq1Fs-x~WnbU1JueQ1PLtY~7b~Krk7eda6EAQkMBa2wamDDcE2lCvrutHCS3jUbhlFFhSuQd1XljbYjBlWOdxYyXpYMmluDlaWlkgm41vA92UD3LSsBPBLrBasotjqNYLGnTg87guXTtUG1rSWlK2FhHxzborReNdrpXUcDMs4-kkQ46tTDgFH~mCPkh5F9DSpm-UsyJ6SmJgm1SWfw09KbQizyp4lIwte1yumKXtORtTCKv5WFWRUFUWD6Kv1eIkh5XJ5jfMzSfaTEikZlYF4t08Lbp5Apk5-alOW-1yYIwqb5RqZhQ26w__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ",
96+
"id": 4559535,
97+
"external_id": None,
98+
"created_date": "2024-09-24 18:31:48",
99+
"updated_date": "2024-09-24 18:31:48",
100+
"img_thumbnail_url": "https://scdn.veryfi.com/other-documents/919ba4778c039560/cf1363b8-a38f-47e8-b9ee-8105342121cd/thumbnail.png?Expires=1727203608&Signature=SIRru1E-r1VT5KmufOC9A3UXlWzpgaZWUn0GhSj~veGagGAISV7sztEA7bER~kZlVnowRBSu19UaR8VeGfQ39uzUxEVlzdxPgjITt7IEgfGa~B-0EUI8izLDfRoOMkdRrOknLJKpCq87hz8fMn6wfKSgWxGgyCFKuvO2zcdla~fmtcTOrR4OMAPA3TX4Y4ZRnwCfUDQwNMw72Zihh9bxulzgjM6Cqffc7wta6wC84rYRlztPgGQj51ARcewG5s-IouvrJKoTAONLJZaq8CEc-iMh~TRzKf4MiI5HoheBFmjKb2NdoJFDpHR~~aLW8RxWkEV87JtglILAumkjrY7jjw__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ",
101+
"blueprint_name": "us_driver_license",
102+
"template_name": "us_driver_license",
103+
"address": "892 MOMONA ST HONOLULU, HI 96820",
104+
"birth_date": "1981-06-03",
105+
"expiration_date": "2008-06-03",
106+
"eyes_color": "BRO",
107+
"first_name": None,
108+
"height": "5-10",
109+
"issue_date": "1998-06-18",
110+
"last_name": "McLovin",
111+
"license_class": "3",
112+
"license_number": "01-47-87441",
113+
"sex": "M",
114+
"state": "HAWAII",
115+
"weight": "150",
116+
}
117+
]
118+
client = Client(client_id="v", client_secret="w", username="o", api_key="c")
119+
responses.add(
120+
responses.GET,
121+
f"{client.versioned_url}/partner/any-documents/",
122+
json=mock,
123+
status=200,
124+
)
125+
d = client.get_any_documents()
126+
assert d == mock

0 commit comments

Comments
 (0)