diff --git a/mpt_api_client/resources/catalog/authorizations.py b/mpt_api_client/resources/catalog/authorizations.py new file mode 100644 index 00000000..dbc1cbda --- /dev/null +++ b/mpt_api_client/resources/catalog/authorizations.py @@ -0,0 +1,42 @@ +from mpt_api_client.http import AsyncService, Service +from mpt_api_client.http.mixins import ( + AsyncCreateMixin, + AsyncDeleteMixin, + AsyncUpdateMixin, + CreateMixin, + DeleteMixin, + UpdateMixin, +) +from mpt_api_client.models import Model + + +class Authorization(Model): + """Authorization resource.""" + + +class AuthorizationsServiceConfig: + """Authorizations service configuration.""" + + _endpoint = "/public/v1/catalog/authorizations" + _model_class = Authorization + _collection_key = "data" + + +class AuthorizationsService( + CreateMixin[Authorization], + DeleteMixin, + UpdateMixin[Authorization], + Service[Authorization], + AuthorizationsServiceConfig, +): + """Authorizations service.""" + + +class AsyncAuthorizationsService( + AsyncCreateMixin[Authorization], + AsyncDeleteMixin, + AsyncUpdateMixin[Authorization], + AsyncService[Authorization], + AuthorizationsServiceConfig, +): + """Authorizations service.""" diff --git a/mpt_api_client/resources/catalog/catalog.py b/mpt_api_client/resources/catalog/catalog.py index 53b61766..999d169c 100644 --- a/mpt_api_client/resources/catalog/catalog.py +++ b/mpt_api_client/resources/catalog/catalog.py @@ -1,4 +1,8 @@ from mpt_api_client.http import AsyncHTTPClient, HTTPClient +from mpt_api_client.resources.catalog.authorizations import ( + AsyncAuthorizationsService, + AuthorizationsService, +) from mpt_api_client.resources.catalog.items import AsyncItemsService, ItemsService from mpt_api_client.resources.catalog.products import AsyncProductsService, ProductsService @@ -9,6 +13,11 @@ class Catalog: def __init__(self, *, http_client: HTTPClient): self.http_client = http_client + @property + def authorizations(self) -> AuthorizationsService: + """Authorizations service.""" + return AuthorizationsService(http_client=self.http_client) + @property def products(self) -> ProductsService: """Products service.""" @@ -26,6 +35,11 @@ class AsyncCatalog: def __init__(self, *, http_client: AsyncHTTPClient): self.http_client = http_client + @property + def authorizations(self) -> AsyncAuthorizationsService: + """Authorizations service.""" + return AsyncAuthorizationsService(http_client=self.http_client) + @property def products(self) -> AsyncProductsService: """Products service.""" diff --git a/setup.cfg b/setup.cfg index e24ef4af..24f1b99a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,6 +33,7 @@ extend-ignore = per-file-ignores = mpt_api_client/rql/query_builder.py: WPS110 WPS115 WPS210 WPS214 + mpt_api_client/resources/catalog/authorizations.py: WPS215 mpt_api_client/resources/catalog/products.py: WPS204 WPS214 WPS215 mpt_api_client/resources/catalog/items.py: WPS215 mpt_api_client/resources/catalog/products_item_groups.py: WPS215 diff --git a/tests/resources/catalog/test_authorizations.py b/tests/resources/catalog/test_authorizations.py new file mode 100644 index 00000000..e8fa0008 --- /dev/null +++ b/tests/resources/catalog/test_authorizations.py @@ -0,0 +1,26 @@ +import pytest + +from mpt_api_client.resources.catalog.authorizations import ( + AsyncAuthorizationsService, + AuthorizationsService, +) + + +@pytest.fixture +def authorizations_service(http_client): + return AuthorizationsService(http_client=http_client) + + +@pytest.fixture +def async_authorizations_service(async_http_client): + return AsyncAuthorizationsService(http_client=async_http_client) + + +@pytest.mark.parametrize("method", ["get", "create", "update", "delete"]) +def test_mixins_present(authorizations_service, method): + assert hasattr(authorizations_service, method) + + +@pytest.mark.parametrize("method", ["get", "create", "update", "delete"]) +def test_async_mixins_present(async_authorizations_service, method): + assert hasattr(async_authorizations_service, method) diff --git a/tests/resources/catalog/test_catalog.py b/tests/resources/catalog/test_catalog.py index 06212d41..4afcfa5e 100644 --- a/tests/resources/catalog/test_catalog.py +++ b/tests/resources/catalog/test_catalog.py @@ -1,5 +1,9 @@ import pytest +from mpt_api_client.resources.catalog.authorizations import ( + AsyncAuthorizationsService, + AuthorizationsService, +) from mpt_api_client.resources.catalog.catalog import AsyncCatalog, Catalog from mpt_api_client.resources.catalog.items import AsyncItemsService, ItemsService from mpt_api_client.resources.catalog.products import AsyncProductsService, ProductsService @@ -18,6 +22,7 @@ def async_catalog(async_http_client): @pytest.mark.parametrize( ("property_name", "expected_service_class"), [ + ("authorizations", AuthorizationsService), ("products", ProductsService), ("items", ItemsService), ], @@ -33,6 +38,7 @@ def test_catalog_properties(catalog, property_name, expected_service_class): @pytest.mark.parametrize( ("property_name", "expected_service_class"), [ + ("authorizations", AsyncAuthorizationsService), ("products", AsyncProductsService), ("items", AsyncItemsService), ],