diff --git a/mpt_api_client/resources/catalog/catalog.py b/mpt_api_client/resources/catalog/catalog.py index f7d597d7..6db510e7 100644 --- a/mpt_api_client/resources/catalog/catalog.py +++ b/mpt_api_client/resources/catalog/catalog.py @@ -4,6 +4,7 @@ AuthorizationsService, ) from mpt_api_client.resources.catalog.items import AsyncItemsService, ItemsService +from mpt_api_client.resources.catalog.listings import AsyncListingsService, ListingsService from mpt_api_client.resources.catalog.price_list_items import ( AsyncPriceListItemsService, PriceListItemsService, @@ -37,6 +38,11 @@ def price_lists(self) -> PriceListsService: """Price Lists service.""" return PriceListsService(http_client=self.http_client) + @property + def listings(self) -> ListingsService: + """Listings service.""" + return ListingsService(http_client=self.http_client) + @property def products(self) -> ProductsService: """Products service.""" @@ -70,6 +76,11 @@ def price_lists(self) -> AsyncPriceListsService: """Price Lists service.""" return AsyncPriceListsService(http_client=self.http_client) + @property + def listings(self) -> AsyncListingsService: + """Listings service.""" + return AsyncListingsService(http_client=self.http_client) + @property def products(self) -> AsyncProductsService: """Products service.""" diff --git a/mpt_api_client/resources/catalog/listings.py b/mpt_api_client/resources/catalog/listings.py new file mode 100644 index 00000000..dafbcfa5 --- /dev/null +++ b/mpt_api_client/resources/catalog/listings.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 Listing(Model): + """Listing resource.""" + + +class ListingsServiceConfig: + """Listings service configuration.""" + + _endpoint = "/public/v1/catalog/listings" + _model_class = Listing + _collection_key = "data" + + +class ListingsService( + CreateMixin[Listing], + DeleteMixin, + UpdateMixin[Listing], + Service[Listing], + ListingsServiceConfig, +): + """Listings service.""" + + +class AsyncListingsService( + AsyncCreateMixin[Listing], + AsyncDeleteMixin, + AsyncUpdateMixin[Listing], + AsyncService[Listing], + ListingsServiceConfig, +): + """Listings service.""" diff --git a/setup.cfg b/setup.cfg index b4d1ad07..c4579c9a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,6 +38,7 @@ per-file-ignores = mpt_api_client/resources/catalog/items.py: WPS215 mpt_api_client/resources/catalog/price_lists.py: WPS215 WPS110 mpt_api_client/resources/catalog/price_list_items.py: WPS215 + mpt_api_client/resources/catalog/listings.py: WPS215 mpt_api_client/resources/catalog/products_item_groups.py: WPS215 mpt_api_client/resources/catalog/products_parameter_groups.py: WPS215 mpt_api_client/resources/catalog/products_parameters.py: WPS215 diff --git a/tests/resources/catalog/test_catalog.py b/tests/resources/catalog/test_catalog.py index cc7526b4..8ac4cbf2 100644 --- a/tests/resources/catalog/test_catalog.py +++ b/tests/resources/catalog/test_catalog.py @@ -6,6 +6,7 @@ ) 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.listings import AsyncListingsService, ListingsService from mpt_api_client.resources.catalog.price_lists import ( AsyncPriceListsService, PriceListsService, @@ -28,6 +29,7 @@ def async_catalog(async_http_client): [ ("authorizations", AuthorizationsService), ("price_lists", PriceListsService), + ("listings", ListingsService), ("products", ProductsService), ("items", ItemsService), ], @@ -45,6 +47,7 @@ def test_catalog_properties(catalog, property_name, expected_service_class): [ ("authorizations", AsyncAuthorizationsService), ("price_lists", AsyncPriceListsService), + ("listings", AsyncListingsService), ("products", AsyncProductsService), ("items", AsyncItemsService), ], diff --git a/tests/resources/catalog/test_listings.py b/tests/resources/catalog/test_listings.py new file mode 100644 index 00000000..7c0d524c --- /dev/null +++ b/tests/resources/catalog/test_listings.py @@ -0,0 +1,26 @@ +import pytest + +from mpt_api_client.resources.catalog.listings import ( + AsyncListingsService, + ListingsService, +) + + +@pytest.fixture +def listings_service(http_client): + return ListingsService(http_client=http_client) + + +@pytest.fixture +def async_listings_service(async_http_client): + return AsyncListingsService(http_client=async_http_client) + + +@pytest.mark.parametrize("method", ["get", "create", "update", "delete"]) +def test_mixins_present(listings_service, method): + assert hasattr(listings_service, method) + + +@pytest.mark.parametrize("method", ["get", "create", "update", "delete"]) +def test_async_mixins_present(async_listings_service, method): + assert hasattr(async_listings_service, method)