Skip to content

Commit 9d6dcce

Browse files
author
Robert Segal
committed
Added billing custom ledger attachments
1 parent 16f0c8f commit 9d6dcce

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.http.mixins import (
3+
AsyncDeleteMixin,
4+
AsyncFileOperationsMixin,
5+
AsyncUpdateMixin,
6+
DeleteMixin,
7+
FileOperationsMixin,
8+
UpdateMixin,
9+
)
10+
from mpt_api_client.models import Model
11+
12+
13+
class CustomLedgerAttachment(Model):
14+
"""Custom Ledger Attachment resource."""
15+
16+
17+
class CustomLedgerAttachmentsServiceConfig:
18+
"""Custom Ledger Attachments service configuration."""
19+
20+
_endpoint = "/public/v1/billing/custom-ledgers/{custom_ledger_id}/attachments"
21+
_model_class = CustomLedgerAttachment
22+
_collection_key = "data"
23+
24+
25+
class CustomLedgerAttachmentsService(
26+
FileOperationsMixin[CustomLedgerAttachment],
27+
DeleteMixin,
28+
UpdateMixin[CustomLedgerAttachment],
29+
Service[CustomLedgerAttachment],
30+
CustomLedgerAttachmentsServiceConfig,
31+
):
32+
"""Custom Ledger Attachments service."""
33+
34+
35+
class AsyncCustomLedgerAttachmentsService(
36+
AsyncFileOperationsMixin[CustomLedgerAttachment],
37+
AsyncDeleteMixin,
38+
AsyncUpdateMixin[CustomLedgerAttachment],
39+
AsyncService[CustomLedgerAttachment],
40+
CustomLedgerAttachmentsServiceConfig,
41+
):
42+
"""Custom Ledger Attachments service."""

mpt_api_client/resources/billing/custom_ledgers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
UpdateMixin,
99
)
1010
from mpt_api_client.models import Model
11+
from mpt_api_client.resources.billing.custom_ledger_attachments import (
12+
AsyncCustomLedgerAttachmentsService,
13+
CustomLedgerAttachmentsService,
14+
)
1115
from mpt_api_client.resources.billing.custom_ledger_charges import (
1216
AsyncCustomLedgerChargesService,
1317
CustomLedgerChargesService,
@@ -55,6 +59,13 @@ def upload(self, custom_ledger_id: str) -> CustomLedgerUploadService:
5559
endpoint_params={"custom_ledger_id": custom_ledger_id},
5660
)
5761

62+
def attachments(self, custom_ledger_id: str) -> CustomLedgerAttachmentsService:
63+
"""Return custom ledger attachments service."""
64+
return CustomLedgerAttachmentsService(
65+
http_client=self.http_client,
66+
endpoint_params={"custom_ledger_id": custom_ledger_id},
67+
)
68+
5869

5970
class AsyncCustomLedgersService(
6071
AsyncCreateMixin[CustomLedger],
@@ -79,3 +90,10 @@ def upload(self, custom_ledger_id: str) -> AsyncCustomLedgerUploadService:
7990
http_client=self.http_client,
8091
endpoint_params={"custom_ledger_id": custom_ledger_id},
8192
)
93+
94+
def attachments(self, custom_ledger_id: str) -> AsyncCustomLedgerAttachmentsService:
95+
"""Return custom ledger attachments service."""
96+
return AsyncCustomLedgerAttachmentsService(
97+
http_client=self.http_client,
98+
endpoint_params={"custom_ledger_id": custom_ledger_id},
99+
)
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_attachments import (
4+
AsyncCustomLedgerAttachmentsService,
5+
CustomLedgerAttachmentsService,
6+
)
7+
8+
9+
@pytest.fixture
10+
def custom_ledger_attachments_service(http_client):
11+
return CustomLedgerAttachmentsService(
12+
http_client=http_client, endpoint_params={"custom_ledger_id": "LDG-0000-0001"}
13+
)
14+
15+
16+
@pytest.fixture
17+
def async_custom_ledger_attachments_service(async_http_client):
18+
return AsyncCustomLedgerAttachmentsService(
19+
http_client=async_http_client, endpoint_params={"custom_ledger_id": "LDG-0000-0001"}
20+
)
21+
22+
23+
def test_endpoint(custom_ledger_attachments_service):
24+
assert custom_ledger_attachments_service.endpoint == (
25+
"/public/v1/billing/custom-ledgers/LDG-0000-0001/attachments"
26+
)
27+
28+
29+
def test_async_endpoint(async_custom_ledger_attachments_service):
30+
assert async_custom_ledger_attachments_service.endpoint == (
31+
"/public/v1/billing/custom-ledgers/LDG-0000-0001/attachments"
32+
)
33+
34+
35+
@pytest.mark.parametrize("method", ["get", "create", "update", "delete"])
36+
def test_methods_present(custom_ledger_attachments_service, method: str):
37+
assert hasattr(custom_ledger_attachments_service, method)
38+
39+
40+
@pytest.mark.parametrize("method", ["get", "create", "update", "delete"])
41+
def test_async_methods_present(async_custom_ledger_attachments_service, method: str):
42+
assert hasattr(async_custom_ledger_attachments_service, method)

tests/resources/billing/test_custom_ledgers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import pytest
22

3+
from mpt_api_client.resources.billing.custom_ledger_attachments import (
4+
AsyncCustomLedgerAttachmentsService,
5+
CustomLedgerAttachmentsService,
6+
)
37
from mpt_api_client.resources.billing.custom_ledger_charges import (
48
AsyncCustomLedgerChargesService,
59
CustomLedgerChargesService,
@@ -39,6 +43,7 @@ def test_async_mixins_present(async_custom_ledgers_service, method):
3943
[
4044
("charges", CustomLedgerChargesService),
4145
("upload", CustomLedgerUploadService),
46+
("attachments", CustomLedgerAttachmentsService),
4247
],
4348
)
4449
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
5358
[
5459
("charges", AsyncCustomLedgerChargesService),
5560
("upload", AsyncCustomLedgerUploadService),
61+
("attachments", AsyncCustomLedgerAttachmentsService),
5662
],
5763
)
5864
def test_async_property_services(

0 commit comments

Comments
 (0)