legalize 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.
- legalize-0.1.0/.gitignore +22 -0
- legalize-0.1.0/CHANGELOG.md +21 -0
- legalize-0.1.0/LICENSE +21 -0
- legalize-0.1.0/PKG-INFO +90 -0
- legalize-0.1.0/README.md +32 -0
- legalize-0.1.0/pyproject.toml +136 -0
- legalize-0.1.0/src/legalize/__init__.py +63 -0
- legalize-0.1.0/src/legalize/_client.py +493 -0
- legalize-0.1.0/src/legalize/_errors.py +295 -0
- legalize-0.1.0/src/legalize/_pagination.py +212 -0
- legalize-0.1.0/src/legalize/_retry.py +107 -0
- legalize-0.1.0/src/legalize/_version.py +1 -0
- legalize-0.1.0/src/legalize/models/__init__.py +48 -0
- legalize-0.1.0/src/legalize/models/_generated.py +165 -0
- legalize-0.1.0/src/legalize/py.typed +0 -0
- legalize-0.1.0/src/legalize/resources/__init__.py +1 -0
- legalize-0.1.0/src/legalize/resources/_base.py +33 -0
- legalize-0.1.0/src/legalize/resources/countries.py +22 -0
- legalize-0.1.0/src/legalize/resources/jurisdictions.py +22 -0
- legalize-0.1.0/src/legalize/resources/law_types.py +20 -0
- legalize-0.1.0/src/legalize/resources/laws.py +288 -0
- legalize-0.1.0/src/legalize/resources/reforms.py +77 -0
- legalize-0.1.0/src/legalize/resources/stats.py +25 -0
- legalize-0.1.0/src/legalize/resources/webhooks.py +197 -0
- legalize-0.1.0/src/legalize/webhooks.py +194 -0
- legalize-0.1.0/tests/cassettes/README.md +32 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
.mypy_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
.coverage
|
|
8
|
+
coverage.xml
|
|
9
|
+
htmlcov/
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
.venv/
|
|
13
|
+
venv/
|
|
14
|
+
.tox/
|
|
15
|
+
.python-version
|
|
16
|
+
.DS_Store
|
|
17
|
+
*.swp
|
|
18
|
+
.env
|
|
19
|
+
.env.local
|
|
20
|
+
apikey
|
|
21
|
+
.claude/
|
|
22
|
+
apikeypypi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the Python SDK will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial release of the Python SDK.
|
|
13
|
+
- Sync (`Legalize`) and async (`AsyncLegalize`) clients covering every
|
|
14
|
+
public `/api/v1/*` endpoint.
|
|
15
|
+
- Typed Pydantic models generated from the OpenAPI spec.
|
|
16
|
+
- `Webhook.verify` for HMAC-SHA256 signature verification with
|
|
17
|
+
replay protection.
|
|
18
|
+
- Retry with exponential backoff + jitter, respecting `Retry-After`.
|
|
19
|
+
- Auto-paginating iterators for laws and reforms.
|
|
20
|
+
- Typed error hierarchy (`APIError`, `AuthenticationError`,
|
|
21
|
+
`RateLimitError`, etc.).
|
legalize-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Legalize
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
legalize-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: legalize
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python client for the Legalize API
|
|
5
|
+
Project-URL: Homepage, https://legalize.dev
|
|
6
|
+
Project-URL: Documentation, https://legalize.dev/api/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/legalize-dev/legalize-sdks
|
|
8
|
+
Project-URL: Issues, https://github.com/legalize-dev/legalize-sdks/issues
|
|
9
|
+
Author-email: Legalize <dev@legalize.dev>
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 Legalize
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: api,laws,legal,legalize,sdk
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
41
|
+
Classifier: Typing :: Typed
|
|
42
|
+
Requires-Python: >=3.10
|
|
43
|
+
Requires-Dist: httpx>=0.27
|
|
44
|
+
Requires-Dist: pydantic>=2.6
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: bandit>=1.7; extra == 'dev'
|
|
47
|
+
Requires-Dist: datamodel-code-generator>=0.26; extra == 'dev'
|
|
48
|
+
Requires-Dist: hypothesis>=6.100; extra == 'dev'
|
|
49
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
50
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
51
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
52
|
+
Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
|
|
53
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
54
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
55
|
+
Requires-Dist: schemathesis>=3.30; extra == 'dev'
|
|
56
|
+
Requires-Dist: vcrpy>=6; extra == 'dev'
|
|
57
|
+
Description-Content-Type: text/markdown
|
|
58
|
+
|
|
59
|
+
# legalize
|
|
60
|
+
|
|
61
|
+
[](https://github.com/legalize-dev/legalize-sdks/actions/workflows/python-ci.yml)
|
|
62
|
+
[](https://pypi.org/project/legalize/)
|
|
63
|
+
[](https://pypi.org/project/legalize/)
|
|
64
|
+
|
|
65
|
+
Official Python client for the [Legalize API](https://legalize.dev/api).
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install legalize
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from legalize import Legalize
|
|
73
|
+
|
|
74
|
+
client = Legalize(api_key="leg_...")
|
|
75
|
+
|
|
76
|
+
for law in client.laws.list(country="es", law_type="ley_organica"):
|
|
77
|
+
print(law.id, law.title)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
See the [monorepo README](../README.md) for the full SDK design and
|
|
81
|
+
language matrix.
|
|
82
|
+
|
|
83
|
+
## Development
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
python -m venv .venv
|
|
87
|
+
source .venv/bin/activate
|
|
88
|
+
pip install -e ".[dev]"
|
|
89
|
+
pytest
|
|
90
|
+
```
|
legalize-0.1.0/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# legalize
|
|
2
|
+
|
|
3
|
+
[](https://github.com/legalize-dev/legalize-sdks/actions/workflows/python-ci.yml)
|
|
4
|
+
[](https://pypi.org/project/legalize/)
|
|
5
|
+
[](https://pypi.org/project/legalize/)
|
|
6
|
+
|
|
7
|
+
Official Python client for the [Legalize API](https://legalize.dev/api).
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install legalize
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from legalize import Legalize
|
|
15
|
+
|
|
16
|
+
client = Legalize(api_key="leg_...")
|
|
17
|
+
|
|
18
|
+
for law in client.laws.list(country="es", law_type="ley_organica"):
|
|
19
|
+
print(law.id, law.title)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
See the [monorepo README](../README.md) for the full SDK design and
|
|
23
|
+
language matrix.
|
|
24
|
+
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
python -m venv .venv
|
|
29
|
+
source .venv/bin/activate
|
|
30
|
+
pip install -e ".[dev]"
|
|
31
|
+
pytest
|
|
32
|
+
```
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "legalize"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python client for the Legalize API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "Legalize", email = "dev@legalize.dev" }]
|
|
13
|
+
keywords = ["legalize", "legal", "laws", "api", "sdk"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Typing :: Typed",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"httpx>=0.27",
|
|
27
|
+
"pydantic>=2.6",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
dev = [
|
|
32
|
+
"pytest>=8",
|
|
33
|
+
"pytest-asyncio>=0.23",
|
|
34
|
+
"pytest-cov>=5",
|
|
35
|
+
"pytest-httpx>=0.30",
|
|
36
|
+
"hypothesis>=6.100",
|
|
37
|
+
"vcrpy>=6",
|
|
38
|
+
"schemathesis>=3.30",
|
|
39
|
+
"ruff>=0.6",
|
|
40
|
+
"mypy>=1.11",
|
|
41
|
+
"datamodel-code-generator>=0.26",
|
|
42
|
+
"bandit>=1.7",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://legalize.dev"
|
|
47
|
+
Documentation = "https://legalize.dev/api/docs"
|
|
48
|
+
Repository = "https://github.com/legalize-dev/legalize-sdks"
|
|
49
|
+
Issues = "https://github.com/legalize-dev/legalize-sdks/issues"
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.wheel]
|
|
52
|
+
packages = ["src/legalize"]
|
|
53
|
+
|
|
54
|
+
[tool.hatch.build.targets.sdist]
|
|
55
|
+
include = ["src/legalize", "README.md", "LICENSE", "CHANGELOG.md"]
|
|
56
|
+
|
|
57
|
+
[tool.ruff]
|
|
58
|
+
line-length = 100
|
|
59
|
+
target-version = "py310"
|
|
60
|
+
src = ["src", "tests"]
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = [
|
|
64
|
+
"E", "F", "W", # pycodestyle + pyflakes
|
|
65
|
+
"I", # isort
|
|
66
|
+
"B", # bugbear
|
|
67
|
+
"UP", # pyupgrade
|
|
68
|
+
"N", # pep8-naming
|
|
69
|
+
"S", # bandit
|
|
70
|
+
"RUF", # ruff rules
|
|
71
|
+
]
|
|
72
|
+
ignore = [
|
|
73
|
+
"S101", # assert in tests
|
|
74
|
+
"E501", # line length handled by formatter
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint.per-file-ignores]
|
|
78
|
+
"tests/**" = ["S105", "S106", "S311"]
|
|
79
|
+
"examples/**" = ["S105", "S106", "T201"]
|
|
80
|
+
"src/legalize/models/**" = ["N815", "UP"] # generated code
|
|
81
|
+
|
|
82
|
+
[tool.ruff.format]
|
|
83
|
+
quote-style = "double"
|
|
84
|
+
indent-style = "space"
|
|
85
|
+
|
|
86
|
+
[tool.mypy]
|
|
87
|
+
python_version = "3.10"
|
|
88
|
+
strict = true
|
|
89
|
+
warn_unreachable = true
|
|
90
|
+
warn_unused_ignores = true
|
|
91
|
+
show_error_codes = true
|
|
92
|
+
exclude = ["tests/", "examples/", "src/legalize/models/"]
|
|
93
|
+
|
|
94
|
+
[[tool.mypy.overrides]]
|
|
95
|
+
module = "legalize.models.*"
|
|
96
|
+
ignore_errors = true
|
|
97
|
+
|
|
98
|
+
[tool.pytest.ini_options]
|
|
99
|
+
minversion = "8.0"
|
|
100
|
+
testpaths = ["tests"]
|
|
101
|
+
asyncio_mode = "auto"
|
|
102
|
+
addopts = [
|
|
103
|
+
"-ra",
|
|
104
|
+
"--strict-markers",
|
|
105
|
+
"--strict-config",
|
|
106
|
+
]
|
|
107
|
+
markers = [
|
|
108
|
+
"unit: fast unit tests with mocked HTTP",
|
|
109
|
+
"webhooks: webhook signature vectors",
|
|
110
|
+
"property: Hypothesis property-based tests",
|
|
111
|
+
"contract: schemathesis contract tests",
|
|
112
|
+
"vcr: VCR-replayed tests against recorded cassettes",
|
|
113
|
+
"integration: tests against a live staging API",
|
|
114
|
+
]
|
|
115
|
+
filterwarnings = [
|
|
116
|
+
"error",
|
|
117
|
+
"ignore::DeprecationWarning:vcr",
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
[tool.coverage.run]
|
|
121
|
+
source = ["src/legalize"]
|
|
122
|
+
branch = true
|
|
123
|
+
omit = [
|
|
124
|
+
"src/legalize/models/*",
|
|
125
|
+
"*/__init__.py",
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
[tool.coverage.report]
|
|
129
|
+
exclude_lines = [
|
|
130
|
+
"pragma: no cover",
|
|
131
|
+
"raise NotImplementedError",
|
|
132
|
+
"if TYPE_CHECKING:",
|
|
133
|
+
"if __name__ == .__main__.:",
|
|
134
|
+
]
|
|
135
|
+
fail_under = 95
|
|
136
|
+
show_missing = true
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Legalize — official Python client for the Legalize API.
|
|
2
|
+
|
|
3
|
+
Typical usage::
|
|
4
|
+
|
|
5
|
+
from legalize import Legalize
|
|
6
|
+
|
|
7
|
+
client = Legalize(api_key="leg_...")
|
|
8
|
+
for law in client.laws.iter(country="es"):
|
|
9
|
+
print(law.id, law.title)
|
|
10
|
+
|
|
11
|
+
See https://legalize.dev/api for the API reference.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from legalize._client import (
|
|
15
|
+
DEFAULT_API_VERSION,
|
|
16
|
+
DEFAULT_BASE_URL,
|
|
17
|
+
DEFAULT_TIMEOUT,
|
|
18
|
+
AsyncLegalize,
|
|
19
|
+
Legalize,
|
|
20
|
+
)
|
|
21
|
+
from legalize._errors import (
|
|
22
|
+
APIConnectionError,
|
|
23
|
+
APIError,
|
|
24
|
+
APITimeoutError,
|
|
25
|
+
AuthenticationError,
|
|
26
|
+
ForbiddenError,
|
|
27
|
+
InvalidRequestError,
|
|
28
|
+
LegalizeError,
|
|
29
|
+
NotFoundError,
|
|
30
|
+
RateLimitError,
|
|
31
|
+
ServerError,
|
|
32
|
+
ServiceUnavailableError,
|
|
33
|
+
ValidationError,
|
|
34
|
+
WebhookVerificationError,
|
|
35
|
+
)
|
|
36
|
+
from legalize._retry import RetryPolicy
|
|
37
|
+
from legalize._version import __version__
|
|
38
|
+
from legalize.webhooks import Webhook, WebhookEvent
|
|
39
|
+
|
|
40
|
+
__all__ = [
|
|
41
|
+
"DEFAULT_API_VERSION",
|
|
42
|
+
"DEFAULT_BASE_URL",
|
|
43
|
+
"DEFAULT_TIMEOUT",
|
|
44
|
+
"APIConnectionError",
|
|
45
|
+
"APIError",
|
|
46
|
+
"APITimeoutError",
|
|
47
|
+
"AsyncLegalize",
|
|
48
|
+
"AuthenticationError",
|
|
49
|
+
"ForbiddenError",
|
|
50
|
+
"InvalidRequestError",
|
|
51
|
+
"Legalize",
|
|
52
|
+
"LegalizeError",
|
|
53
|
+
"NotFoundError",
|
|
54
|
+
"RateLimitError",
|
|
55
|
+
"RetryPolicy",
|
|
56
|
+
"ServerError",
|
|
57
|
+
"ServiceUnavailableError",
|
|
58
|
+
"ValidationError",
|
|
59
|
+
"Webhook",
|
|
60
|
+
"WebhookEvent",
|
|
61
|
+
"WebhookVerificationError",
|
|
62
|
+
"__version__",
|
|
63
|
+
]
|