diff --git a/mpt_api_client/resources/billing/custom_ledger_attachments.py b/mpt_api_client/resources/billing/custom_ledger_attachments.py new file mode 100644 index 00000000..bbc4454b --- /dev/null +++ b/mpt_api_client/resources/billing/custom_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 CustomLedgerAttachment(Model): + """Custom Ledger Attachment resource.""" + + +class CustomLedgerAttachmentsServiceConfig: + """Custom Ledger Attachments service configuration.""" + + _endpoint = "/public/v1/billing/custom-ledgers/{custom_ledger_id}/attachments" + _model_class = CustomLedgerAttachment + _collection_key = "data" + + +class CustomLedgerAttachmentsService( + FileOperationsMixin[CustomLedgerAttachment], + DeleteMixin, + UpdateMixin[CustomLedgerAttachment], + Service[CustomLedgerAttachment], + CustomLedgerAttachmentsServiceConfig, +): + """Custom Ledger Attachments service.""" + + +class AsyncCustomLedgerAttachmentsService( + AsyncFileOperationsMixin[CustomLedgerAttachment], + AsyncDeleteMixin, + AsyncUpdateMixin[CustomLedgerAttachment], + AsyncService[CustomLedgerAttachment], + CustomLedgerAttachmentsServiceConfig, +): + """Custom Ledger Attachments service.""" diff --git a/mpt_api_client/resources/billing/custom_ledgers.py b/mpt_api_client/resources/billing/custom_ledgers.py index c24ffbec..70206e59 100644 --- a/mpt_api_client/resources/billing/custom_ledgers.py +++ b/mpt_api_client/resources/billing/custom_ledgers.py @@ -8,6 +8,10 @@ UpdateMixin, ) from mpt_api_client.models import Model +from mpt_api_client.resources.billing.custom_ledger_attachments import ( + AsyncCustomLedgerAttachmentsService, + CustomLedgerAttachmentsService, +) from mpt_api_client.resources.billing.custom_ledger_charges import ( AsyncCustomLedgerChargesService, CustomLedgerChargesService, @@ -55,6 +59,13 @@ def upload(self, custom_ledger_id: str) -> CustomLedgerUploadService: endpoint_params={"custom_ledger_id": custom_ledger_id}, ) + def attachments(self, custom_ledger_id: str) -> CustomLedgerAttachmentsService: + """Return custom ledger attachments service.""" + return CustomLedgerAttachmentsService( + http_client=self.http_client, + endpoint_params={"custom_ledger_id": custom_ledger_id}, + ) + class AsyncCustomLedgersService( AsyncCreateMixin[CustomLedger], @@ -79,3 +90,10 @@ def upload(self, custom_ledger_id: str) -> AsyncCustomLedgerUploadService: http_client=self.http_client, endpoint_params={"custom_ledger_id": custom_ledger_id}, ) + + def attachments(self, custom_ledger_id: str) -> AsyncCustomLedgerAttachmentsService: + """Return custom ledger attachments service.""" + return AsyncCustomLedgerAttachmentsService( + http_client=self.http_client, + endpoint_params={"custom_ledger_id": custom_ledger_id}, + ) diff --git a/tests/resources/billing/test_custom_ledger_attachments.py b/tests/resources/billing/test_custom_ledger_attachments.py new file mode 100644 index 00000000..320abffd --- /dev/null +++ b/tests/resources/billing/test_custom_ledger_attachments.py @@ -0,0 +1,42 @@ +import pytest + +from mpt_api_client.resources.billing.custom_ledger_attachments import ( + AsyncCustomLedgerAttachmentsService, + CustomLedgerAttachmentsService, +) + + +@pytest.fixture +def custom_ledger_attachments_service(http_client): + return CustomLedgerAttachmentsService( + http_client=http_client, endpoint_params={"custom_ledger_id": "LDG-0000-0001"} + ) + + +@pytest.fixture +def async_custom_ledger_attachments_service(async_http_client): + return AsyncCustomLedgerAttachmentsService( + http_client=async_http_client, endpoint_params={"custom_ledger_id": "LDG-0000-0001"} + ) + + +def test_endpoint(custom_ledger_attachments_service): + assert custom_ledger_attachments_service.endpoint == ( + "/public/v1/billing/custom-ledgers/LDG-0000-0001/attachments" + ) + + +def test_async_endpoint(async_custom_ledger_attachments_service): + assert async_custom_ledger_attachments_service.endpoint == ( + "/public/v1/billing/custom-ledgers/LDG-0000-0001/attachments" + ) + + +@pytest.mark.parametrize("method", ["get", "create", "update", "delete"]) +def test_methods_present(custom_ledger_attachments_service, method: str): + assert hasattr(custom_ledger_attachments_service, method) + + +@pytest.mark.parametrize("method", ["get", "create", "update", "delete"]) +def test_async_methods_present(async_custom_ledger_attachments_service, method: str): + assert hasattr(async_custom_ledger_attachments_service, method) diff --git a/tests/resources/billing/test_custom_ledgers.py b/tests/resources/billing/test_custom_ledgers.py index 9913979d..ba56c772 100644 --- a/tests/resources/billing/test_custom_ledgers.py +++ b/tests/resources/billing/test_custom_ledgers.py @@ -1,5 +1,9 @@ import pytest +from mpt_api_client.resources.billing.custom_ledger_attachments import ( + AsyncCustomLedgerAttachmentsService, + CustomLedgerAttachmentsService, +) from mpt_api_client.resources.billing.custom_ledger_charges import ( AsyncCustomLedgerChargesService, CustomLedgerChargesService, @@ -39,6 +43,7 @@ def test_async_mixins_present(async_custom_ledgers_service, method): [ ("charges", CustomLedgerChargesService), ("upload", CustomLedgerUploadService), + ("attachments", CustomLedgerAttachmentsService), ], ) def test_property_services(custom_ledgers_service, service_method, expected_service_class): @@ -53,6 +58,7 @@ def test_property_services(custom_ledgers_service, service_method, expected_serv [ ("charges", AsyncCustomLedgerChargesService), ("upload", AsyncCustomLedgerUploadService), + ("attachments", AsyncCustomLedgerAttachmentsService), ], ) def test_async_property_services(