wexample-api 6.8.2__tar.gz → 6.8.4__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.
Files changed (31) hide show
  1. wexample_api-6.8.4/PKG-INFO +277 -0
  2. wexample_api-6.8.4/README.md +256 -0
  3. {wexample_api-6.8.2 → wexample_api-6.8.4}/pyproject.toml +4 -4
  4. wexample_api-6.8.2/tests/common/__init__.py → wexample_api-6.8.4/tests/.gitkeep +0 -0
  5. wexample_api-6.8.4/tests/new_architecture/__init__.py +0 -0
  6. wexample_api-6.8.2/PKG-INFO +0 -326
  7. wexample_api-6.8.2/README.md +0 -305
  8. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/__init__.py +0 -0
  9. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/__pycache__/__init__.py +0 -0
  10. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/common/__init__.py +0 -0
  11. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/common/__pycache__/__init__.py +0 -0
  12. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/common/abstract_gateway.py +0 -0
  13. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/common/http_request_payload.py +0 -0
  14. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/const/__init__.py +0 -0
  15. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/const/__pycache__/__init__.py +0 -0
  16. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/const/http.py +0 -0
  17. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/demo/__init__.py +0 -0
  18. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/demo/demo_simple_gateway.py +0 -0
  19. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/enums/__init__.py +0 -0
  20. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/enums/__pycache__/__init__.py +0 -0
  21. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/enums/http.py +0 -0
  22. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/errors/__init__.py +0 -0
  23. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/errors/gateway_authentication_error.py +0 -0
  24. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/errors/gateway_connexion_error.py +0 -0
  25. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/middleware/__init__.py +0 -0
  26. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/models/__init__.py +0 -0
  27. {wexample_api-6.8.2 → wexample_api-6.8.4}/src/wexample_api/py.typed +0 -0
  28. {wexample_api-6.8.2/tests/demo → wexample_api-6.8.4/tests/common}/__init__.py +0 -0
  29. {wexample_api-6.8.2 → wexample_api-6.8.4}/tests/common/test_http_request_payload.py +0 -0
  30. {wexample_api-6.8.2/tests/new_architecture → wexample_api-6.8.4/tests/demo}/__init__.py +0 -0
  31. {wexample_api-6.8.2 → wexample_api-6.8.4}/tests/demo/test_demo_simple_gateway.py +0 -0
@@ -0,0 +1,277 @@
1
+ Metadata-Version: 2.1
2
+ Name: wexample-api
3
+ Version: 6.8.4
4
+ Summary: Provides an AbstractGateway base class that handles HTTP requests with rate limiting, status-code validation, retry logic, and structured error reporting for building typed API client gateways
5
+ Author-Email: weeger <contact@wexample.com>
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Project-URL: homepage, https://github.com/wexample/python-api
11
+ Requires-Python: >=3.10
12
+ Requires-Dist: attrs>=23.1.0
13
+ Requires-Dist: cattrs>=23.1.0
14
+ Requires-Dist: requests
15
+ Requires-Dist: wexample-helpers>=20.0.0
16
+ Requires-Dist: wexample-prompt>=15.0.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest; extra == "dev"
19
+ Requires-Dist: pytest-cov; extra == "dev"
20
+ Description-Content-Type: text/markdown
21
+
22
+ # api
23
+
24
+ Version: 6.8.4
25
+
26
+ `wexample-api` provides an `AbstractGateway` base class for building typed HTTP API client gateways in Python. It wraps `requests` with built-in rate limiting, configurable timeout, status-code validation, exponential-backoff retries, and structured error reporting via `wexample-prompt`, so a concrete gateway only needs to declare a `base_url` and call `make_request`. The package targets Python developers who integrate third-party REST APIs and want to centralise connection handling, logging, and error propagation without writing the same boilerplate for each service.
27
+
28
+ ## Table of Contents
29
+
30
+ - [Installation](#installation)
31
+ - [Quickstart](#quickstart)
32
+ - [Tests](#tests)
33
+ - [Architecture](#architecture)
34
+ - [Integration in the Suite](#integration-in-the-suite)
35
+ - [Dependencies](#dependencies)
36
+ - [Versioning & Compatibility Policy](#versioning--compatibility-policy)
37
+ - [License](#license)
38
+ - [About us](#about-us)
39
+ - [Known Limitations & Roadmap](#known-limitations--roadmap)
40
+ - [Status & Compatibility](#status--compatibility)
41
+ - [Useful Links](#useful-links)
42
+ - [Migration Notes](#migration-notes)
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pip install wexample-api
48
+ ```
49
+
50
+ Requires Python >=3.10.
51
+
52
+ ## Quickstart
53
+
54
+ Install the package:
55
+
56
+ ```bash
57
+ pip install wexample-api
58
+ ```
59
+
60
+ Subclass `AbstractGateway`, pass `base_url` and an `IoManager`, then call `make_request`:
61
+
62
+ ```python
63
+ from wexample_api.common.abstract_gateway import AbstractGateway
64
+ from wexample_api.enums.http import HttpMethod
65
+ from wexample_helpers.decorator.base_class import base_class
66
+ from wexample_prompt.common.io_manager import IoManager
67
+
68
+ @base_class
69
+ class JsonPlaceholderGateway(AbstractGateway):
70
+ def get_post(self, post_id: int) -> dict | None:
71
+ response = self.make_request(
72
+ endpoint=f"/posts/{post_id}",
73
+ method=HttpMethod.GET,
74
+ expected_status_codes=200,
75
+ )
76
+ return response.json() if response else None
77
+
78
+ gateway = JsonPlaceholderGateway(
79
+ base_url="https://jsonplaceholder.typicode.com",
80
+ io=IoManager(),
81
+ )
82
+
83
+ post = gateway.get_post(1)
84
+ print(post["title"])
85
+ # sunt aut facere repellat provident occaecati excepturi optio reprehenderit
86
+ ```
87
+
88
+ `make_request` returns the raw `requests.Response` when the actual status code is in `expected_status_codes`, or `None` when it is not. Omitting `expected_status_codes` accepts any response. The `@base_class` decorator is required: `AbstractGateway` uses `wexample_helpers` field initialisation that depends on it.
89
+
90
+ A runnable, annotated version of this example lives at examples/common/http_request_example.py.
91
+
92
+ ## Tests
93
+
94
+ This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
95
+
96
+ ### Installation
97
+
98
+ First, install the required testing dependencies:
99
+ ```bash
100
+ .venv/bin/python -m pip install pytest pytest-cov
101
+ ```
102
+
103
+ ### Basic Usage
104
+
105
+ Run all tests with coverage:
106
+ ```bash
107
+ .venv/bin/python -m pytest --cov --cov-report=html
108
+ ```
109
+
110
+ ### Common Commands
111
+ ```bash
112
+ # Run tests with coverage for a specific module
113
+ .venv/bin/python -m pytest --cov=your_module
114
+
115
+ # Show which lines are not covered
116
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
117
+
118
+ # Generate an HTML coverage report
119
+ .venv/bin/python -m pytest --cov=your_module --cov-report=html
120
+
121
+ # Combine terminal and HTML reports
122
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
123
+
124
+ # Run specific test file with coverage
125
+ .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
126
+ ```
127
+
128
+ ### Viewing HTML Reports
129
+
130
+ After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
131
+
132
+ ### Coverage Threshold
133
+
134
+ To enforce a minimum coverage percentage:
135
+ ```bash
136
+ .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
137
+ ```
138
+
139
+ This will cause the test suite to fail if coverage drops below 80%.
140
+
141
+ ## Architecture
142
+
143
+ `wexample-api` ships one thing: `AbstractGateway`, a base class callers subclass to build typed HTTP clients. The rest of the package feeds that class — enums for the HTTP vocabulary, a payload dataclass that carries each request's parameters, two error types for the failure modes gateways commonly signal, and a demo subclass that shows the pattern in use.
144
+
145
+ ### Modules
146
+
147
+ | File | Owns |
148
+ |------|------|
149
+ | src/wexample_api/common/abstract_gateway.py | `AbstractGateway` — the only class callers subclass |
150
+ | src/wexample_api/common/http_request_payload.py | `HttpRequestPayload` — value object assembled for each call |
151
+ | src/wexample_api/enums/http.py | `HttpMethod`, `ContentType`, `Header` enums |
152
+ | src/wexample_api/const/http.py | `HTTP_METHOD_MAP` — string-to-`HttpMethod` lookup |
153
+ | src/wexample_api/errors/gateway_connexion_error.py | `GatewayConnectionError` |
154
+ | src/wexample_api/errors/gateway_authentication_error.py | `GatewayAuthenticationError` |
155
+ | src/wexample_api/demo/demo_simple_gateway.py | `DemoSimpleGateway` — concrete subclass used in tests |
156
+
157
+ `src/wexample_api/middleware/` and `src/wexample_api/models/` are currently empty; they are stubs reserved for a planned rework documented in `.wex/journal/todo/abstract-gateway-rework.md`.
158
+
159
+ ### AbstractGateway
160
+
161
+ `AbstractGateway` inherits three mixins from `wexample-helpers` and `wexample-prompt`:
162
+
163
+ - `WithIoManager` — exposes `self.io` for structured terminal output (`debug`, `error`, `properties`)
164
+ - `HasTwoStepInit` — two-phase initialisation; `setup()` is the second phase
165
+ - `HasSnakeShortClassNameClassMixin` — `get_class_name_suffix` strips `"GatewayService"` from derived class names
166
+
167
+ Its public fields control the request lifecycle:
168
+
169
+ - `base_url` — prepended to every endpoint
170
+ - `default_headers` — merged into every call's header dict
171
+ - `connected` / `rate_limit_delay` / `timeout` — connection and throttle configuration
172
+ - `quiet` — suppresses non-error log lines when `True`
173
+ - `last_exception` / `last_request_time` — per-instance mutable state written after each call
174
+
175
+ Concrete subclasses declare domain methods (e.g. `get_user`, `create_item`) and delegate to `self.make_request`.
176
+
177
+ ### HttpRequestPayload
178
+
179
+ `HttpRequestPayload` is the internal transfer object for one HTTP call. `make_request` constructs it with `HttpRequestPayload.from_endpoint()`, which joins `base_url` and `endpoint` (stripping duplicate slashes) and coerces a bare `int` in `expected_status_codes` to a one-element list. The payload object then travels into `handle_api_response`, where it provides the URL, method, data, and `call_origin` for log lines and error details.
180
+
181
+ ### Call path through make_request
182
+
183
+ 1. **Retry wrapper.** If `retries > 0`, the call is handed to `RetryableCallbackManager` from `wexample-helpers`, which re-invokes `make_request` with `raise_exceptions=True` and exponential back-off (`backoff_base_seconds=3`), retrying only on `GatewayError`.
184
+
185
+ 2. **Payload assembly.** `HttpRequestPayload.from_endpoint()` constructs the full URL and normalises the status-code argument.
186
+
187
+ 3. **Connection.** If `self.connected` is `False`, `connect()` is called; the base implementation sets the flag and returns `True`. Subclasses override this to perform real handshakes.
188
+
189
+ 4. **Rate limiting.** `_handle_rate_limiting()` sleeps as needed so that consecutive calls are at least `rate_limit_delay` seconds apart.
190
+
191
+ 5. **Body dispatch.** The content type of the merged headers determines how the body travels: `files=` for multipart, `data=` for `application/x-www-form-urlencoded`, `application/octet-stream`, and `text/plain`, `json=` for everything else (including when no `Content-Type` is set).
192
+
193
+ 6. **HTTP call.** `requests.request(**request_kwargs)` executes the call. On `RequestException`, a `GatewayError` is created, stored in `last_exception`, and passed to `handle_api_response` with `response=None`; if `raise_exceptions=True` the error is raised instead.
194
+
195
+ 7. **Status validation.** If `expected_status_codes` was supplied and the response status is not in the set, a `GatewayError` is created (and raised immediately when `raise_exceptions=True`).
196
+
197
+ 8. **Response handling.** `handle_api_response` logs the outcome via `self.io` and returns the `requests.Response` object, or `None` when the call failed and `fatal_on_error` is `False`. When `fatal_on_error` is `True`, it calls `self.io.error(..., fatal=True)`, which terminates the process.
198
+
199
+ ### Errors
200
+
201
+ Both `GatewayConnectionError` and `GatewayAuthenticationError` subclass `GatewayError` from `wexample-helpers`. `AbstractGateway.make_request` itself raises only `GatewayError`; the two subclasses are available for concrete gateways that need callers to distinguish the failure mode.
202
+
203
+ ### External dependencies
204
+
205
+ `AbstractGateway` calls `requests.request` directly — the `requests` library is the only HTTP transport. `wexample-prompt` supplies `IoManager` for all output. `wexample-helpers` supplies `RetryableCallbackManager`, `GatewayError`, and the class infrastructure (`base_class` decorator, `public_field`, `HasTwoStepInit`).
206
+
207
+ ## Integration in the Suite
208
+
209
+ This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
210
+
211
+ ### Related Packages
212
+
213
+ The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
214
+
215
+ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
216
+
217
+ ## Dependencies
218
+
219
+ - attrs: >=23.1.0
220
+ - cattrs: >=23.1.0
221
+ - requests:
222
+ - wexample-helpers: >=20.0.0
223
+ - wexample-prompt: >=15.0.0
224
+
225
+ ## Versioning & Compatibility Policy
226
+
227
+ Wexample packages follow **Semantic Versioning** (SemVer):
228
+
229
+ - **MAJOR**: Breaking changes
230
+ - **MINOR**: New features, backward compatible
231
+ - **PATCH**: Bug fixes, backward compatible
232
+
233
+ We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
234
+
235
+ ## License
236
+
237
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
238
+
239
+ Free to use in both personal and commercial projects.
240
+
241
+ ## About us
242
+
243
+ [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
244
+
245
+ This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
246
+
247
+ Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
248
+
249
+ ## Known Limitations & Roadmap
250
+
251
+ Current limitations and planned features are tracked in the GitHub issues.
252
+
253
+ See the [project roadmap](https://github.com/wexample/python-api/issues) for upcoming features and improvements.
254
+
255
+ ## Status & Compatibility
256
+
257
+ **Maturity**: Production-ready
258
+
259
+ **Python Support**: >=3.10
260
+
261
+ **OS Support**: Linux, macOS, Windows
262
+
263
+ **Status**: Actively maintained
264
+
265
+ ## Useful Links
266
+
267
+ - **Homepage**: https://github.com/wexample/python-api
268
+ - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
269
+ - **Issue Tracker**: https://github.com/wexample/python-api/issues
270
+ - **Discussions**: https://github.com/wexample/python-api/discussions
271
+ - **PyPI**: [pypi.org/project/wexample-api](https://pypi.org/project/wexample-api/)
272
+
273
+ ## Migration Notes
274
+
275
+ When upgrading between major versions, refer to the migration guides in the documentation.
276
+
277
+ Breaking changes are clearly documented with upgrade paths and examples.
@@ -0,0 +1,256 @@
1
+ # api
2
+
3
+ Version: 6.8.4
4
+
5
+ `wexample-api` provides an `AbstractGateway` base class for building typed HTTP API client gateways in Python. It wraps `requests` with built-in rate limiting, configurable timeout, status-code validation, exponential-backoff retries, and structured error reporting via `wexample-prompt`, so a concrete gateway only needs to declare a `base_url` and call `make_request`. The package targets Python developers who integrate third-party REST APIs and want to centralise connection handling, logging, and error propagation without writing the same boilerplate for each service.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Quickstart](#quickstart)
11
+ - [Tests](#tests)
12
+ - [Architecture](#architecture)
13
+ - [Integration in the Suite](#integration-in-the-suite)
14
+ - [Dependencies](#dependencies)
15
+ - [Versioning & Compatibility Policy](#versioning--compatibility-policy)
16
+ - [License](#license)
17
+ - [About us](#about-us)
18
+ - [Known Limitations & Roadmap](#known-limitations--roadmap)
19
+ - [Status & Compatibility](#status--compatibility)
20
+ - [Useful Links](#useful-links)
21
+ - [Migration Notes](#migration-notes)
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pip install wexample-api
27
+ ```
28
+
29
+ Requires Python >=3.10.
30
+
31
+ ## Quickstart
32
+
33
+ Install the package:
34
+
35
+ ```bash
36
+ pip install wexample-api
37
+ ```
38
+
39
+ Subclass `AbstractGateway`, pass `base_url` and an `IoManager`, then call `make_request`:
40
+
41
+ ```python
42
+ from wexample_api.common.abstract_gateway import AbstractGateway
43
+ from wexample_api.enums.http import HttpMethod
44
+ from wexample_helpers.decorator.base_class import base_class
45
+ from wexample_prompt.common.io_manager import IoManager
46
+
47
+ @base_class
48
+ class JsonPlaceholderGateway(AbstractGateway):
49
+ def get_post(self, post_id: int) -> dict | None:
50
+ response = self.make_request(
51
+ endpoint=f"/posts/{post_id}",
52
+ method=HttpMethod.GET,
53
+ expected_status_codes=200,
54
+ )
55
+ return response.json() if response else None
56
+
57
+ gateway = JsonPlaceholderGateway(
58
+ base_url="https://jsonplaceholder.typicode.com",
59
+ io=IoManager(),
60
+ )
61
+
62
+ post = gateway.get_post(1)
63
+ print(post["title"])
64
+ # sunt aut facere repellat provident occaecati excepturi optio reprehenderit
65
+ ```
66
+
67
+ `make_request` returns the raw `requests.Response` when the actual status code is in `expected_status_codes`, or `None` when it is not. Omitting `expected_status_codes` accepts any response. The `@base_class` decorator is required: `AbstractGateway` uses `wexample_helpers` field initialisation that depends on it.
68
+
69
+ A runnable, annotated version of this example lives at examples/common/http_request_example.py.
70
+
71
+ ## Tests
72
+
73
+ This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
74
+
75
+ ### Installation
76
+
77
+ First, install the required testing dependencies:
78
+ ```bash
79
+ .venv/bin/python -m pip install pytest pytest-cov
80
+ ```
81
+
82
+ ### Basic Usage
83
+
84
+ Run all tests with coverage:
85
+ ```bash
86
+ .venv/bin/python -m pytest --cov --cov-report=html
87
+ ```
88
+
89
+ ### Common Commands
90
+ ```bash
91
+ # Run tests with coverage for a specific module
92
+ .venv/bin/python -m pytest --cov=your_module
93
+
94
+ # Show which lines are not covered
95
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
96
+
97
+ # Generate an HTML coverage report
98
+ .venv/bin/python -m pytest --cov=your_module --cov-report=html
99
+
100
+ # Combine terminal and HTML reports
101
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
102
+
103
+ # Run specific test file with coverage
104
+ .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
105
+ ```
106
+
107
+ ### Viewing HTML Reports
108
+
109
+ After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
110
+
111
+ ### Coverage Threshold
112
+
113
+ To enforce a minimum coverage percentage:
114
+ ```bash
115
+ .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
116
+ ```
117
+
118
+ This will cause the test suite to fail if coverage drops below 80%.
119
+
120
+ ## Architecture
121
+
122
+ `wexample-api` ships one thing: `AbstractGateway`, a base class callers subclass to build typed HTTP clients. The rest of the package feeds that class — enums for the HTTP vocabulary, a payload dataclass that carries each request's parameters, two error types for the failure modes gateways commonly signal, and a demo subclass that shows the pattern in use.
123
+
124
+ ### Modules
125
+
126
+ | File | Owns |
127
+ |------|------|
128
+ | src/wexample_api/common/abstract_gateway.py | `AbstractGateway` — the only class callers subclass |
129
+ | src/wexample_api/common/http_request_payload.py | `HttpRequestPayload` — value object assembled for each call |
130
+ | src/wexample_api/enums/http.py | `HttpMethod`, `ContentType`, `Header` enums |
131
+ | src/wexample_api/const/http.py | `HTTP_METHOD_MAP` — string-to-`HttpMethod` lookup |
132
+ | src/wexample_api/errors/gateway_connexion_error.py | `GatewayConnectionError` |
133
+ | src/wexample_api/errors/gateway_authentication_error.py | `GatewayAuthenticationError` |
134
+ | src/wexample_api/demo/demo_simple_gateway.py | `DemoSimpleGateway` — concrete subclass used in tests |
135
+
136
+ `src/wexample_api/middleware/` and `src/wexample_api/models/` are currently empty; they are stubs reserved for a planned rework documented in `.wex/journal/todo/abstract-gateway-rework.md`.
137
+
138
+ ### AbstractGateway
139
+
140
+ `AbstractGateway` inherits three mixins from `wexample-helpers` and `wexample-prompt`:
141
+
142
+ - `WithIoManager` — exposes `self.io` for structured terminal output (`debug`, `error`, `properties`)
143
+ - `HasTwoStepInit` — two-phase initialisation; `setup()` is the second phase
144
+ - `HasSnakeShortClassNameClassMixin` — `get_class_name_suffix` strips `"GatewayService"` from derived class names
145
+
146
+ Its public fields control the request lifecycle:
147
+
148
+ - `base_url` — prepended to every endpoint
149
+ - `default_headers` — merged into every call's header dict
150
+ - `connected` / `rate_limit_delay` / `timeout` — connection and throttle configuration
151
+ - `quiet` — suppresses non-error log lines when `True`
152
+ - `last_exception` / `last_request_time` — per-instance mutable state written after each call
153
+
154
+ Concrete subclasses declare domain methods (e.g. `get_user`, `create_item`) and delegate to `self.make_request`.
155
+
156
+ ### HttpRequestPayload
157
+
158
+ `HttpRequestPayload` is the internal transfer object for one HTTP call. `make_request` constructs it with `HttpRequestPayload.from_endpoint()`, which joins `base_url` and `endpoint` (stripping duplicate slashes) and coerces a bare `int` in `expected_status_codes` to a one-element list. The payload object then travels into `handle_api_response`, where it provides the URL, method, data, and `call_origin` for log lines and error details.
159
+
160
+ ### Call path through make_request
161
+
162
+ 1. **Retry wrapper.** If `retries > 0`, the call is handed to `RetryableCallbackManager` from `wexample-helpers`, which re-invokes `make_request` with `raise_exceptions=True` and exponential back-off (`backoff_base_seconds=3`), retrying only on `GatewayError`.
163
+
164
+ 2. **Payload assembly.** `HttpRequestPayload.from_endpoint()` constructs the full URL and normalises the status-code argument.
165
+
166
+ 3. **Connection.** If `self.connected` is `False`, `connect()` is called; the base implementation sets the flag and returns `True`. Subclasses override this to perform real handshakes.
167
+
168
+ 4. **Rate limiting.** `_handle_rate_limiting()` sleeps as needed so that consecutive calls are at least `rate_limit_delay` seconds apart.
169
+
170
+ 5. **Body dispatch.** The content type of the merged headers determines how the body travels: `files=` for multipart, `data=` for `application/x-www-form-urlencoded`, `application/octet-stream`, and `text/plain`, `json=` for everything else (including when no `Content-Type` is set).
171
+
172
+ 6. **HTTP call.** `requests.request(**request_kwargs)` executes the call. On `RequestException`, a `GatewayError` is created, stored in `last_exception`, and passed to `handle_api_response` with `response=None`; if `raise_exceptions=True` the error is raised instead.
173
+
174
+ 7. **Status validation.** If `expected_status_codes` was supplied and the response status is not in the set, a `GatewayError` is created (and raised immediately when `raise_exceptions=True`).
175
+
176
+ 8. **Response handling.** `handle_api_response` logs the outcome via `self.io` and returns the `requests.Response` object, or `None` when the call failed and `fatal_on_error` is `False`. When `fatal_on_error` is `True`, it calls `self.io.error(..., fatal=True)`, which terminates the process.
177
+
178
+ ### Errors
179
+
180
+ Both `GatewayConnectionError` and `GatewayAuthenticationError` subclass `GatewayError` from `wexample-helpers`. `AbstractGateway.make_request` itself raises only `GatewayError`; the two subclasses are available for concrete gateways that need callers to distinguish the failure mode.
181
+
182
+ ### External dependencies
183
+
184
+ `AbstractGateway` calls `requests.request` directly — the `requests` library is the only HTTP transport. `wexample-prompt` supplies `IoManager` for all output. `wexample-helpers` supplies `RetryableCallbackManager`, `GatewayError`, and the class infrastructure (`base_class` decorator, `public_field`, `HasTwoStepInit`).
185
+
186
+ ## Integration in the Suite
187
+
188
+ This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
189
+
190
+ ### Related Packages
191
+
192
+ The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
193
+
194
+ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
195
+
196
+ ## Dependencies
197
+
198
+ - attrs: >=23.1.0
199
+ - cattrs: >=23.1.0
200
+ - requests:
201
+ - wexample-helpers: >=20.0.0
202
+ - wexample-prompt: >=15.0.0
203
+
204
+ ## Versioning & Compatibility Policy
205
+
206
+ Wexample packages follow **Semantic Versioning** (SemVer):
207
+
208
+ - **MAJOR**: Breaking changes
209
+ - **MINOR**: New features, backward compatible
210
+ - **PATCH**: Bug fixes, backward compatible
211
+
212
+ We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
213
+
214
+ ## License
215
+
216
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
217
+
218
+ Free to use in both personal and commercial projects.
219
+
220
+ ## About us
221
+
222
+ [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
223
+
224
+ This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
225
+
226
+ Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
227
+
228
+ ## Known Limitations & Roadmap
229
+
230
+ Current limitations and planned features are tracked in the GitHub issues.
231
+
232
+ See the [project roadmap](https://github.com/wexample/python-api/issues) for upcoming features and improvements.
233
+
234
+ ## Status & Compatibility
235
+
236
+ **Maturity**: Production-ready
237
+
238
+ **Python Support**: >=3.10
239
+
240
+ **OS Support**: Linux, macOS, Windows
241
+
242
+ **Status**: Actively maintained
243
+
244
+ ## Useful Links
245
+
246
+ - **Homepage**: https://github.com/wexample/python-api
247
+ - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
248
+ - **Issue Tracker**: https://github.com/wexample/python-api/issues
249
+ - **Discussions**: https://github.com/wexample/python-api/discussions
250
+ - **PyPI**: [pypi.org/project/wexample-api](https://pypi.org/project/wexample-api/)
251
+
252
+ ## Migration Notes
253
+
254
+ When upgrading between major versions, refer to the migration guides in the documentation.
255
+
256
+ Breaking changes are clearly documented with upgrade paths and examples.
@@ -6,8 +6,8 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "wexample-api"
9
- version = "6.8.2"
10
- description = "Some python basic helpers for apis."
9
+ version = "6.8.4"
10
+ description = "Provides an AbstractGateway base class that handles HTTP requests with rate limiting, status-code validation, retry logic, and structured error reporting for building typed API client gateways"
11
11
  authors = [
12
12
  { name = "weeger", email = "contact@wexample.com" },
13
13
  ]
@@ -21,8 +21,8 @@ dependencies = [
21
21
  "attrs>=23.1.0",
22
22
  "cattrs>=23.1.0",
23
23
  "requests",
24
- "wexample-helpers>=19.0.0",
25
- "wexample-prompt>=14.1.0",
24
+ "wexample-helpers>=20.0.0",
25
+ "wexample-prompt>=15.0.0",
26
26
  ]
27
27
 
28
28
  [project.readme]
File without changes
@@ -1,326 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: wexample-api
3
- Version: 6.8.2
4
- Summary: Some python basic helpers for apis.
5
- Author-Email: weeger <contact@wexample.com>
6
- License: MIT
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Project-URL: homepage, https://github.com/wexample/python-api
11
- Requires-Python: >=3.10
12
- Requires-Dist: attrs>=23.1.0
13
- Requires-Dist: cattrs>=23.1.0
14
- Requires-Dist: requests
15
- Requires-Dist: wexample-helpers>=19.0.0
16
- Requires-Dist: wexample-prompt>=14.1.0
17
- Provides-Extra: dev
18
- Requires-Dist: pytest; extra == "dev"
19
- Requires-Dist: pytest-cov; extra == "dev"
20
- Description-Content-Type: text/markdown
21
-
22
- # api
23
-
24
- Version: 6.8.2
25
-
26
- Some python basic helpers for apis.
27
-
28
- ## Table of Contents
29
-
30
- - [Tests](#tests)
31
- - [Suite Integration](#suite-integration)
32
- - [Dependencies](#dependencies)
33
- - [Versioning](#versioning)
34
- - [License](#license)
35
- - [Suite Integration](#suite-integration)
36
- - [Suite Signature](#suite-signature)
37
- - [Introduction](#introduction)
38
- - [Roadmap](#roadmap)
39
- - [Status Compatibility](#status-compatibility)
40
- - [Useful Links](#useful-links)
41
- - [Migration Notes](#migration-notes)
42
-
43
- ## Tests
44
-
45
- This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
46
-
47
- ### Installation
48
-
49
- First, install the required testing dependencies:
50
- ```bash
51
- .venv/bin/python -m pip install pytest pytest-cov
52
- ```
53
-
54
- ### Basic Usage
55
-
56
- Run all tests with coverage:
57
- ```bash
58
- .venv/bin/python -m pytest --cov --cov-report=html
59
- ```
60
-
61
- ### Common Commands
62
- ```bash
63
- # Run tests with coverage for a specific module
64
- .venv/bin/python -m pytest --cov=your_module
65
-
66
- # Show which lines are not covered
67
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
68
-
69
- # Generate an HTML coverage report
70
- .venv/bin/python -m pytest --cov=your_module --cov-report=html
71
-
72
- # Combine terminal and HTML reports
73
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
74
-
75
- # Run specific test file with coverage
76
- .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
77
- ```
78
-
79
- ### Viewing HTML Reports
80
-
81
- After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
82
-
83
- ### Coverage Threshold
84
-
85
- To enforce a minimum coverage percentage:
86
- ```bash
87
- .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
88
- ```
89
-
90
- This will cause the test suite to fail if coverage drops below 80%.
91
-
92
- ## Integration in the Suite
93
-
94
- This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
95
-
96
- ### Related Packages
97
-
98
- The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
99
-
100
- Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
101
-
102
- ## Dependencies
103
-
104
- - attrs: >=23.1.0
105
- - cattrs: >=23.1.0
106
- - requests:
107
- - wexample-helpers: >=19.0.0
108
- - wexample-prompt: >=14.1.0
109
-
110
- ## Versioning & Compatibility Policy
111
-
112
- Wexample packages follow **Semantic Versioning** (SemVer):
113
-
114
- - **MAJOR**: Breaking changes
115
- - **MINOR**: New features, backward compatible
116
- - **PATCH**: Bug fixes, backward compatible
117
-
118
- We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
119
-
120
- ## License
121
-
122
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
123
-
124
- Free to use in both personal and commercial projects.
125
-
126
- ## Integration in the Suite
127
-
128
- This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
129
-
130
- ### Related Packages
131
-
132
- The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
133
-
134
- Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
135
-
136
- # About us
137
-
138
- [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
139
-
140
- This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
141
-
142
- Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
143
-
144
- # api
145
-
146
- Version: 6.1.1
147
-
148
- Some python basic helpers for apis.
149
-
150
- ## Table of Contents
151
-
152
- - [Tests](#tests)
153
- - [Suite Integration](#suite-integration)
154
- - [Dependencies](#dependencies)
155
- - [Versioning](#versioning)
156
- - [License](#license)
157
- - [Suite Integration](#suite-integration)
158
- - [Suite Signature](#suite-signature)
159
- - [Introduction](#introduction)
160
- - [Roadmap](#roadmap)
161
- - [Status Compatibility](#status-compatibility)
162
- - [Useful Links](#useful-links)
163
- - [Migration Notes](#migration-notes)
164
-
165
- ## Tests
166
-
167
- This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
168
-
169
- ### Installation
170
-
171
- First, install the required testing dependencies:
172
- ```bash
173
- .venv/bin/python -m pip install pytest pytest-cov
174
- ```
175
-
176
- ### Basic Usage
177
-
178
- Run all tests with coverage:
179
- ```bash
180
- .venv/bin/python -m pytest --cov --cov-report=html
181
- ```
182
-
183
- ### Common Commands
184
- ```bash
185
- # Run tests with coverage for a specific module
186
- .venv/bin/python -m pytest --cov=your_module
187
-
188
- # Show which lines are not covered
189
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
190
-
191
- # Generate an HTML coverage report
192
- .venv/bin/python -m pytest --cov=your_module --cov-report=html
193
-
194
- # Combine terminal and HTML reports
195
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
196
-
197
- # Run specific test file with coverage
198
- .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
199
- ```
200
-
201
- ### Viewing HTML Reports
202
-
203
- After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
204
-
205
- ### Coverage Threshold
206
-
207
- To enforce a minimum coverage percentage:
208
- ```bash
209
- .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
210
- ```
211
-
212
- This will cause the test suite to fail if coverage drops below 80%.
213
-
214
- ## Integration in the Suite
215
-
216
- This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
217
-
218
- ### Related Packages
219
-
220
- The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
221
-
222
- Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
223
-
224
- ## Dependencies
225
-
226
- - attrs: >=23.1.0
227
- - cattrs: >=23.1.0
228
- - requests:
229
- - wexample-helpers: >=8.0.0
230
- - wexample-prompt: >=6.1.0
231
-
232
- ## Versioning & Compatibility Policy
233
-
234
- Wexample packages follow **Semantic Versioning** (SemVer):
235
-
236
- - **MAJOR**: Breaking changes
237
- - **MINOR**: New features, backward compatible
238
- - **PATCH**: Bug fixes, backward compatible
239
-
240
- We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
241
-
242
- ## License
243
-
244
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
245
-
246
- Free to use in both personal and commercial projects.
247
-
248
- ## Integration in the Suite
249
-
250
- This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
251
-
252
- ### Related Packages
253
-
254
- The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
255
-
256
- Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
257
-
258
- # About us
259
-
260
- [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
261
-
262
- This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
263
-
264
- Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
265
-
266
- A Python toolkit for building and consuming structured APIs.
267
-
268
- ## Known Limitations & Roadmap
269
-
270
- Current limitations and planned features are tracked in the GitHub issues.
271
-
272
- See the [project roadmap](https://github.com/wexample/python-api/issues) for upcoming features and improvements.
273
-
274
- ## Status & Compatibility
275
-
276
- **Maturity**: Production-ready
277
-
278
- **Python Support**: >=3.10
279
-
280
- **OS Support**: Linux, macOS, Windows
281
-
282
- **Status**: Actively maintained
283
-
284
- ## Useful Links
285
-
286
- - **Homepage**: https://github.com/wexample/python-api
287
- - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
288
- - **Issue Tracker**: https://github.com/wexample/python-api/issues
289
- - **Discussions**: https://github.com/wexample/python-api/discussions
290
- - **PyPI**: [pypi.org/project/api](https://pypi.org/project/api/)
291
-
292
- ## Migration Notes
293
-
294
- When upgrading between major versions, refer to the migration guides in the documentation.
295
-
296
- Breaking changes are clearly documented with upgrade paths and examples.
297
-
298
- ## Known Limitations & Roadmap
299
-
300
- Current limitations and planned features are tracked in the GitHub issues.
301
-
302
- See the [project roadmap](https://github.com/wexample/python-api/issues) for upcoming features and improvements.
303
-
304
- ## Status & Compatibility
305
-
306
- **Maturity**: Production-ready
307
-
308
- **Python Support**: >=3.10
309
-
310
- **OS Support**: Linux, macOS, Windows
311
-
312
- **Status**: Actively maintained
313
-
314
- ## Useful Links
315
-
316
- - **Homepage**: https://github.com/wexample/python-api
317
- - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
318
- - **Issue Tracker**: https://github.com/wexample/python-api/issues
319
- - **Discussions**: https://github.com/wexample/python-api/discussions
320
- - **PyPI**: [pypi.org/project/api](https://pypi.org/project/api/)
321
-
322
- ## Migration Notes
323
-
324
- When upgrading between major versions, refer to the migration guides in the documentation.
325
-
326
- Breaking changes are clearly documented with upgrade paths and examples.
@@ -1,305 +0,0 @@
1
- # api
2
-
3
- Version: 6.8.2
4
-
5
- Some python basic helpers for apis.
6
-
7
- ## Table of Contents
8
-
9
- - [Tests](#tests)
10
- - [Suite Integration](#suite-integration)
11
- - [Dependencies](#dependencies)
12
- - [Versioning](#versioning)
13
- - [License](#license)
14
- - [Suite Integration](#suite-integration)
15
- - [Suite Signature](#suite-signature)
16
- - [Introduction](#introduction)
17
- - [Roadmap](#roadmap)
18
- - [Status Compatibility](#status-compatibility)
19
- - [Useful Links](#useful-links)
20
- - [Migration Notes](#migration-notes)
21
-
22
- ## Tests
23
-
24
- This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
25
-
26
- ### Installation
27
-
28
- First, install the required testing dependencies:
29
- ```bash
30
- .venv/bin/python -m pip install pytest pytest-cov
31
- ```
32
-
33
- ### Basic Usage
34
-
35
- Run all tests with coverage:
36
- ```bash
37
- .venv/bin/python -m pytest --cov --cov-report=html
38
- ```
39
-
40
- ### Common Commands
41
- ```bash
42
- # Run tests with coverage for a specific module
43
- .venv/bin/python -m pytest --cov=your_module
44
-
45
- # Show which lines are not covered
46
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
47
-
48
- # Generate an HTML coverage report
49
- .venv/bin/python -m pytest --cov=your_module --cov-report=html
50
-
51
- # Combine terminal and HTML reports
52
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
53
-
54
- # Run specific test file with coverage
55
- .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
56
- ```
57
-
58
- ### Viewing HTML Reports
59
-
60
- After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
61
-
62
- ### Coverage Threshold
63
-
64
- To enforce a minimum coverage percentage:
65
- ```bash
66
- .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
67
- ```
68
-
69
- This will cause the test suite to fail if coverage drops below 80%.
70
-
71
- ## Integration in the Suite
72
-
73
- This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
74
-
75
- ### Related Packages
76
-
77
- The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
78
-
79
- Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
80
-
81
- ## Dependencies
82
-
83
- - attrs: >=23.1.0
84
- - cattrs: >=23.1.0
85
- - requests:
86
- - wexample-helpers: >=19.0.0
87
- - wexample-prompt: >=14.1.0
88
-
89
- ## Versioning & Compatibility Policy
90
-
91
- Wexample packages follow **Semantic Versioning** (SemVer):
92
-
93
- - **MAJOR**: Breaking changes
94
- - **MINOR**: New features, backward compatible
95
- - **PATCH**: Bug fixes, backward compatible
96
-
97
- We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
98
-
99
- ## License
100
-
101
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
102
-
103
- Free to use in both personal and commercial projects.
104
-
105
- ## Integration in the Suite
106
-
107
- This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
108
-
109
- ### Related Packages
110
-
111
- The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
112
-
113
- Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
114
-
115
- # About us
116
-
117
- [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
118
-
119
- This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
120
-
121
- Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
122
-
123
- # api
124
-
125
- Version: 6.1.1
126
-
127
- Some python basic helpers for apis.
128
-
129
- ## Table of Contents
130
-
131
- - [Tests](#tests)
132
- - [Suite Integration](#suite-integration)
133
- - [Dependencies](#dependencies)
134
- - [Versioning](#versioning)
135
- - [License](#license)
136
- - [Suite Integration](#suite-integration)
137
- - [Suite Signature](#suite-signature)
138
- - [Introduction](#introduction)
139
- - [Roadmap](#roadmap)
140
- - [Status Compatibility](#status-compatibility)
141
- - [Useful Links](#useful-links)
142
- - [Migration Notes](#migration-notes)
143
-
144
- ## Tests
145
-
146
- This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
147
-
148
- ### Installation
149
-
150
- First, install the required testing dependencies:
151
- ```bash
152
- .venv/bin/python -m pip install pytest pytest-cov
153
- ```
154
-
155
- ### Basic Usage
156
-
157
- Run all tests with coverage:
158
- ```bash
159
- .venv/bin/python -m pytest --cov --cov-report=html
160
- ```
161
-
162
- ### Common Commands
163
- ```bash
164
- # Run tests with coverage for a specific module
165
- .venv/bin/python -m pytest --cov=your_module
166
-
167
- # Show which lines are not covered
168
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
169
-
170
- # Generate an HTML coverage report
171
- .venv/bin/python -m pytest --cov=your_module --cov-report=html
172
-
173
- # Combine terminal and HTML reports
174
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
175
-
176
- # Run specific test file with coverage
177
- .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
178
- ```
179
-
180
- ### Viewing HTML Reports
181
-
182
- After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
183
-
184
- ### Coverage Threshold
185
-
186
- To enforce a minimum coverage percentage:
187
- ```bash
188
- .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
189
- ```
190
-
191
- This will cause the test suite to fail if coverage drops below 80%.
192
-
193
- ## Integration in the Suite
194
-
195
- This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
196
-
197
- ### Related Packages
198
-
199
- The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
200
-
201
- Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
202
-
203
- ## Dependencies
204
-
205
- - attrs: >=23.1.0
206
- - cattrs: >=23.1.0
207
- - requests:
208
- - wexample-helpers: >=8.0.0
209
- - wexample-prompt: >=6.1.0
210
-
211
- ## Versioning & Compatibility Policy
212
-
213
- Wexample packages follow **Semantic Versioning** (SemVer):
214
-
215
- - **MAJOR**: Breaking changes
216
- - **MINOR**: New features, backward compatible
217
- - **PATCH**: Bug fixes, backward compatible
218
-
219
- We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
220
-
221
- ## License
222
-
223
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
224
-
225
- Free to use in both personal and commercial projects.
226
-
227
- ## Integration in the Suite
228
-
229
- This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
230
-
231
- ### Related Packages
232
-
233
- The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
234
-
235
- Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
236
-
237
- # About us
238
-
239
- [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
240
-
241
- This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
242
-
243
- Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
244
-
245
- A Python toolkit for building and consuming structured APIs.
246
-
247
- ## Known Limitations & Roadmap
248
-
249
- Current limitations and planned features are tracked in the GitHub issues.
250
-
251
- See the [project roadmap](https://github.com/wexample/python-api/issues) for upcoming features and improvements.
252
-
253
- ## Status & Compatibility
254
-
255
- **Maturity**: Production-ready
256
-
257
- **Python Support**: >=3.10
258
-
259
- **OS Support**: Linux, macOS, Windows
260
-
261
- **Status**: Actively maintained
262
-
263
- ## Useful Links
264
-
265
- - **Homepage**: https://github.com/wexample/python-api
266
- - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
267
- - **Issue Tracker**: https://github.com/wexample/python-api/issues
268
- - **Discussions**: https://github.com/wexample/python-api/discussions
269
- - **PyPI**: [pypi.org/project/api](https://pypi.org/project/api/)
270
-
271
- ## Migration Notes
272
-
273
- When upgrading between major versions, refer to the migration guides in the documentation.
274
-
275
- Breaking changes are clearly documented with upgrade paths and examples.
276
-
277
- ## Known Limitations & Roadmap
278
-
279
- Current limitations and planned features are tracked in the GitHub issues.
280
-
281
- See the [project roadmap](https://github.com/wexample/python-api/issues) for upcoming features and improvements.
282
-
283
- ## Status & Compatibility
284
-
285
- **Maturity**: Production-ready
286
-
287
- **Python Support**: >=3.10
288
-
289
- **OS Support**: Linux, macOS, Windows
290
-
291
- **Status**: Actively maintained
292
-
293
- ## Useful Links
294
-
295
- - **Homepage**: https://github.com/wexample/python-api
296
- - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
297
- - **Issue Tracker**: https://github.com/wexample/python-api/issues
298
- - **Discussions**: https://github.com/wexample/python-api/discussions
299
- - **PyPI**: [pypi.org/project/api](https://pypi.org/project/api/)
300
-
301
- ## Migration Notes
302
-
303
- When upgrading between major versions, refer to the migration guides in the documentation.
304
-
305
- Breaking changes are clearly documented with upgrade paths and examples.