diff --git a/mpt_api_client/resources/billing/custom_ledger_upload.py b/mpt_api_client/resources/billing/custom_ledger_upload.py new file mode 100644 index 0000000..2c445b3 --- /dev/null +++ b/mpt_api_client/resources/billing/custom_ledger_upload.py @@ -0,0 +1,31 @@ +from mpt_api_client.http import AsyncService, Service +from mpt_api_client.http.mixins import AsyncFileOperationsMixin, FileOperationsMixin +from mpt_api_client.models import Model + + +class CustomLedgerUpload(Model): + """Custom Ledger Upload resource.""" + + +class CustomLedgerUploadServiceConfig: + """Custom Ledger Upload service configuration.""" + + _endpoint = "/public/v1/billing/custom-ledgers/{custom_ledger_id}/upload" + _model_class = CustomLedgerUpload + _collection_key = "data" + + +class CustomLedgerUploadService( + FileOperationsMixin[CustomLedgerUpload], + Service[CustomLedgerUpload], + CustomLedgerUploadServiceConfig, +): + """Custom Ledger Upload service.""" + + +class AsyncCustomLedgerUploadService( + AsyncFileOperationsMixin[CustomLedgerUpload], + AsyncService[CustomLedgerUpload], + CustomLedgerUploadServiceConfig, +): + """Async Custom Ledger Upload service.""" diff --git a/mpt_api_client/resources/billing/custom_ledgers.py b/mpt_api_client/resources/billing/custom_ledgers.py index cd504bb..c24ffbe 100644 --- a/mpt_api_client/resources/billing/custom_ledgers.py +++ b/mpt_api_client/resources/billing/custom_ledgers.py @@ -12,6 +12,10 @@ AsyncCustomLedgerChargesService, CustomLedgerChargesService, ) +from mpt_api_client.resources.billing.custom_ledger_upload import ( + AsyncCustomLedgerUploadService, + CustomLedgerUploadService, +) from mpt_api_client.resources.billing.mixins import AcceptableMixin, AsyncAcceptableMixin @@ -44,6 +48,13 @@ def charges(self, custom_ledger_id: str) -> CustomLedgerChargesService: endpoint_params={"custom_ledger_id": custom_ledger_id}, ) + def upload(self, custom_ledger_id: str) -> CustomLedgerUploadService: + """Get the Custom Ledger Upload service.""" + return CustomLedgerUploadService( + http_client=self.http_client, + endpoint_params={"custom_ledger_id": custom_ledger_id}, + ) + class AsyncCustomLedgersService( AsyncCreateMixin[CustomLedger], @@ -61,3 +72,10 @@ def charges(self, custom_ledger_id: str) -> AsyncCustomLedgerChargesService: http_client=self.http_client, endpoint_params={"custom_ledger_id": custom_ledger_id}, ) + + def upload(self, custom_ledger_id: str) -> AsyncCustomLedgerUploadService: + """Get the Async Custom Ledger Upload service.""" + return AsyncCustomLedgerUploadService( + http_client=self.http_client, + endpoint_params={"custom_ledger_id": custom_ledger_id}, + ) diff --git a/tests/resources/billing/test_custom_ledger_upload.py b/tests/resources/billing/test_custom_ledger_upload.py new file mode 100644 index 0000000..d2fb805 --- /dev/null +++ b/tests/resources/billing/test_custom_ledger_upload.py @@ -0,0 +1,42 @@ +import pytest + +from mpt_api_client.resources.billing.custom_ledger_upload import ( + AsyncCustomLedgerUploadService, + CustomLedgerUploadService, +) + + +@pytest.fixture +def custom_ledger_upload_service(http_client): + return CustomLedgerUploadService( + http_client=http_client, endpoint_params={"custom_ledger_id": "LDG-0000-0001"} + ) + + +@pytest.fixture +def async_custom_ledger_upload_service(http_client): + return AsyncCustomLedgerUploadService( + http_client=http_client, endpoint_params={"custom_ledger_id": "LDG-0000-0001"} + ) + + +def test_endpoint(custom_ledger_upload_service): + assert custom_ledger_upload_service.endpoint == ( + "/public/v1/billing/custom-ledgers/LDG-0000-0001/upload" + ) + + +def test_async_endpoint(async_custom_ledger_upload_service): + assert async_custom_ledger_upload_service.endpoint == ( + "/public/v1/billing/custom-ledgers/LDG-0000-0001/upload" + ) + + +@pytest.mark.parametrize("method", ["create"]) +def test_mixins_present(custom_ledger_upload_service, method): + assert hasattr(custom_ledger_upload_service, method) + + +@pytest.mark.parametrize("method", ["create"]) +def test_async_mixins_present(async_custom_ledger_upload_service, method): + assert hasattr(async_custom_ledger_upload_service, method) diff --git a/tests/resources/billing/test_custom_ledgers.py b/tests/resources/billing/test_custom_ledgers.py index 8348058..9913979 100644 --- a/tests/resources/billing/test_custom_ledgers.py +++ b/tests/resources/billing/test_custom_ledgers.py @@ -4,6 +4,10 @@ AsyncCustomLedgerChargesService, CustomLedgerChargesService, ) +from mpt_api_client.resources.billing.custom_ledger_upload import ( + AsyncCustomLedgerUploadService, + CustomLedgerUploadService, +) from mpt_api_client.resources.billing.custom_ledgers import ( AsyncCustomLedgersService, CustomLedgersService, @@ -34,6 +38,7 @@ def test_async_mixins_present(async_custom_ledgers_service, method): ("service_method", "expected_service_class"), [ ("charges", CustomLedgerChargesService), + ("upload", CustomLedgerUploadService), ], ) def test_property_services(custom_ledgers_service, service_method, expected_service_class): @@ -47,6 +52,7 @@ def test_property_services(custom_ledgers_service, service_method, expected_serv ("service_method", "expected_service_class"), [ ("charges", AsyncCustomLedgerChargesService), + ("upload", AsyncCustomLedgerUploadService), ], ) def test_async_property_services(