Skip to content
Closed
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
11 changes: 11 additions & 0 deletions mpt_api_client/resources/catalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
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."""
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -28,6 +29,7 @@ def async_catalog(async_http_client):
[
("authorizations", AuthorizationsService),
("price_lists", PriceListsService),
("listings", ListingsService),
("products", ProductsService),
("items", ItemsService),
],
Expand All @@ -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),
],
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)
You are viewing a condensed version of this merge commit. You can view the full changes here.