Skip to content

Commit ffcf3a1

Browse files
authored
[MPT-13828] Adding billing invoices endpoints (#55)
Adding billing invoices endpoints https://softwareone.atlassian.net/browse/MPT-13828
2 parents 8a8cce3 + d815128 commit ffcf3a1

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

mpt_api_client/resources/billing/billing.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
2+
from mpt_api_client.resources.billing.invoices import AsyncInvoicesService, InvoicesService
23
from mpt_api_client.resources.billing.journals import AsyncJournalsService, JournalsService
34
from mpt_api_client.resources.billing.ledgers import AsyncLedgersService, LedgersService
45
from mpt_api_client.resources.billing.statements import AsyncStatementsService, StatementsService
@@ -25,6 +26,11 @@ def statements(self) -> StatementsService:
2526
"""Statements service."""
2627
return StatementsService(http_client=self.http_client)
2728

29+
@property
30+
def invoices(self) -> InvoicesService:
31+
"""Invoices service."""
32+
return InvoicesService(http_client=self.http_client)
33+
2834

2935
class AsyncBilling:
3036
"""Billing MPT API Module."""
@@ -46,3 +52,8 @@ def ledgers(self) -> AsyncLedgersService:
4652
def statements(self) -> AsyncStatementsService:
4753
"""Statements service."""
4854
return AsyncStatementsService(http_client=self.http_client)
55+
56+
@property
57+
def invoices(self) -> AsyncInvoicesService:
58+
"""Invoices service."""
59+
return AsyncInvoicesService(http_client=self.http_client)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.http.mixins import AsyncCreateMixin, AsyncUpdateMixin, CreateMixin, UpdateMixin
3+
from mpt_api_client.models import Model
4+
5+
6+
class Invoice(Model):
7+
"""Invoice resource."""
8+
9+
10+
class InvoicesServiceConfig:
11+
"""Invoices service configuration."""
12+
13+
_endpoint = "/public/v1/billing/invoices"
14+
_model_class = Invoice
15+
_collection_key = "data"
16+
17+
18+
class InvoicesService(
19+
CreateMixin[Invoice],
20+
UpdateMixin[Invoice],
21+
Service[Invoice],
22+
InvoicesServiceConfig,
23+
):
24+
"""Invoices service."""
25+
26+
27+
class AsyncInvoicesService(
28+
AsyncCreateMixin[Invoice],
29+
AsyncUpdateMixin[Invoice],
30+
AsyncService[Invoice],
31+
InvoicesServiceConfig,
32+
):
33+
"""Async Invoices service."""

tests/resources/billing/test_billing.py

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

33
from mpt_api_client.resources.billing.billing import AsyncBilling, Billing
4+
from mpt_api_client.resources.billing.invoices import AsyncInvoicesService, InvoicesService
45
from mpt_api_client.resources.billing.journals import AsyncJournalsService, JournalsService
56
from mpt_api_client.resources.billing.ledgers import AsyncLedgersService, LedgersService
67
from mpt_api_client.resources.billing.statements import AsyncStatementsService, StatementsService
@@ -22,6 +23,7 @@ def async_billing(async_http_client):
2223
("journals", JournalsService),
2324
("ledgers", LedgersService),
2425
("statements", StatementsService),
26+
("invoices", InvoicesService),
2527
],
2628
)
2729
def test_billing_properties(billing, property_name, expected_service_class):
@@ -38,6 +40,7 @@ def test_billing_properties(billing, property_name, expected_service_class):
3840
("journals", AsyncJournalsService),
3941
("ledgers", AsyncLedgersService),
4042
("statements", AsyncStatementsService),
43+
("invoices", AsyncInvoicesService),
4144
],
4245
)
4346
def test_async_billing_properties(async_billing, property_name, expected_service_class):
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import pytest
2+
3+
from mpt_api_client.resources.billing.invoices import (
4+
AsyncInvoicesService,
5+
InvoicesService,
6+
)
7+
8+
9+
@pytest.fixture
10+
def invoices_service(http_client):
11+
return InvoicesService(http_client=http_client)
12+
13+
14+
@pytest.fixture
15+
def async_invoices_service(async_http_client):
16+
return AsyncInvoicesService(http_client=async_http_client)
17+
18+
19+
@pytest.mark.parametrize(
20+
"method",
21+
["get", "create", "update"],
22+
)
23+
def test_mixins_present(invoices_service, method):
24+
assert hasattr(invoices_service, method)
25+
26+
27+
@pytest.mark.parametrize(
28+
"method",
29+
["get", "create", "update"],
30+
)
31+
def test_async_mixins_present(async_invoices_service, method):
32+
assert hasattr(async_invoices_service, method)

0 commit comments

Comments
 (0)