open-product-client 0.3.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.
- open_product_client-0.3.0/PKG-INFO +100 -0
- open_product_client-0.3.0/README.rst +62 -0
- open_product_client-0.3.0/open_product_client.egg-info/PKG-INFO +100 -0
- open_product_client-0.3.0/open_product_client.egg-info/SOURCES.txt +30 -0
- open_product_client-0.3.0/open_product_client.egg-info/dependency_links.txt +1 -0
- open_product_client-0.3.0/open_product_client.egg-info/requires.txt +19 -0
- open_product_client-0.3.0/open_product_client.egg-info/top_level.txt +1 -0
- open_product_client-0.3.0/openproduct_client/__init__.py +1 -0
- open_product_client-0.3.0/openproduct_client/clients.py +53 -0
- open_product_client-0.3.0/openproduct_client/resources/__init__.py +0 -0
- open_product_client-0.3.0/openproduct_client/resources/base.py +125 -0
- open_product_client-0.3.0/openproduct_client/resources/product/__init__.py +0 -0
- open_product_client-0.3.0/openproduct_client/resources/product_type/__init__.py +11 -0
- open_product_client-0.3.0/openproduct_client/resources/product_type/content_label.py +18 -0
- open_product_client-0.3.0/openproduct_client/resources/product_type/price.py +18 -0
- open_product_client-0.3.0/openproduct_client/resources/product_type/product_type.py +65 -0
- open_product_client-0.3.0/openproduct_client/resources/product_type/theme.py +21 -0
- open_product_client-0.3.0/openproduct_client/structs/__init__.py +0 -0
- open_product_client-0.3.0/openproduct_client/structs/base.py +44 -0
- open_product_client-0.3.0/openproduct_client/structs/product/__init__.py +0 -0
- open_product_client-0.3.0/openproduct_client/structs/product_type/__init__.py +30 -0
- open_product_client-0.3.0/openproduct_client/structs/product_type/common.py +11 -0
- open_product_client-0.3.0/openproduct_client/structs/product_type/content_label.py +9 -0
- open_product_client-0.3.0/openproduct_client/structs/product_type/price.py +62 -0
- open_product_client-0.3.0/openproduct_client/structs/product_type/product_type.py +247 -0
- open_product_client-0.3.0/openproduct_client/structs/product_type/theme.py +59 -0
- open_product_client-0.3.0/pyproject.toml +127 -0
- open_product_client-0.3.0/setup.cfg +4 -0
- open_product_client-0.3.0/tests/test_content_label.py +13 -0
- open_product_client-0.3.0/tests/test_price.py +25 -0
- open_product_client-0.3.0/tests/test_product_type.py +115 -0
- open_product_client-0.3.0/tests/test_theme.py +26 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: open-product-client
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: API Client library to communicate with the Open Product service.
|
|
5
|
+
Author-email: Maykin <support@maykinmedia.nl>
|
|
6
|
+
License-Expression: EUPL-1.2
|
|
7
|
+
Project-URL: Homepage, https://github.com/maykinmedia/open-product-api-client
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/maykinmedia/open-product-api-client/issues
|
|
9
|
+
Project-URL: Source Code, https://github.com/maykinmedia/open-product-api-client
|
|
10
|
+
Keywords: maykin,openproduct,open product,producten,producttypen,common ground,api client
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: Unix
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Description-Content-Type: text/x-rst
|
|
22
|
+
Requires-Dist: ape-pie>=0.2.0
|
|
23
|
+
Requires-Dist: msgspec>=0.22.0
|
|
24
|
+
Provides-Extra: tests
|
|
25
|
+
Requires-Dist: pytest; extra == "tests"
|
|
26
|
+
Requires-Dist: tox; extra == "tests"
|
|
27
|
+
Requires-Dist: ruff; extra == "tests"
|
|
28
|
+
Requires-Dist: pyright; extra == "tests"
|
|
29
|
+
Requires-Dist: vcrpy; extra == "tests"
|
|
30
|
+
Requires-Dist: pytest-recording; extra == "tests"
|
|
31
|
+
Requires-Dist: types-requests; extra == "tests"
|
|
32
|
+
Requires-Dist: pytest-cov; extra == "tests"
|
|
33
|
+
Provides-Extra: docs
|
|
34
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
35
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
36
|
+
Provides-Extra: release
|
|
37
|
+
Requires-Dist: bump-my-version; extra == "release"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Open Product Client
|
|
42
|
+
=======================
|
|
43
|
+
|
|
44
|
+
:Version: 0.3.0
|
|
45
|
+
:Source: https://github.com/maykinmedia/open-product-client
|
|
46
|
+
:Keywords: Open Product API, Client, producten, producttypen
|
|
47
|
+
|
|
48
|
+
Currently compatible with Open Product 1.7.0
|
|
49
|
+
|
|
50
|
+
|build-status| |coverage| |python-versions| |pypi-version|
|
|
51
|
+
|
|
52
|
+
About
|
|
53
|
+
=====
|
|
54
|
+
|
|
55
|
+
A Python client library for interacting with the `Open Product API <https://github.com/maykinmedia/open-product>`_.
|
|
56
|
+
|
|
57
|
+
Installation
|
|
58
|
+
============
|
|
59
|
+
|
|
60
|
+
Requirements
|
|
61
|
+
------------
|
|
62
|
+
|
|
63
|
+
* Python 3.12 or newer
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
Install
|
|
67
|
+
-------
|
|
68
|
+
|
|
69
|
+
.. code-block:: bash
|
|
70
|
+
|
|
71
|
+
uv pip install open-product-client
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
Usage
|
|
75
|
+
=====
|
|
76
|
+
|
|
77
|
+
# TODO
|
|
78
|
+
|
|
79
|
+
Licence
|
|
80
|
+
=======
|
|
81
|
+
|
|
82
|
+
Licensed under the `MIT`_.
|
|
83
|
+
|
|
84
|
+
.. _`Maykin Media B.V.`: https://www.maykin.nl
|
|
85
|
+
.. _`MIT`: LICENSE
|
|
86
|
+
.. _`Open Product API`: https://github.com/maykinmedia/open-product
|
|
87
|
+
|
|
88
|
+
.. |build-status| image:: https://github.com/maykinmedia/open-product-client/actions/workflows/ci.yml/badge.svg
|
|
89
|
+
:alt: Build status
|
|
90
|
+
:target: https://github.com/maykinmedia/open-product-client/actions/workflows/ci.yml
|
|
91
|
+
|
|
92
|
+
.. |coverage| image:: https://codecov.io/gh/maykinmedia/open-product-client/branch/main/graph/badge.svg
|
|
93
|
+
:target: https://codecov.io/gh/maykinmedia/open-product-client
|
|
94
|
+
:alt: Coverage status
|
|
95
|
+
|
|
96
|
+
.. |python-versions| image:: https://img.shields.io/badge/python-3.12-blue.svg
|
|
97
|
+
:alt: Supported Python versions
|
|
98
|
+
|
|
99
|
+
.. |pypi-version| image:: https://img.shields.io/pypi/v/open_product_client.svg
|
|
100
|
+
:target: https://pypi.org/project/open_product_client/
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
Open Product Client
|
|
4
|
+
=======================
|
|
5
|
+
|
|
6
|
+
:Version: 0.3.0
|
|
7
|
+
:Source: https://github.com/maykinmedia/open-product-client
|
|
8
|
+
:Keywords: Open Product API, Client, producten, producttypen
|
|
9
|
+
|
|
10
|
+
Currently compatible with Open Product 1.7.0
|
|
11
|
+
|
|
12
|
+
|build-status| |coverage| |python-versions| |pypi-version|
|
|
13
|
+
|
|
14
|
+
About
|
|
15
|
+
=====
|
|
16
|
+
|
|
17
|
+
A Python client library for interacting with the `Open Product API <https://github.com/maykinmedia/open-product>`_.
|
|
18
|
+
|
|
19
|
+
Installation
|
|
20
|
+
============
|
|
21
|
+
|
|
22
|
+
Requirements
|
|
23
|
+
------------
|
|
24
|
+
|
|
25
|
+
* Python 3.12 or newer
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
Install
|
|
29
|
+
-------
|
|
30
|
+
|
|
31
|
+
.. code-block:: bash
|
|
32
|
+
|
|
33
|
+
uv pip install open-product-client
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Usage
|
|
37
|
+
=====
|
|
38
|
+
|
|
39
|
+
# TODO
|
|
40
|
+
|
|
41
|
+
Licence
|
|
42
|
+
=======
|
|
43
|
+
|
|
44
|
+
Licensed under the `MIT`_.
|
|
45
|
+
|
|
46
|
+
.. _`Maykin Media B.V.`: https://www.maykin.nl
|
|
47
|
+
.. _`MIT`: LICENSE
|
|
48
|
+
.. _`Open Product API`: https://github.com/maykinmedia/open-product
|
|
49
|
+
|
|
50
|
+
.. |build-status| image:: https://github.com/maykinmedia/open-product-client/actions/workflows/ci.yml/badge.svg
|
|
51
|
+
:alt: Build status
|
|
52
|
+
:target: https://github.com/maykinmedia/open-product-client/actions/workflows/ci.yml
|
|
53
|
+
|
|
54
|
+
.. |coverage| image:: https://codecov.io/gh/maykinmedia/open-product-client/branch/main/graph/badge.svg
|
|
55
|
+
:target: https://codecov.io/gh/maykinmedia/open-product-client
|
|
56
|
+
:alt: Coverage status
|
|
57
|
+
|
|
58
|
+
.. |python-versions| image:: https://img.shields.io/badge/python-3.12-blue.svg
|
|
59
|
+
:alt: Supported Python versions
|
|
60
|
+
|
|
61
|
+
.. |pypi-version| image:: https://img.shields.io/pypi/v/open_product_client.svg
|
|
62
|
+
:target: https://pypi.org/project/open_product_client/
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: open-product-client
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: API Client library to communicate with the Open Product service.
|
|
5
|
+
Author-email: Maykin <support@maykinmedia.nl>
|
|
6
|
+
License-Expression: EUPL-1.2
|
|
7
|
+
Project-URL: Homepage, https://github.com/maykinmedia/open-product-api-client
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/maykinmedia/open-product-api-client/issues
|
|
9
|
+
Project-URL: Source Code, https://github.com/maykinmedia/open-product-api-client
|
|
10
|
+
Keywords: maykin,openproduct,open product,producten,producttypen,common ground,api client
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: Unix
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Description-Content-Type: text/x-rst
|
|
22
|
+
Requires-Dist: ape-pie>=0.2.0
|
|
23
|
+
Requires-Dist: msgspec>=0.22.0
|
|
24
|
+
Provides-Extra: tests
|
|
25
|
+
Requires-Dist: pytest; extra == "tests"
|
|
26
|
+
Requires-Dist: tox; extra == "tests"
|
|
27
|
+
Requires-Dist: ruff; extra == "tests"
|
|
28
|
+
Requires-Dist: pyright; extra == "tests"
|
|
29
|
+
Requires-Dist: vcrpy; extra == "tests"
|
|
30
|
+
Requires-Dist: pytest-recording; extra == "tests"
|
|
31
|
+
Requires-Dist: types-requests; extra == "tests"
|
|
32
|
+
Requires-Dist: pytest-cov; extra == "tests"
|
|
33
|
+
Provides-Extra: docs
|
|
34
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
35
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
36
|
+
Provides-Extra: release
|
|
37
|
+
Requires-Dist: bump-my-version; extra == "release"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Open Product Client
|
|
42
|
+
=======================
|
|
43
|
+
|
|
44
|
+
:Version: 0.3.0
|
|
45
|
+
:Source: https://github.com/maykinmedia/open-product-client
|
|
46
|
+
:Keywords: Open Product API, Client, producten, producttypen
|
|
47
|
+
|
|
48
|
+
Currently compatible with Open Product 1.7.0
|
|
49
|
+
|
|
50
|
+
|build-status| |coverage| |python-versions| |pypi-version|
|
|
51
|
+
|
|
52
|
+
About
|
|
53
|
+
=====
|
|
54
|
+
|
|
55
|
+
A Python client library for interacting with the `Open Product API <https://github.com/maykinmedia/open-product>`_.
|
|
56
|
+
|
|
57
|
+
Installation
|
|
58
|
+
============
|
|
59
|
+
|
|
60
|
+
Requirements
|
|
61
|
+
------------
|
|
62
|
+
|
|
63
|
+
* Python 3.12 or newer
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
Install
|
|
67
|
+
-------
|
|
68
|
+
|
|
69
|
+
.. code-block:: bash
|
|
70
|
+
|
|
71
|
+
uv pip install open-product-client
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
Usage
|
|
75
|
+
=====
|
|
76
|
+
|
|
77
|
+
# TODO
|
|
78
|
+
|
|
79
|
+
Licence
|
|
80
|
+
=======
|
|
81
|
+
|
|
82
|
+
Licensed under the `MIT`_.
|
|
83
|
+
|
|
84
|
+
.. _`Maykin Media B.V.`: https://www.maykin.nl
|
|
85
|
+
.. _`MIT`: LICENSE
|
|
86
|
+
.. _`Open Product API`: https://github.com/maykinmedia/open-product
|
|
87
|
+
|
|
88
|
+
.. |build-status| image:: https://github.com/maykinmedia/open-product-client/actions/workflows/ci.yml/badge.svg
|
|
89
|
+
:alt: Build status
|
|
90
|
+
:target: https://github.com/maykinmedia/open-product-client/actions/workflows/ci.yml
|
|
91
|
+
|
|
92
|
+
.. |coverage| image:: https://codecov.io/gh/maykinmedia/open-product-client/branch/main/graph/badge.svg
|
|
93
|
+
:target: https://codecov.io/gh/maykinmedia/open-product-client
|
|
94
|
+
:alt: Coverage status
|
|
95
|
+
|
|
96
|
+
.. |python-versions| image:: https://img.shields.io/badge/python-3.12-blue.svg
|
|
97
|
+
:alt: Supported Python versions
|
|
98
|
+
|
|
99
|
+
.. |pypi-version| image:: https://img.shields.io/pypi/v/open_product_client.svg
|
|
100
|
+
:target: https://pypi.org/project/open_product_client/
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
README.rst
|
|
2
|
+
pyproject.toml
|
|
3
|
+
open_product_client.egg-info/PKG-INFO
|
|
4
|
+
open_product_client.egg-info/SOURCES.txt
|
|
5
|
+
open_product_client.egg-info/dependency_links.txt
|
|
6
|
+
open_product_client.egg-info/requires.txt
|
|
7
|
+
open_product_client.egg-info/top_level.txt
|
|
8
|
+
openproduct_client/__init__.py
|
|
9
|
+
openproduct_client/clients.py
|
|
10
|
+
openproduct_client/resources/__init__.py
|
|
11
|
+
openproduct_client/resources/base.py
|
|
12
|
+
openproduct_client/resources/product/__init__.py
|
|
13
|
+
openproduct_client/resources/product_type/__init__.py
|
|
14
|
+
openproduct_client/resources/product_type/content_label.py
|
|
15
|
+
openproduct_client/resources/product_type/price.py
|
|
16
|
+
openproduct_client/resources/product_type/product_type.py
|
|
17
|
+
openproduct_client/resources/product_type/theme.py
|
|
18
|
+
openproduct_client/structs/__init__.py
|
|
19
|
+
openproduct_client/structs/base.py
|
|
20
|
+
openproduct_client/structs/product/__init__.py
|
|
21
|
+
openproduct_client/structs/product_type/__init__.py
|
|
22
|
+
openproduct_client/structs/product_type/common.py
|
|
23
|
+
openproduct_client/structs/product_type/content_label.py
|
|
24
|
+
openproduct_client/structs/product_type/price.py
|
|
25
|
+
openproduct_client/structs/product_type/product_type.py
|
|
26
|
+
openproduct_client/structs/product_type/theme.py
|
|
27
|
+
tests/test_content_label.py
|
|
28
|
+
tests/test_price.py
|
|
29
|
+
tests/test_product_type.py
|
|
30
|
+
tests/test_theme.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
openproduct_client
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from collections.abc import MutableMapping
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
from ape_pie import APIClient
|
|
5
|
+
from ape_pie.typing import ConfigAdapter
|
|
6
|
+
|
|
7
|
+
from .resources.product_type import (
|
|
8
|
+
ContentLabelResource,
|
|
9
|
+
PriceResource,
|
|
10
|
+
ProductTypeResource,
|
|
11
|
+
ThemeResource,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class OpenProductClient(APIClient):
|
|
16
|
+
product_type: ProductTypeResource
|
|
17
|
+
theme: ThemeResource
|
|
18
|
+
content_label: ContentLabelResource
|
|
19
|
+
price: PriceResource
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
base_url: str,
|
|
24
|
+
*,
|
|
25
|
+
token: str = "",
|
|
26
|
+
language_code: Literal["nl", "en"] = "nl",
|
|
27
|
+
request_kwargs: MutableMapping[str, object] | None = None,
|
|
28
|
+
**kwargs,
|
|
29
|
+
):
|
|
30
|
+
if request_kwargs is None:
|
|
31
|
+
request_kwargs = {}
|
|
32
|
+
if "headers" not in request_kwargs:
|
|
33
|
+
request_kwargs["headers"] = {}
|
|
34
|
+
|
|
35
|
+
assert isinstance(request_kwargs["headers"], MutableMapping)
|
|
36
|
+
|
|
37
|
+
if token:
|
|
38
|
+
request_kwargs["headers"]["Authorization"] = f"Token {token}"
|
|
39
|
+
|
|
40
|
+
request_kwargs["headers"]["Accept-Language"] = language_code
|
|
41
|
+
|
|
42
|
+
super().__init__(base_url=base_url, request_kwargs=request_kwargs) # pyright: ignore[reportArgumentType]
|
|
43
|
+
|
|
44
|
+
self.theme = ThemeResource(self)
|
|
45
|
+
self.content_label = ContentLabelResource(self)
|
|
46
|
+
self.product_type = ProductTypeResource(self)
|
|
47
|
+
self.price = PriceResource(self)
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def configure_from(cls, adapter: ConfigAdapter, **kwargs):
|
|
51
|
+
base_url = adapter.get_client_base_url()
|
|
52
|
+
session_kwargs = adapter.get_client_session_kwargs()
|
|
53
|
+
return cls(base_url, request_kwargs=session_kwargs, **kwargs)
|
|
File without changes
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from collections.abc import Mapping
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
import msgspec
|
|
8
|
+
import requests
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from ..clients import OpenProductClient
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class BaseResource:
|
|
18
|
+
http_client: OpenProductClient
|
|
19
|
+
|
|
20
|
+
def __init__(self, http_client: OpenProductClient):
|
|
21
|
+
self.http_client = http_client
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def process_response[T](
|
|
25
|
+
response: requests.Response,
|
|
26
|
+
struct_type: type[T],
|
|
27
|
+
) -> T:
|
|
28
|
+
response_data = response.json()
|
|
29
|
+
# for now: assume no errors :)
|
|
30
|
+
return msgspec.convert(response_data, type=struct_type)
|
|
31
|
+
|
|
32
|
+
def _get(
|
|
33
|
+
self,
|
|
34
|
+
path: str,
|
|
35
|
+
headers: Mapping | None = None,
|
|
36
|
+
params: msgspec.Struct | None = None,
|
|
37
|
+
) -> requests.Response:
|
|
38
|
+
query_params = msgspec.to_builtins(params)
|
|
39
|
+
response = self.http_client.request(
|
|
40
|
+
"get", path, headers=headers, params=query_params
|
|
41
|
+
)
|
|
42
|
+
response.raise_for_status()
|
|
43
|
+
return response
|
|
44
|
+
|
|
45
|
+
def _post(
|
|
46
|
+
self,
|
|
47
|
+
path: str,
|
|
48
|
+
headers: Mapping | None = None,
|
|
49
|
+
params: msgspec.Struct | None = None,
|
|
50
|
+
data: object = None,
|
|
51
|
+
) -> requests.Response:
|
|
52
|
+
query_params = msgspec.to_builtins(params)
|
|
53
|
+
response = self.http_client.request(
|
|
54
|
+
"post",
|
|
55
|
+
path,
|
|
56
|
+
headers=headers,
|
|
57
|
+
json=data,
|
|
58
|
+
params=query_params,
|
|
59
|
+
)
|
|
60
|
+
response.raise_for_status()
|
|
61
|
+
return response
|
|
62
|
+
|
|
63
|
+
def _put(
|
|
64
|
+
self,
|
|
65
|
+
path: str,
|
|
66
|
+
headers: Mapping | None = None,
|
|
67
|
+
params: msgspec.Struct | None = None,
|
|
68
|
+
data: object = None,
|
|
69
|
+
) -> requests.Response:
|
|
70
|
+
query_params = msgspec.to_builtins(params)
|
|
71
|
+
response = self.http_client.request(
|
|
72
|
+
"put", path, headers=headers, json=data, params=query_params
|
|
73
|
+
)
|
|
74
|
+
response.raise_for_status()
|
|
75
|
+
return response
|
|
76
|
+
|
|
77
|
+
def _delete(
|
|
78
|
+
self,
|
|
79
|
+
path: str,
|
|
80
|
+
headers: Mapping | None = None,
|
|
81
|
+
params: msgspec.Struct | None = None,
|
|
82
|
+
) -> requests.Response:
|
|
83
|
+
query_params = msgspec.to_builtins(params)
|
|
84
|
+
response = self.http_client.request(
|
|
85
|
+
"delete",
|
|
86
|
+
path,
|
|
87
|
+
headers=headers,
|
|
88
|
+
params=query_params,
|
|
89
|
+
)
|
|
90
|
+
response.raise_for_status()
|
|
91
|
+
return response
|
|
92
|
+
|
|
93
|
+
def _patch(
|
|
94
|
+
self,
|
|
95
|
+
path: str,
|
|
96
|
+
headers: Mapping | None = None,
|
|
97
|
+
params: msgspec.Struct | None = None,
|
|
98
|
+
data: object = None,
|
|
99
|
+
) -> requests.Response:
|
|
100
|
+
query_params = msgspec.to_builtins(params)
|
|
101
|
+
response = self.http_client.request(
|
|
102
|
+
"patch",
|
|
103
|
+
path,
|
|
104
|
+
headers=headers,
|
|
105
|
+
params=query_params,
|
|
106
|
+
json=data,
|
|
107
|
+
)
|
|
108
|
+
response.raise_for_status()
|
|
109
|
+
return response
|
|
110
|
+
|
|
111
|
+
def _options(
|
|
112
|
+
self,
|
|
113
|
+
path: str,
|
|
114
|
+
headers: Mapping | None = None,
|
|
115
|
+
params: msgspec.Struct | None = None,
|
|
116
|
+
) -> requests.Response:
|
|
117
|
+
query_params = msgspec.to_builtins(params)
|
|
118
|
+
response = self.http_client.request(
|
|
119
|
+
"delete",
|
|
120
|
+
path,
|
|
121
|
+
headers=headers,
|
|
122
|
+
params=query_params,
|
|
123
|
+
)
|
|
124
|
+
response.raise_for_status()
|
|
125
|
+
return response
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from .content_label import ContentLabelResource
|
|
2
|
+
from .price import PriceResource
|
|
3
|
+
from .product_type import ProductTypeResource
|
|
4
|
+
from .theme import ThemeResource
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"ContentLabelResource",
|
|
8
|
+
"PriceResource",
|
|
9
|
+
"ProductTypeResource",
|
|
10
|
+
"ThemeResource",
|
|
11
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from typing import ClassVar
|
|
2
|
+
|
|
3
|
+
from ...structs.base import PaginatedResponseBody, PaginationParams
|
|
4
|
+
from ...structs.product_type import ContentLabel
|
|
5
|
+
from ..base import BaseResource
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ContentLabelResource(BaseResource):
|
|
9
|
+
base_path: ClassVar[str] = "contentlabels"
|
|
10
|
+
|
|
11
|
+
def list(
|
|
12
|
+
self, *, params: PaginationParams | None = None
|
|
13
|
+
) -> PaginatedResponseBody[ContentLabel]:
|
|
14
|
+
"""
|
|
15
|
+
Get all the available content labels (based on query parameters).
|
|
16
|
+
"""
|
|
17
|
+
response = self._get(self.base_path, params=params)
|
|
18
|
+
return self.process_response(response, PaginatedResponseBody[ContentLabel])
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from typing import ClassVar
|
|
2
|
+
|
|
3
|
+
from ...structs.base import PaginatedResponseBody
|
|
4
|
+
from ...structs.product_type import Price, PriceParams
|
|
5
|
+
from ..base import BaseResource
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PriceResource(BaseResource):
|
|
9
|
+
base_path: ClassVar[str] = "prijzen"
|
|
10
|
+
|
|
11
|
+
def list(
|
|
12
|
+
self, *, params: PriceParams | None = None
|
|
13
|
+
) -> PaginatedResponseBody[Price]:
|
|
14
|
+
"""
|
|
15
|
+
Get all the available prices (based on query parameters).
|
|
16
|
+
"""
|
|
17
|
+
response = self._get(self.base_path, params=params)
|
|
18
|
+
return self.process_response(response, PaginatedResponseBody[Price])
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import uuid
|
|
2
|
+
from collections.abc import Sequence
|
|
3
|
+
from typing import ClassVar
|
|
4
|
+
|
|
5
|
+
from ...structs.base import PaginatedResponseBody
|
|
6
|
+
from ...structs.product_type import (
|
|
7
|
+
ContentParams,
|
|
8
|
+
NestedContentElement,
|
|
9
|
+
ProductType,
|
|
10
|
+
ProductTypeCreateData,
|
|
11
|
+
ProductTypeParams,
|
|
12
|
+
ProductTypePartialUpdateData,
|
|
13
|
+
)
|
|
14
|
+
from ..base import BaseResource
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ProductTypeResource(BaseResource):
|
|
18
|
+
base_path: ClassVar[str] = "producttypen"
|
|
19
|
+
|
|
20
|
+
def list(
|
|
21
|
+
self, *, params: ProductTypeParams | None = None
|
|
22
|
+
) -> PaginatedResponseBody[ProductType]:
|
|
23
|
+
"""
|
|
24
|
+
Get all the available product types (based on query parameters).
|
|
25
|
+
"""
|
|
26
|
+
response = self._get(self.base_path, params=params)
|
|
27
|
+
return self.process_response(response, PaginatedResponseBody[ProductType])
|
|
28
|
+
|
|
29
|
+
def retrieve(self, /, uuid: str | uuid.UUID) -> ProductType:
|
|
30
|
+
"""
|
|
31
|
+
Get a specific product type based on its uuid.
|
|
32
|
+
"""
|
|
33
|
+
response = self._get(f"{self.base_path}/{uuid!s}")
|
|
34
|
+
return self.process_response(response, ProductType)
|
|
35
|
+
|
|
36
|
+
def create(self, *, data: ProductTypeCreateData) -> ProductType:
|
|
37
|
+
"""
|
|
38
|
+
Create a new product type.
|
|
39
|
+
"""
|
|
40
|
+
response = self._post(self.base_path, data=data)
|
|
41
|
+
return self.process_response(response, ProductType)
|
|
42
|
+
|
|
43
|
+
def partial_update(
|
|
44
|
+
self, /, uuid: str, *, data: ProductTypePartialUpdateData
|
|
45
|
+
) -> ProductType:
|
|
46
|
+
"""
|
|
47
|
+
Partially update a specific product type.
|
|
48
|
+
"""
|
|
49
|
+
response = self._patch(f"{self.base_path}/{uuid!s}", data=data)
|
|
50
|
+
return self.process_response(response, ProductType)
|
|
51
|
+
|
|
52
|
+
def delete(self, /, uuid: str):
|
|
53
|
+
"""
|
|
54
|
+
Delete a specific product type.
|
|
55
|
+
"""
|
|
56
|
+
return self._delete(f"{self.base_path}/{uuid!s}")
|
|
57
|
+
|
|
58
|
+
def list_content(
|
|
59
|
+
self, uuid: str | uuid.UUID, *, params: ContentParams | None = None
|
|
60
|
+
) -> Sequence[NestedContentElement]:
|
|
61
|
+
"""
|
|
62
|
+
Get the content of a specific product type (based on query parameters).
|
|
63
|
+
"""
|
|
64
|
+
response = self._get(f"{self.base_path}/{uuid!s}/content", params=params)
|
|
65
|
+
return self.process_response(response, Sequence[NestedContentElement])
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from typing import ClassVar
|
|
2
|
+
|
|
3
|
+
from ...structs.base import PaginatedResponseBody
|
|
4
|
+
from ...structs.product_type import (
|
|
5
|
+
Theme,
|
|
6
|
+
ThemeParams,
|
|
7
|
+
)
|
|
8
|
+
from ..base import BaseResource
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ThemeResource(BaseResource):
|
|
12
|
+
base_path: ClassVar[str] = "themas"
|
|
13
|
+
|
|
14
|
+
def list(
|
|
15
|
+
self, *, params: ThemeParams | None = None
|
|
16
|
+
) -> PaginatedResponseBody[Theme]:
|
|
17
|
+
"""
|
|
18
|
+
Get all the available themes (based on query parameters).
|
|
19
|
+
"""
|
|
20
|
+
response = self._get(self.base_path, params=params)
|
|
21
|
+
return self.process_response(response, PaginatedResponseBody[Theme])
|
|
File without changes
|