From 28b9cc445f41655455c074614041f41eda902a07 Mon Sep 17 00:00:00 2001 From: Robert Segal Date: Fri, 26 Sep 2025 09:13:03 -0600 Subject: [PATCH] Added billing journal sellers endpoint --- .../resources/billing/journal_sellers.py | 28 +++++++++++++ mpt_api_client/resources/billing/journals.py | 16 ++++++++ .../resources/billing/test_journal_sellers.py | 41 +++++++++++++++++++ tests/resources/billing/test_journals.py | 6 +++ 4 files changed, 91 insertions(+) create mode 100644 mpt_api_client/resources/billing/journal_sellers.py create mode 100644 tests/resources/billing/test_journal_sellers.py diff --git a/mpt_api_client/resources/billing/journal_sellers.py b/mpt_api_client/resources/billing/journal_sellers.py new file mode 100644 index 00000000..64f51a4d --- /dev/null +++ b/mpt_api_client/resources/billing/journal_sellers.py @@ -0,0 +1,28 @@ +from mpt_api_client.http import AsyncService, Service +from mpt_api_client.models import Model + + +class JournalSeller(Model): + """Journal Seller resource.""" + + +class JournalSellersServiceConfig: + """Journal Sellers service configuration.""" + + _endpoint = "/public/v1/billing/journals/{journal_id}/sellers" + _model_class = JournalSeller + _collection_key = "data" + + +class JournalSellersService( + Service[JournalSeller], + JournalSellersServiceConfig, +): + """Journal Sellers service.""" + + +class AsyncJournalSellersService( + AsyncService[JournalSeller], + JournalSellersServiceConfig, +): + """Async Journal Sellers service.""" diff --git a/mpt_api_client/resources/billing/journals.py b/mpt_api_client/resources/billing/journals.py index 0c1b7b54..121c6c54 100644 --- a/mpt_api_client/resources/billing/journals.py +++ b/mpt_api_client/resources/billing/journals.py @@ -11,6 +11,10 @@ AsyncJournalAttachmentsService, JournalAttachmentsService, ) +from mpt_api_client.resources.billing.journal_sellers import ( + AsyncJournalSellersService, + JournalSellersService, +) from mpt_api_client.resources.billing.mixins import AsyncRegeneratableMixin, RegeneratableMixin @@ -43,6 +47,12 @@ def attachments(self, journal_id: str) -> JournalAttachmentsService: endpoint_params={"journal_id": journal_id}, ) + def sellers(self, journal_id: str) -> JournalSellersService: + """Return journal sellers service.""" + return JournalSellersService( + http_client=self.http_client, endpoint_params={"journal_id": journal_id} + ) + class AsyncJournalsService( AsyncCreateMixin[Journal], @@ -60,3 +70,9 @@ def attachments(self, journal_id: str) -> AsyncJournalAttachmentsService: http_client=self.http_client, endpoint_params={"journal_id": journal_id}, ) + + def sellers(self, journal_id: str) -> AsyncJournalSellersService: + """Return journal sellers service.""" + return AsyncJournalSellersService( + http_client=self.http_client, endpoint_params={"journal_id": journal_id} + ) diff --git a/tests/resources/billing/test_journal_sellers.py b/tests/resources/billing/test_journal_sellers.py new file mode 100644 index 00000000..9678525c --- /dev/null +++ b/tests/resources/billing/test_journal_sellers.py @@ -0,0 +1,41 @@ +import pytest + +from mpt_api_client.resources.billing.journal_sellers import ( + AsyncJournalSellersService, + JournalSellersService, +) + + +@pytest.fixture +def journal_sellers_service(http_client): + return JournalSellersService( + http_client=http_client, endpoint_params={"journal_id": "JRN-0000-0001"} + ) + + +@pytest.fixture +def async_journal_sellers_service(async_http_client): + return AsyncJournalSellersService( + http_client=async_http_client, endpoint_params={"journal_id": "JRN-0000-0001"} + ) + + +def test_endpoint(journal_sellers_service): + assert journal_sellers_service.endpoint == "/public/v1/billing/journals/JRN-0000-0001/sellers" + + +def test_async_endpoint(async_journal_sellers_service): + assert ( + async_journal_sellers_service.endpoint + == "/public/v1/billing/journals/JRN-0000-0001/sellers" + ) + + +@pytest.mark.parametrize("method", ["get"]) +def test_methods_present(journal_sellers_service, method): + assert hasattr(journal_sellers_service, method) + + +@pytest.mark.parametrize("method", ["get"]) +def test_async_methods_present(async_journal_sellers_service, method): + assert hasattr(async_journal_sellers_service, method) diff --git a/tests/resources/billing/test_journals.py b/tests/resources/billing/test_journals.py index 8018d832..7ee4b16b 100644 --- a/tests/resources/billing/test_journals.py +++ b/tests/resources/billing/test_journals.py @@ -4,6 +4,10 @@ AsyncJournalAttachmentsService, JournalAttachmentsService, ) +from mpt_api_client.resources.billing.journal_sellers import ( + AsyncJournalSellersService, + JournalSellersService, +) from mpt_api_client.resources.billing.journals import AsyncJournalsService, JournalsService @@ -37,6 +41,7 @@ def test_async_mixins_present(async_journals_service, method): ("service_method", "expected_service_class"), [ ("attachments", JournalAttachmentsService), + ("sellers", JournalSellersService), ], ) def test_property_services(journals_service, service_method, expected_service_class): @@ -50,6 +55,7 @@ def test_property_services(journals_service, service_method, expected_service_cl ("service_method", "expected_service_class"), [ ("attachments", AsyncJournalAttachmentsService), + ("sellers", AsyncJournalSellersService), ], ) def test_async_property_services(async_journals_service, service_method, expected_service_class):