Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions mpt_api_client/resources/catalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
AuthorizationsService,
)
from mpt_api_client.resources.catalog.items import AsyncItemsService, ItemsService
from mpt_api_client.resources.catalog.price_list_items import (
AsyncPriceListItemsService,
PriceListItemsService,
)
from mpt_api_client.resources.catalog.listings import AsyncListingsService, ListingsService
from mpt_api_client.resources.catalog.price_lists import (
AsyncPriceListsService,
PriceListsService,
Expand All @@ -26,11 +23,10 @@ def authorizations(self) -> AuthorizationsService:
"""Authorizations service."""
return AuthorizationsService(http_client=self.http_client)

def price_list_items(self, price_list_id: str) -> PriceListItemsService:
"""Price List Items service."""
return PriceListItemsService(
http_client=self.http_client, endpoint_params={"price_list_id": price_list_id}
)
@property
def listings(self) -> ListingsService:
"""Listings service."""
return ListingsService(http_client=self.http_client)

@property
def price_lists(self) -> PriceListsService:
Expand Down Expand Up @@ -59,11 +55,10 @@ def authorizations(self) -> AsyncAuthorizationsService:
"""Authorizations service."""
return AsyncAuthorizationsService(http_client=self.http_client)

def price_list_items(self, price_list_id: str) -> AsyncPriceListItemsService:
"""Price List Items service."""
return AsyncPriceListItemsService(
http_client=self.http_client, endpoint_params={"price_list_id": price_list_id}
)
@property
def listings(self) -> AsyncListingsService:
"""Listings service."""
return AsyncListingsService(http_client=self.http_client)

@property
def price_lists(self) -> AsyncPriceListsService:
Expand Down
42 changes: 42 additions & 0 deletions mpt_api_client/resources/catalog/listings.py
Original file line number Diff line number Diff line change
@@ -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."""
15 changes: 2 additions & 13 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,10 @@ extend-ignore =


per-file-ignores =
mpt_api_client/resources/catalog/*.py: WPS110 WPS215
mpt_api_client/resources/commerce/*.py: WPS215
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/price_lists.py: WPS215 WPS110
mpt_api_client/resources/catalog/price_list_items.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
mpt_api_client/resources/catalog/products_media.py: WPS215
mpt_api_client/resources/catalog/products_documents.py: WPS215
mpt_api_client/resources/catalog/products_templates.py: WPS215
mpt_api_client/resources/catalog/product_terms.py: WPS215
mpt_api_client/resources/catalog/product_term_variants.py: WPS215
mpt_api_client/resources/commerce/agreements_attachments.py: WPS215
mpt_api_client/http/mixins.py: WPS202
tests/http/test_async_service.py: WPS204 WPS202
tests/http/test_service.py: WPS204 WPS202
Expand Down
3 changes: 3 additions & 0 deletions tests/resources/catalog/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -27,6 +28,7 @@ def async_catalog(async_http_client):
("property_name", "expected_service_class"),
[
("authorizations", AuthorizationsService),
("listings", ListingsService),
("price_lists", PriceListsService),
("products", ProductsService),
("items", ItemsService),
Expand All @@ -44,6 +46,7 @@ def test_catalog_properties(catalog, property_name, expected_service_class):
("property_name", "expected_service_class"),
[
("authorizations", AsyncAuthorizationsService),
("listings", AsyncListingsService),
("price_lists", AsyncPriceListsService),
("products", AsyncProductsService),
("items", AsyncItemsService),
Expand Down
26 changes: 26 additions & 0 deletions tests/resources/catalog/test_listings.py
Original file line number Diff line number Diff line change
@@ -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)