Skip to content

Commit 16f0c8f

Browse files
authored
[MPT-13837] Added custom ledger upload endpoint (#65)
Added custom ledger upload endpoint https://softwareone.atlassian.net/browse/MPT-13837
2 parents a503cfb + 7bbe80d commit 16f0c8f

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.http.mixins import AsyncFileOperationsMixin, FileOperationsMixin
3+
from mpt_api_client.models import Model
4+
5+
6+
class CustomLedgerUpload(Model):
7+
"""Custom Ledger Upload resource."""
8+
9+
10+
class CustomLedgerUploadServiceConfig:
11+
"""Custom Ledger Upload service configuration."""
12+
13+
_endpoint = "/public/v1/billing/custom-ledgers/{custom_ledger_id}/upload"
14+
_model_class = CustomLedgerUpload
15+
_collection_key = "data"
16+
17+
18+
class CustomLedgerUploadService(
19+
FileOperationsMixin[CustomLedgerUpload],
20+
Service[CustomLedgerUpload],
21+
CustomLedgerUploadServiceConfig,
22+
):
23+
"""Custom Ledger Upload service."""
24+
25+
26+
class AsyncCustomLedgerUploadService(
27+
AsyncFileOperationsMixin[CustomLedgerUpload],
28+
AsyncService[CustomLedgerUpload],
29+
CustomLedgerUploadServiceConfig,
30+
):
31+
"""Async Custom Ledger Upload service."""

mpt_api_client/resources/billing/custom_ledgers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
AsyncCustomLedgerChargesService,
1313
CustomLedgerChargesService,
1414
)
15+
from mpt_api_client.resources.billing.custom_ledger_upload import (
16+
AsyncCustomLedgerUploadService,
17+
CustomLedgerUploadService,
18+
)
1519
from mpt_api_client.resources.billing.mixins import AcceptableMixin, AsyncAcceptableMixin
1620

1721

@@ -44,6 +48,13 @@ def charges(self, custom_ledger_id: str) -> CustomLedgerChargesService:
4448
endpoint_params={"custom_ledger_id": custom_ledger_id},
4549
)
4650

51+
def upload(self, custom_ledger_id: str) -> CustomLedgerUploadService:
52+
"""Get the Custom Ledger Upload service."""
53+
return CustomLedgerUploadService(
54+
http_client=self.http_client,
55+
endpoint_params={"custom_ledger_id": custom_ledger_id},
56+
)
57+
4758

4859
class AsyncCustomLedgersService(
4960
AsyncCreateMixin[CustomLedger],
@@ -61,3 +72,10 @@ def charges(self, custom_ledger_id: str) -> AsyncCustomLedgerChargesService:
6172
http_client=self.http_client,
6273
endpoint_params={"custom_ledger_id": custom_ledger_id},
6374
)
75+
76+
def upload(self, custom_ledger_id: str) -> AsyncCustomLedgerUploadService:
77+
"""Get the Async Custom Ledger Upload service."""
78+
return AsyncCustomLedgerUploadService(
79+
http_client=self.http_client,
80+
endpoint_params={"custom_ledger_id": custom_ledger_id},
81+
)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import pytest
2+
3+
from mpt_api_client.resources.billing.custom_ledger_upload import (
4+
AsyncCustomLedgerUploadService,
5+
CustomLedgerUploadService,
6+
)
7+
8+
9+
@pytest.fixture
10+
def custom_ledger_upload_service(http_client):
11+
return CustomLedgerUploadService(
12+
http_client=http_client, endpoint_params={"custom_ledger_id": "LDG-0000-0001"}
13+
)
14+
15+
16+
@pytest.fixture
17+
def async_custom_ledger_upload_service(http_client):
18+
return AsyncCustomLedgerUploadService(
19+
http_client=http_client, endpoint_params={"custom_ledger_id": "LDG-0000-0001"}
20+
)
21+
22+
23+
def test_endpoint(custom_ledger_upload_service):
24+
assert custom_ledger_upload_service.endpoint == (
25+
"/public/v1/billing/custom-ledgers/LDG-0000-0001/upload"
26+
)
27+
28+
29+
def test_async_endpoint(async_custom_ledger_upload_service):
30+
assert async_custom_ledger_upload_service.endpoint == (
31+
"/public/v1/billing/custom-ledgers/LDG-0000-0001/upload"
32+
)
33+
34+
35+
@pytest.mark.parametrize("method", ["create"])
36+
def test_mixins_present(custom_ledger_upload_service, method):
37+
assert hasattr(custom_ledger_upload_service, method)
38+
39+
40+
@pytest.mark.parametrize("method", ["create"])
41+
def test_async_mixins_present(async_custom_ledger_upload_service, method):
42+
assert hasattr(async_custom_ledger_upload_service, method)

tests/resources/billing/test_custom_ledgers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
AsyncCustomLedgerChargesService,
55
CustomLedgerChargesService,
66
)
7+
from mpt_api_client.resources.billing.custom_ledger_upload import (
8+
AsyncCustomLedgerUploadService,
9+
CustomLedgerUploadService,
10+
)
711
from mpt_api_client.resources.billing.custom_ledgers import (
812
AsyncCustomLedgersService,
913
CustomLedgersService,
@@ -34,6 +38,7 @@ def test_async_mixins_present(async_custom_ledgers_service, method):
3438
("service_method", "expected_service_class"),
3539
[
3640
("charges", CustomLedgerChargesService),
41+
("upload", CustomLedgerUploadService),
3742
],
3843
)
3944
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
4752
("service_method", "expected_service_class"),
4853
[
4954
("charges", AsyncCustomLedgerChargesService),
55+
("upload", AsyncCustomLedgerUploadService),
5056
],
5157
)
5258
def test_async_property_services(

0 commit comments

Comments
 (0)