diff --git a/mpt_api_client/resources/billing/journal_charges.py b/mpt_api_client/resources/billing/journal_charges.py new file mode 100644 index 00000000..2f0c6903 --- /dev/null +++ b/mpt_api_client/resources/billing/journal_charges.py @@ -0,0 +1,28 @@ +from mpt_api_client.http import AsyncService, Service +from mpt_api_client.models import Model + + +class JournalCharge(Model): + """Journal Charge resource.""" + + +class JournalChargesServiceConfig: + """Journal Charges service configuration.""" + + _endpoint = "/public/v1/billing/journals/{journal_id}/charges" + _model_class = JournalCharge + _collection_key = "data" + + +class JournalChargesService( + Service[JournalCharge], + JournalChargesServiceConfig, +): + """Journal Charges service.""" + + +class AsyncJournalChargesService( + AsyncService[JournalCharge], + JournalChargesServiceConfig, +): + """Async Journal Charges service.""" diff --git a/mpt_api_client/resources/billing/journals.py b/mpt_api_client/resources/billing/journals.py index 121c6c54..58b9d1a6 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_charges import ( + AsyncJournalChargesService, + JournalChargesService, +) from mpt_api_client.resources.billing.journal_sellers import ( AsyncJournalSellersService, JournalSellersService, @@ -53,6 +57,12 @@ def sellers(self, journal_id: str) -> JournalSellersService: http_client=self.http_client, endpoint_params={"journal_id": journal_id} ) + def charges(self, journal_id: str) -> JournalChargesService: + """Return journal charges service.""" + return JournalChargesService( + http_client=self.http_client, endpoint_params={"journal_id": journal_id} + ) + class AsyncJournalsService( AsyncCreateMixin[Journal], @@ -76,3 +86,9 @@ def sellers(self, journal_id: str) -> AsyncJournalSellersService: return AsyncJournalSellersService( http_client=self.http_client, endpoint_params={"journal_id": journal_id} ) + + def charges(self, journal_id: str) -> AsyncJournalChargesService: + """Return journal charges service.""" + return AsyncJournalChargesService( + http_client=self.http_client, endpoint_params={"journal_id": journal_id} + ) diff --git a/mpt_api_client/resources/billing/ledger_attachments.py b/mpt_api_client/resources/billing/ledger_attachments.py new file mode 100644 index 00000000..31252bc8 --- /dev/null +++ b/mpt_api_client/resources/billing/ledger_attachments.py @@ -0,0 +1,42 @@ +from mpt_api_client.http import AsyncService, Service +from mpt_api_client.http.mixins import ( + AsyncDeleteMixin, + AsyncFileOperationsMixin, + AsyncUpdateMixin, + DeleteMixin, + FileOperationsMixin, + UpdateMixin, +) +from mpt_api_client.models import Model + + +class LedgerAttachment(Model): + """Ledger Attachment resource.""" + + +class LedgerAttachmentsServiceConfig: + """Ledger Attachments service configuration.""" + + _endpoint = "/public/v1/billing/ledgers/{ledger_id}/attachments" + _model_class = LedgerAttachment + _collection_key = "data" + + +class LedgerAttachmentsService( + FileOperationsMixin[LedgerAttachment], + DeleteMixin, + UpdateMixin[LedgerAttachment], + Service[LedgerAttachment], + LedgerAttachmentsServiceConfig, +): + """Ledger Attachments service.""" + + +class AsyncLedgerAttachmentsService( + AsyncFileOperationsMixin[LedgerAttachment], + AsyncDeleteMixin, + AsyncUpdateMixin[LedgerAttachment], + AsyncService[LedgerAttachment], + LedgerAttachmentsServiceConfig, +): + """Ledger Attachments service.""" diff --git a/mpt_api_client/resources/billing/ledgers.py b/mpt_api_client/resources/billing/ledgers.py index 63e7ce70..821db938 100644 --- a/mpt_api_client/resources/billing/ledgers.py +++ b/mpt_api_client/resources/billing/ledgers.py @@ -4,6 +4,10 @@ CreateMixin, ) from mpt_api_client.models import Model +from mpt_api_client.resources.billing.ledger_attachments import ( + AsyncLedgerAttachmentsService, + LedgerAttachmentsService, +) from mpt_api_client.resources.billing.ledger_charges import ( AsyncLedgerChargesService, LedgerChargesService, @@ -36,6 +40,13 @@ def charges(self, ledger_id: str) -> LedgerChargesService: endpoint_params={"ledger_id": ledger_id}, ) + def attachments(self, ledger_id: str) -> LedgerAttachmentsService: + """Return ledger attachments service.""" + return LedgerAttachmentsService( + http_client=self.http_client, + endpoint_params={"ledger_id": ledger_id}, + ) + class AsyncLedgersService( AsyncCreateMixin[Ledger], @@ -50,3 +61,10 @@ def charges(self, ledger_id: str) -> AsyncLedgerChargesService: http_client=self.http_client, endpoint_params={"ledger_id": ledger_id}, ) + + def attachments(self, ledger_id: str) -> AsyncLedgerAttachmentsService: + """Return ledger attachments service.""" + return AsyncLedgerAttachmentsService( + http_client=self.http_client, + endpoint_params={"ledger_id": ledger_id}, + ) diff --git a/tests/resources/billing/test_journal_charges.py b/tests/resources/billing/test_journal_charges.py new file mode 100644 index 00000000..675621ce --- /dev/null +++ b/tests/resources/billing/test_journal_charges.py @@ -0,0 +1,40 @@ +import pytest + +from mpt_api_client.resources.billing.journal_charges import ( + AsyncJournalChargesService, + JournalChargesService, +) + + +@pytest.fixture +def journal_charges_service(http_client): + return JournalChargesService( + http_client=http_client, endpoint_params={"journal_id": "JRN-0000-0001"} + ) + + +@pytest.fixture +def async_journal_charges_service(async_http_client): + return AsyncJournalChargesService( + http_client=async_http_client, endpoint_params={"journal_id": "JRN-0000-0001"} + ) + + +def test_endpoint(journal_charges_service): + assert journal_charges_service.endpoint == "/public/v1/billing/journals/JRN-0000-0001/charges" + + +def test_async_endpoint(async_journal_charges_service): + assert async_journal_charges_service.endpoint == ( + "/public/v1/billing/journals/JRN-0000-0001/charges" + ) + + +@pytest.mark.parametrize("method", ["get"]) +def test_methods_present(journal_charges_service, method): + assert hasattr(journal_charges_service, method) + + +@pytest.mark.parametrize("method", ["get"]) +def test_async_methods_present(async_journal_charges_service, method): + assert hasattr(async_journal_charges_service, method) diff --git a/tests/resources/billing/test_journals.py b/tests/resources/billing/test_journals.py index 7ee4b16b..5eba1788 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_charges import ( + AsyncJournalChargesService, + JournalChargesService, +) from mpt_api_client.resources.billing.journal_sellers import ( AsyncJournalSellersService, JournalSellersService, @@ -42,6 +46,7 @@ def test_async_mixins_present(async_journals_service, method): [ ("attachments", JournalAttachmentsService), ("sellers", JournalSellersService), + ("charges", JournalChargesService), ], ) def test_property_services(journals_service, service_method, expected_service_class): @@ -56,6 +61,7 @@ def test_property_services(journals_service, service_method, expected_service_cl [ ("attachments", AsyncJournalAttachmentsService), ("sellers", AsyncJournalSellersService), + ("charges", AsyncJournalChargesService), ], ) def test_async_property_services(async_journals_service, service_method, expected_service_class): diff --git a/tests/resources/billing/test_ledger_attachments.py b/tests/resources/billing/test_ledger_attachments.py new file mode 100644 index 00000000..b33c9445 --- /dev/null +++ b/tests/resources/billing/test_ledger_attachments.py @@ -0,0 +1,44 @@ +import pytest + +from mpt_api_client.resources.billing.ledger_attachments import ( + AsyncLedgerAttachmentsService, + LedgerAttachmentsService, +) + + +@pytest.fixture +def ledger_attachments_service(http_client) -> LedgerAttachmentsService: + return LedgerAttachmentsService( + http_client=http_client, endpoint_params={"ledger_id": "LED-0000-0001"} + ) + + +@pytest.fixture +def async_ledger_attachments_service(async_http_client) -> AsyncLedgerAttachmentsService: + return AsyncLedgerAttachmentsService( + http_client=async_http_client, endpoint_params={"ledger_id": "LED-0000-0001"} + ) + + +def test_endpoint(ledger_attachments_service) -> None: + assert ( + ledger_attachments_service.endpoint + == "/public/v1/billing/ledgers/LED-0000-0001/attachments" + ) + + +def test_async_endpoint(async_ledger_attachments_service) -> None: + assert ( + async_ledger_attachments_service.endpoint + == "/public/v1/billing/ledgers/LED-0000-0001/attachments" + ) + + +@pytest.mark.parametrize("method", ["get", "create", "update", "delete"]) +def test_methods_present(ledger_attachments_service, method: str) -> None: + assert hasattr(ledger_attachments_service, method) + + +@pytest.mark.parametrize("method", ["get", "create", "update", "delete"]) +def test_async_methods_present(async_ledger_attachments_service, method: str) -> None: + assert hasattr(async_ledger_attachments_service, method) diff --git a/tests/resources/billing/test_ledgers.py b/tests/resources/billing/test_ledgers.py index 04e0a6c5..358037c0 100644 --- a/tests/resources/billing/test_ledgers.py +++ b/tests/resources/billing/test_ledgers.py @@ -1,5 +1,9 @@ import pytest +from mpt_api_client.resources.billing.ledger_attachments import ( + AsyncLedgerAttachmentsService, + LedgerAttachmentsService, +) from mpt_api_client.resources.billing.ledger_charges import ( AsyncLedgerChargesService, LedgerChargesService, @@ -37,6 +41,7 @@ def test_async_mixins_present(async_ledgers_service, method): ("service_method", "expected_service_class"), [ ("charges", LedgerChargesService), + ("attachments", LedgerAttachmentsService), ], ) def test_property_services(ledgers_service, service_method, expected_service_class): @@ -50,6 +55,7 @@ def test_property_services(ledgers_service, service_method, expected_service_cla ("service_method", "expected_service_class"), [ ("charges", AsyncLedgerChargesService), + ("attachments", AsyncLedgerAttachmentsService), ], ) def test_async_property_services(async_ledgers_service, service_method, expected_service_class):