diff --git a/mpt_api_client/mpt_client.py b/mpt_api_client/mpt_client.py index 633e3168..7e7af763 100644 --- a/mpt_api_client/mpt_client.py +++ b/mpt_api_client/mpt_client.py @@ -1,7 +1,16 @@ from typing import Self from mpt_api_client.http import AsyncHTTPClient, HTTPClient -from mpt_api_client.resources import AsyncCatalog, AsyncCommerce, Catalog, Commerce +from mpt_api_client.resources import ( + AsyncAudit, + AsyncBilling, + AsyncCatalog, + AsyncCommerce, + Audit, + Billing, + Catalog, + Commerce, +) class AsyncMPTClient: @@ -37,6 +46,16 @@ def commerce(self) -> AsyncCommerce: """Commerce MPT API Client.""" return AsyncCommerce(http_client=self.http_client) + @property + def audit(self) -> AsyncAudit: + """Audit MPT API Client.""" + return AsyncAudit(http_client=self.http_client) + + @property + def billing(self) -> AsyncBilling: + """Billing MPT API Client.""" + return AsyncBilling(http_client=self.http_client) + class MPTClient: """MPT API Client.""" @@ -75,3 +94,13 @@ def commerce(self) -> Commerce: def catalog(self) -> Catalog: """Catalog MPT API Client.""" return Catalog(http_client=self.http_client) + + @property + def audit(self) -> Audit: + """Audit MPT API Client.""" + return Audit(http_client=self.http_client) + + @property + def billing(self) -> Billing: + """Billing MPT API Client.""" + return Billing(http_client=self.http_client) diff --git a/mpt_api_client/resources/__init__.py b/mpt_api_client/resources/__init__.py index b75c3cf6..6d0b9302 100644 --- a/mpt_api_client/resources/__init__.py +++ b/mpt_api_client/resources/__init__.py @@ -1,4 +1,15 @@ +from mpt_api_client.resources.audit import AsyncAudit, Audit +from mpt_api_client.resources.billing import AsyncBilling, Billing from mpt_api_client.resources.catalog import AsyncCatalog, Catalog from mpt_api_client.resources.commerce import AsyncCommerce, Commerce -__all__ = ["AsyncCatalog", "AsyncCommerce", "Catalog", "Commerce"] # noqa: WPS410 +__all__ = [ # noqa: WPS410 + "AsyncAudit", + "AsyncBilling", + "AsyncCatalog", + "AsyncCommerce", + "Audit", + "Billing", + "Catalog", + "Commerce", +] diff --git a/mpt_api_client/resources/audit/__init__.py b/mpt_api_client/resources/audit/__init__.py new file mode 100644 index 00000000..8938da3e --- /dev/null +++ b/mpt_api_client/resources/audit/__init__.py @@ -0,0 +1,3 @@ +from mpt_api_client.resources.audit.audit import AsyncAudit, Audit + +__all__ = ["AsyncAudit", "Audit"] # noqa: WPS410 diff --git a/mpt_api_client/resources/audit/audit.py b/mpt_api_client/resources/audit/audit.py index a560ca54..e29abcc6 100644 --- a/mpt_api_client/resources/audit/audit.py +++ b/mpt_api_client/resources/audit/audit.py @@ -1,4 +1,8 @@ from mpt_api_client.http import AsyncHTTPClient, HTTPClient +from mpt_api_client.resources.audit.event_types import ( + AsyncEventTypesService, + EventTypesService, +) from mpt_api_client.resources.audit.records import AsyncRecordsService, RecordsService @@ -13,6 +17,11 @@ def records(self) -> RecordsService: """Records service.""" return RecordsService(http_client=self.http_client) + @property + def event_types(self) -> EventTypesService: + """Event Types service.""" + return EventTypesService(http_client=self.http_client) + class AsyncAudit: """Async Audit MPT API Module.""" @@ -24,3 +33,8 @@ def __init__(self, *, http_client: AsyncHTTPClient): def records(self) -> AsyncRecordsService: """Records service.""" return AsyncRecordsService(http_client=self.http_client) + + @property + def event_types(self) -> AsyncEventTypesService: + """Event Types service.""" + return AsyncEventTypesService(http_client=self.http_client) diff --git a/mpt_api_client/resources/audit/event_types.py b/mpt_api_client/resources/audit/event_types.py new file mode 100644 index 00000000..d9f30911 --- /dev/null +++ b/mpt_api_client/resources/audit/event_types.py @@ -0,0 +1,28 @@ +from mpt_api_client.http import AsyncService, Service +from mpt_api_client.http.mixins import ( + AsyncUpdateMixin, + UpdateMixin, +) +from mpt_api_client.models import Model + + +class EventType(Model): + """Event Type resource.""" + + +class EventTypesServiceConfig: + """Event Types service configuration.""" + + _endpoint = "/public/v1/audit/event-types" + _model_class = EventType + _collection_key = "data" + + +class EventTypesService(UpdateMixin[EventType], Service[EventType], EventTypesServiceConfig): + """Event Types service.""" + + +class AsyncEventTypesService( + AsyncUpdateMixin[EventType], AsyncService[EventType], EventTypesServiceConfig +): + """Async Event Types service.""" diff --git a/mpt_api_client/resources/billing/__init__.py b/mpt_api_client/resources/billing/__init__.py index e69de29b..4d1cb705 100644 --- a/mpt_api_client/resources/billing/__init__.py +++ b/mpt_api_client/resources/billing/__init__.py @@ -0,0 +1,3 @@ +from mpt_api_client.resources.billing.billing import AsyncBilling, Billing + +__all__ = ["AsyncBilling", "Billing"] # noqa: WPS410 diff --git a/tests/resources/audit/test_audit.py b/tests/resources/audit/test_audit.py index 06c24fde..58d37723 100644 --- a/tests/resources/audit/test_audit.py +++ b/tests/resources/audit/test_audit.py @@ -1,6 +1,7 @@ import pytest from mpt_api_client.resources.audit.audit import AsyncAudit, Audit +from mpt_api_client.resources.audit.event_types import AsyncEventTypesService, EventTypesService from mpt_api_client.resources.audit.records import AsyncRecordsService, RecordsService @@ -18,6 +19,7 @@ def async_audit(async_http_client): ("property_name", "expected_service_class"), [ ("records", RecordsService), + ("event_types", EventTypesService), ], ) def test_audit_properties(audit, property_name, expected_service_class): @@ -32,6 +34,7 @@ def test_audit_properties(audit, property_name, expected_service_class): ("property_name", "expected_service_class"), [ ("records", AsyncRecordsService), + ("event_types", AsyncEventTypesService), ], ) def test_async_audit_properties(async_audit, property_name, expected_service_class): diff --git a/tests/resources/audit/test_event_types.py b/tests/resources/audit/test_event_types.py new file mode 100644 index 00000000..1bb5bc1d --- /dev/null +++ b/tests/resources/audit/test_event_types.py @@ -0,0 +1,23 @@ +import pytest + +from mpt_api_client.resources.audit.event_types import AsyncEventTypesService, EventTypesService + + +@pytest.fixture +def event_types_service(http_client): + return EventTypesService(http_client=http_client) + + +@pytest.fixture +def async_event_types_service(async_http_client): + return AsyncEventTypesService(http_client=async_http_client) + + +@pytest.mark.parametrize("method", ["get", "update"]) +def test_mixins_present(event_types_service, method): + assert hasattr(event_types_service, method) + + +@pytest.mark.parametrize("method", ["get", "update"]) +def test_async_mixins_present(async_event_types_service, method): + assert hasattr(async_event_types_service, method) diff --git a/tests/test_mpt.py b/tests/test_mpt.py index 096766c3..bf39c59c 100644 --- a/tests/test_mpt.py +++ b/tests/test_mpt.py @@ -2,7 +2,16 @@ from mpt_api_client.http import AsyncHTTPClient, HTTPClient from mpt_api_client.mpt_client import AsyncMPTClient, MPTClient -from mpt_api_client.resources import AsyncCatalog, AsyncCommerce, Catalog, Commerce +from mpt_api_client.resources import ( + AsyncAudit, + AsyncBilling, + AsyncCatalog, + AsyncCommerce, + Audit, + Billing, + Catalog, + Commerce, +) from tests.conftest import API_TOKEN, API_URL @@ -10,10 +19,14 @@ def test_mpt_client() -> None: mpt = MPTClient.from_config(base_url=API_URL, api_token=API_TOKEN) commerce = mpt.commerce catalog = mpt.catalog + audit = mpt.audit + billing = mpt.billing assert isinstance(mpt, MPTClient) assert isinstance(commerce, Commerce) assert isinstance(catalog, Catalog) + assert isinstance(audit, Audit) + assert isinstance(billing, Billing) def test_mpt_client_env(monkeypatch: pytest.MonkeyPatch) -> None: @@ -30,10 +43,14 @@ def test_async_mpt_client() -> None: mpt = AsyncMPTClient.from_config(base_url=API_URL, api_token=API_TOKEN) commerce = mpt.commerce catalog = mpt.catalog + audit = mpt.audit + billing = mpt.billing assert isinstance(mpt, AsyncMPTClient) assert isinstance(commerce, AsyncCommerce) assert isinstance(catalog, AsyncCatalog) + assert isinstance(audit, AsyncAudit) + assert isinstance(billing, AsyncBilling) def test_async_mpt_client_env(monkeypatch: pytest.MonkeyPatch) -> None: