origoid 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- origoid-0.1.0/PKG-INFO +169 -0
- origoid-0.1.0/README.md +142 -0
- origoid-0.1.0/pyproject.toml +61 -0
- origoid-0.1.0/src/origoid/__init__.py +42 -0
- origoid-0.1.0/src/origoid/authentication/__init__.py +2 -0
- origoid-0.1.0/src/origoid/authentication/client.py +162 -0
- origoid-0.1.0/src/origoid/biometrics/__init__.py +5 -0
- origoid-0.1.0/src/origoid/biometrics/client.py +384 -0
- origoid-0.1.0/src/origoid/biometrics/types/__init__.py +5 -0
- origoid-0.1.0/src/origoid/biometrics/types/match_faces_request_document_type.py +7 -0
- origoid-0.1.0/src/origoid/client.py +172 -0
- origoid-0.1.0/src/origoid/compliance/__init__.py +5 -0
- origoid-0.1.0/src/origoid/compliance/client.py +731 -0
- origoid-0.1.0/src/origoid/compliance/types/__init__.py +7 -0
- origoid-0.1.0/src/origoid/compliance/types/search_peps_request.py +5 -0
- origoid-0.1.0/src/origoid/compliance/types/search_sat69b_request.py +5 -0
- origoid-0.1.0/src/origoid/compliance/types/search_sat69request.py +5 -0
- origoid-0.1.0/src/origoid/core/__init__.py +46 -0
- origoid-0.1.0/src/origoid/core/api_error.py +15 -0
- origoid-0.1.0/src/origoid/core/client_wrapper.py +54 -0
- origoid-0.1.0/src/origoid/core/datetime_utils.py +28 -0
- origoid-0.1.0/src/origoid/core/file.py +43 -0
- origoid-0.1.0/src/origoid/core/http_client.py +477 -0
- origoid-0.1.0/src/origoid/core/jsonable_encoder.py +101 -0
- origoid-0.1.0/src/origoid/core/pydantic_utilities.py +273 -0
- origoid-0.1.0/src/origoid/core/query_encoder.py +58 -0
- origoid-0.1.0/src/origoid/core/remove_none_from_dict.py +11 -0
- origoid-0.1.0/src/origoid/core/request_options.py +32 -0
- origoid-0.1.0/src/origoid/core/serialization.py +254 -0
- origoid-0.1.0/src/origoid/email/__init__.py +2 -0
- origoid-0.1.0/src/origoid/email/client.py +183 -0
- origoid-0.1.0/src/origoid/environment.py +7 -0
- origoid-0.1.0/src/origoid/errors/__init__.py +6 -0
- origoid-0.1.0/src/origoid/errors/too_many_requests_error.py +9 -0
- origoid-0.1.0/src/origoid/errors/unauthorized_error.py +9 -0
- origoid-0.1.0/src/origoid/imss/__init__.py +2 -0
- origoid-0.1.0/src/origoid/imss/client.py +349 -0
- origoid-0.1.0/src/origoid/ine/__init__.py +5 -0
- origoid-0.1.0/src/origoid/ine/client.py +529 -0
- origoid-0.1.0/src/origoid/ine/types/__init__.py +5 -0
- origoid-0.1.0/src/origoid/ine/types/validate_voter_list_request.py +5 -0
- origoid-0.1.0/src/origoid/proof_of_address/__init__.py +2 -0
- origoid-0.1.0/src/origoid/proof_of_address/client.py +203 -0
- origoid-0.1.0/src/origoid/py.typed +0 -0
- origoid-0.1.0/src/origoid/renapo/__init__.py +5 -0
- origoid-0.1.0/src/origoid/renapo/client.py +432 -0
- origoid-0.1.0/src/origoid/renapo/types/__init__.py +5 -0
- origoid-0.1.0/src/origoid/renapo/types/lookup_curp_request_gender.py +5 -0
- origoid-0.1.0/src/origoid/sat/__init__.py +5 -0
- origoid-0.1.0/src/origoid/sat/client.py +506 -0
- origoid-0.1.0/src/origoid/sat/types/__init__.py +6 -0
- origoid-0.1.0/src/origoid/sat/types/extract_csf_request.py +5 -0
- origoid-0.1.0/src/origoid/sat/types/validate_cfdi_request.py +5 -0
- origoid-0.1.0/src/origoid/types/__init__.py +7 -0
- origoid-0.1.0/src/origoid/types/envelope.py +62 -0
- origoid-0.1.0/src/origoid/types/envelope_status.py +5 -0
- origoid-0.1.0/src/origoid/types/error_detail.py +32 -0
- origoid-0.1.0/src/origoid/version.py +3 -0
origoid-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: origoid
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary:
|
|
5
|
+
Requires-Python: >=3.8,<4.0
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: Operating System :: MacOS
|
|
8
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Operating System :: POSIX
|
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Dist: httpx (>=0.21.2)
|
|
22
|
+
Requires-Dist: pydantic (>=2.0.0)
|
|
23
|
+
Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
|
|
24
|
+
Requires-Dist: typing_extensions (>=4.0.0)
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Origoid Python Library
|
|
28
|
+
|
|
29
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Forigoid%2Fsdk-python)
|
|
30
|
+
[](https://pypi.python.org/pypi/origoid)
|
|
31
|
+
|
|
32
|
+
The Origoid Python library provides convenient access to the Origoid APIs from Python.
|
|
33
|
+
|
|
34
|
+
## Table of Contents
|
|
35
|
+
|
|
36
|
+
- [Installation](#installation)
|
|
37
|
+
- [Usage](#usage)
|
|
38
|
+
- [Async Client](#async-client)
|
|
39
|
+
- [Exception Handling](#exception-handling)
|
|
40
|
+
- [Advanced](#advanced)
|
|
41
|
+
- [Retries](#retries)
|
|
42
|
+
- [Timeouts](#timeouts)
|
|
43
|
+
- [Custom Client](#custom-client)
|
|
44
|
+
- [Contributing](#contributing)
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
pip install origoid
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
Instantiate and use the client with the following:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from origoid import OrigoID
|
|
58
|
+
|
|
59
|
+
client = OrigoID(
|
|
60
|
+
api_key="YOUR_API_KEY",
|
|
61
|
+
)
|
|
62
|
+
client.authentication.issue_token()
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Async Client
|
|
66
|
+
|
|
67
|
+
The SDK also exports an `async` client so that you can make non-blocking calls to our API.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
import asyncio
|
|
71
|
+
|
|
72
|
+
from origoid import AsyncOrigoID
|
|
73
|
+
|
|
74
|
+
client = AsyncOrigoID(
|
|
75
|
+
api_key="YOUR_API_KEY",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
async def main() -> None:
|
|
80
|
+
await client.authentication.issue_token()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
asyncio.run(main())
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Exception Handling
|
|
87
|
+
|
|
88
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
89
|
+
will be thrown.
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from origoid.core.api_error import ApiError
|
|
93
|
+
|
|
94
|
+
try:
|
|
95
|
+
client.authentication.issue_token(...)
|
|
96
|
+
except ApiError as e:
|
|
97
|
+
print(e.status_code)
|
|
98
|
+
print(e.body)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Advanced
|
|
102
|
+
|
|
103
|
+
### Retries
|
|
104
|
+
|
|
105
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
106
|
+
as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
|
|
107
|
+
retry limit (default: 2).
|
|
108
|
+
|
|
109
|
+
A request is deemed retriable when any of the following HTTP status codes is returned:
|
|
110
|
+
|
|
111
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
112
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
113
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
114
|
+
|
|
115
|
+
Use the `max_retries` request option to configure this behavior.
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
client.authentication.issue_token(..., {
|
|
119
|
+
"max_retries": 1
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Timeouts
|
|
124
|
+
|
|
125
|
+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
|
|
129
|
+
from origoid import OrigoID
|
|
130
|
+
|
|
131
|
+
client = OrigoID(
|
|
132
|
+
...,
|
|
133
|
+
timeout=20.0,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
# Override timeout for a specific method
|
|
138
|
+
client.authentication.issue_token(..., {
|
|
139
|
+
"timeout_in_seconds": 1
|
|
140
|
+
})
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Custom Client
|
|
144
|
+
|
|
145
|
+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
146
|
+
and transports.
|
|
147
|
+
```python
|
|
148
|
+
import httpx
|
|
149
|
+
from origoid import OrigoID
|
|
150
|
+
|
|
151
|
+
client = OrigoID(
|
|
152
|
+
...,
|
|
153
|
+
httpx_client=httpx.Client(
|
|
154
|
+
proxies="http://my.test.proxy.example.com",
|
|
155
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
156
|
+
),
|
|
157
|
+
)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Contributing
|
|
161
|
+
|
|
162
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
163
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
164
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
165
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
166
|
+
an issue first to discuss with us!
|
|
167
|
+
|
|
168
|
+
On the other hand, contributions to the README are always very welcome!
|
|
169
|
+
|
origoid-0.1.0/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Origoid Python Library
|
|
2
|
+
|
|
3
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Forigoid%2Fsdk-python)
|
|
4
|
+
[](https://pypi.python.org/pypi/origoid)
|
|
5
|
+
|
|
6
|
+
The Origoid Python library provides convenient access to the Origoid APIs from Python.
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Usage](#usage)
|
|
12
|
+
- [Async Client](#async-client)
|
|
13
|
+
- [Exception Handling](#exception-handling)
|
|
14
|
+
- [Advanced](#advanced)
|
|
15
|
+
- [Retries](#retries)
|
|
16
|
+
- [Timeouts](#timeouts)
|
|
17
|
+
- [Custom Client](#custom-client)
|
|
18
|
+
- [Contributing](#contributing)
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
pip install origoid
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
Instantiate and use the client with the following:
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from origoid import OrigoID
|
|
32
|
+
|
|
33
|
+
client = OrigoID(
|
|
34
|
+
api_key="YOUR_API_KEY",
|
|
35
|
+
)
|
|
36
|
+
client.authentication.issue_token()
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Async Client
|
|
40
|
+
|
|
41
|
+
The SDK also exports an `async` client so that you can make non-blocking calls to our API.
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import asyncio
|
|
45
|
+
|
|
46
|
+
from origoid import AsyncOrigoID
|
|
47
|
+
|
|
48
|
+
client = AsyncOrigoID(
|
|
49
|
+
api_key="YOUR_API_KEY",
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
async def main() -> None:
|
|
54
|
+
await client.authentication.issue_token()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
asyncio.run(main())
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Exception Handling
|
|
61
|
+
|
|
62
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
63
|
+
will be thrown.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from origoid.core.api_error import ApiError
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
client.authentication.issue_token(...)
|
|
70
|
+
except ApiError as e:
|
|
71
|
+
print(e.status_code)
|
|
72
|
+
print(e.body)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Advanced
|
|
76
|
+
|
|
77
|
+
### Retries
|
|
78
|
+
|
|
79
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
80
|
+
as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
|
|
81
|
+
retry limit (default: 2).
|
|
82
|
+
|
|
83
|
+
A request is deemed retriable when any of the following HTTP status codes is returned:
|
|
84
|
+
|
|
85
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
86
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
87
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
88
|
+
|
|
89
|
+
Use the `max_retries` request option to configure this behavior.
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
client.authentication.issue_token(..., {
|
|
93
|
+
"max_retries": 1
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Timeouts
|
|
98
|
+
|
|
99
|
+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
|
|
103
|
+
from origoid import OrigoID
|
|
104
|
+
|
|
105
|
+
client = OrigoID(
|
|
106
|
+
...,
|
|
107
|
+
timeout=20.0,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# Override timeout for a specific method
|
|
112
|
+
client.authentication.issue_token(..., {
|
|
113
|
+
"timeout_in_seconds": 1
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Custom Client
|
|
118
|
+
|
|
119
|
+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
120
|
+
and transports.
|
|
121
|
+
```python
|
|
122
|
+
import httpx
|
|
123
|
+
from origoid import OrigoID
|
|
124
|
+
|
|
125
|
+
client = OrigoID(
|
|
126
|
+
...,
|
|
127
|
+
httpx_client=httpx.Client(
|
|
128
|
+
proxies="http://my.test.proxy.example.com",
|
|
129
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
130
|
+
),
|
|
131
|
+
)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Contributing
|
|
135
|
+
|
|
136
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
137
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
138
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
139
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
140
|
+
an issue first to discuss with us!
|
|
141
|
+
|
|
142
|
+
On the other hand, contributions to the README are always very welcome!
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "origoid"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = ""
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = []
|
|
7
|
+
keywords = []
|
|
8
|
+
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Intended Audience :: Developers",
|
|
11
|
+
"Programming Language :: Python",
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"Programming Language :: Python :: 3.8",
|
|
14
|
+
"Programming Language :: Python :: 3.9",
|
|
15
|
+
"Programming Language :: Python :: 3.10",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Operating System :: POSIX",
|
|
20
|
+
"Operating System :: MacOS",
|
|
21
|
+
"Operating System :: POSIX :: Linux",
|
|
22
|
+
"Operating System :: Microsoft :: Windows",
|
|
23
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
24
|
+
"Typing :: Typed"
|
|
25
|
+
]
|
|
26
|
+
packages = [
|
|
27
|
+
{ include = "origoid", from = "src"}
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Repository = 'https://github.com/origoid/sdk-python'
|
|
32
|
+
|
|
33
|
+
[tool.poetry.dependencies]
|
|
34
|
+
python = "^3.8"
|
|
35
|
+
httpx = ">=0.21.2"
|
|
36
|
+
pydantic = ">= 2.0.0"
|
|
37
|
+
pydantic-core = "^2.18.2"
|
|
38
|
+
typing_extensions = ">= 4.0.0"
|
|
39
|
+
|
|
40
|
+
[tool.poetry.dev-dependencies]
|
|
41
|
+
mypy = "1.0.1"
|
|
42
|
+
pytest = "^7.4.0"
|
|
43
|
+
pytest-asyncio = "^0.23.5"
|
|
44
|
+
python-dateutil = "^2.9.0"
|
|
45
|
+
types-python-dateutil = "^2.9.0.20240316"
|
|
46
|
+
ruff = "^0.5.6"
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
testpaths = [ "tests" ]
|
|
50
|
+
asyncio_mode = "auto"
|
|
51
|
+
|
|
52
|
+
[tool.mypy]
|
|
53
|
+
plugins = ["pydantic.mypy"]
|
|
54
|
+
|
|
55
|
+
[tool.ruff]
|
|
56
|
+
line-length = 120
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
[build-system]
|
|
60
|
+
requires = ["poetry-core"]
|
|
61
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from .types import Envelope, EnvelopeStatus, ErrorDetail
|
|
4
|
+
from .errors import TooManyRequestsError, UnauthorizedError
|
|
5
|
+
from . import authentication, biometrics, compliance, email, imss, ine, proof_of_address, renapo, sat
|
|
6
|
+
from .biometrics import MatchFacesRequestDocumentType
|
|
7
|
+
from .client import AsyncOrigoID, OrigoID
|
|
8
|
+
from .compliance import SearchPepsRequest, SearchSat69BRequest, SearchSat69Request
|
|
9
|
+
from .environment import OrigoIDEnvironment
|
|
10
|
+
from .ine import ValidateVoterListRequest
|
|
11
|
+
from .renapo import LookupCurpRequestGender
|
|
12
|
+
from .sat import ExtractCsfRequest, ValidateCfdiRequest
|
|
13
|
+
from .version import __version__
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"AsyncOrigoID",
|
|
17
|
+
"Envelope",
|
|
18
|
+
"EnvelopeStatus",
|
|
19
|
+
"ErrorDetail",
|
|
20
|
+
"ExtractCsfRequest",
|
|
21
|
+
"LookupCurpRequestGender",
|
|
22
|
+
"MatchFacesRequestDocumentType",
|
|
23
|
+
"OrigoID",
|
|
24
|
+
"OrigoIDEnvironment",
|
|
25
|
+
"SearchPepsRequest",
|
|
26
|
+
"SearchSat69BRequest",
|
|
27
|
+
"SearchSat69Request",
|
|
28
|
+
"TooManyRequestsError",
|
|
29
|
+
"UnauthorizedError",
|
|
30
|
+
"ValidateCfdiRequest",
|
|
31
|
+
"ValidateVoterListRequest",
|
|
32
|
+
"__version__",
|
|
33
|
+
"authentication",
|
|
34
|
+
"biometrics",
|
|
35
|
+
"compliance",
|
|
36
|
+
"email",
|
|
37
|
+
"imss",
|
|
38
|
+
"ine",
|
|
39
|
+
"proof_of_address",
|
|
40
|
+
"renapo",
|
|
41
|
+
"sat",
|
|
42
|
+
]
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from ..core.request_options import RequestOptions
|
|
6
|
+
from ..types.envelope import Envelope
|
|
7
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
8
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
9
|
+
from json.decoder import JSONDecodeError
|
|
10
|
+
from ..core.api_error import ApiError
|
|
11
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
12
|
+
|
|
13
|
+
# this is used as the default value for optional parameters
|
|
14
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AuthenticationClient:
|
|
18
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
19
|
+
self._client_wrapper = client_wrapper
|
|
20
|
+
|
|
21
|
+
def issue_token(
|
|
22
|
+
self, *, expire_after: typing.Optional[int] = OMIT, request_options: typing.Optional[RequestOptions] = None
|
|
23
|
+
) -> Envelope:
|
|
24
|
+
"""
|
|
25
|
+
**Credits:** Free — authentication endpoint.
|
|
26
|
+
|
|
27
|
+
Issues a short-lived Bearer JWT token from valid API Key or Basic credentials. The token can then be used as `Authorization: Bearer <token>` on subsequent requests instead of resending your long-lived API Key. Useful when you need to delegate access to a downstream client without sharing your primary credentials.
|
|
28
|
+
|
|
29
|
+
The token's lifetime is returned in the `expires_in` field (seconds). Tokens are stateless — there is no revocation endpoint; if compromised, rotate the underlying API Key instead.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
expire_after : typing.Optional[int]
|
|
34
|
+
Seconds of validity (Default: 1800).
|
|
35
|
+
|
|
36
|
+
request_options : typing.Optional[RequestOptions]
|
|
37
|
+
Request-specific configuration.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
Envelope
|
|
42
|
+
Token generated successfully.
|
|
43
|
+
|
|
44
|
+
Examples
|
|
45
|
+
--------
|
|
46
|
+
from origoid import OrigoID
|
|
47
|
+
|
|
48
|
+
client = OrigoID(
|
|
49
|
+
api_key="YOUR_API_KEY",
|
|
50
|
+
)
|
|
51
|
+
client.authentication.issue_token()
|
|
52
|
+
"""
|
|
53
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
54
|
+
"auth/token",
|
|
55
|
+
method="POST",
|
|
56
|
+
json={
|
|
57
|
+
"expireAfter": expire_after,
|
|
58
|
+
},
|
|
59
|
+
request_options=request_options,
|
|
60
|
+
omit=OMIT,
|
|
61
|
+
)
|
|
62
|
+
try:
|
|
63
|
+
if 200 <= _response.status_code < 300:
|
|
64
|
+
return typing.cast(
|
|
65
|
+
Envelope,
|
|
66
|
+
parse_obj_as(
|
|
67
|
+
type_=Envelope, # type: ignore
|
|
68
|
+
object_=_response.json(),
|
|
69
|
+
),
|
|
70
|
+
)
|
|
71
|
+
if _response.status_code == 401:
|
|
72
|
+
raise UnauthorizedError(
|
|
73
|
+
typing.cast(
|
|
74
|
+
Envelope,
|
|
75
|
+
parse_obj_as(
|
|
76
|
+
type_=Envelope, # type: ignore
|
|
77
|
+
object_=_response.json(),
|
|
78
|
+
),
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
_response_json = _response.json()
|
|
82
|
+
except JSONDecodeError:
|
|
83
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
84
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class AsyncAuthenticationClient:
|
|
88
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
89
|
+
self._client_wrapper = client_wrapper
|
|
90
|
+
|
|
91
|
+
async def issue_token(
|
|
92
|
+
self, *, expire_after: typing.Optional[int] = OMIT, request_options: typing.Optional[RequestOptions] = None
|
|
93
|
+
) -> Envelope:
|
|
94
|
+
"""
|
|
95
|
+
**Credits:** Free — authentication endpoint.
|
|
96
|
+
|
|
97
|
+
Issues a short-lived Bearer JWT token from valid API Key or Basic credentials. The token can then be used as `Authorization: Bearer <token>` on subsequent requests instead of resending your long-lived API Key. Useful when you need to delegate access to a downstream client without sharing your primary credentials.
|
|
98
|
+
|
|
99
|
+
The token's lifetime is returned in the `expires_in` field (seconds). Tokens are stateless — there is no revocation endpoint; if compromised, rotate the underlying API Key instead.
|
|
100
|
+
|
|
101
|
+
Parameters
|
|
102
|
+
----------
|
|
103
|
+
expire_after : typing.Optional[int]
|
|
104
|
+
Seconds of validity (Default: 1800).
|
|
105
|
+
|
|
106
|
+
request_options : typing.Optional[RequestOptions]
|
|
107
|
+
Request-specific configuration.
|
|
108
|
+
|
|
109
|
+
Returns
|
|
110
|
+
-------
|
|
111
|
+
Envelope
|
|
112
|
+
Token generated successfully.
|
|
113
|
+
|
|
114
|
+
Examples
|
|
115
|
+
--------
|
|
116
|
+
import asyncio
|
|
117
|
+
|
|
118
|
+
from origoid import AsyncOrigoID
|
|
119
|
+
|
|
120
|
+
client = AsyncOrigoID(
|
|
121
|
+
api_key="YOUR_API_KEY",
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
async def main() -> None:
|
|
126
|
+
await client.authentication.issue_token()
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
asyncio.run(main())
|
|
130
|
+
"""
|
|
131
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
132
|
+
"auth/token",
|
|
133
|
+
method="POST",
|
|
134
|
+
json={
|
|
135
|
+
"expireAfter": expire_after,
|
|
136
|
+
},
|
|
137
|
+
request_options=request_options,
|
|
138
|
+
omit=OMIT,
|
|
139
|
+
)
|
|
140
|
+
try:
|
|
141
|
+
if 200 <= _response.status_code < 300:
|
|
142
|
+
return typing.cast(
|
|
143
|
+
Envelope,
|
|
144
|
+
parse_obj_as(
|
|
145
|
+
type_=Envelope, # type: ignore
|
|
146
|
+
object_=_response.json(),
|
|
147
|
+
),
|
|
148
|
+
)
|
|
149
|
+
if _response.status_code == 401:
|
|
150
|
+
raise UnauthorizedError(
|
|
151
|
+
typing.cast(
|
|
152
|
+
Envelope,
|
|
153
|
+
parse_obj_as(
|
|
154
|
+
type_=Envelope, # type: ignore
|
|
155
|
+
object_=_response.json(),
|
|
156
|
+
),
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
_response_json = _response.json()
|
|
160
|
+
except JSONDecodeError:
|
|
161
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
162
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|