Skip to content

Commit 66d801e

Browse files
author
Robert Segal
committed
Adding billing invoices endpoints
1 parent 835e706 commit 66d801e

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

@@ -19,6 +20,11 @@ def ledgers(self) -> LedgersService:
1920
"""Ledgers service."""
2021
return LedgersService(http_client=self.http_client)
2122

23+
@property
24+
def invoices(self) -> InvoicesService:
25+
"""Invoices service."""
26+
return InvoicesService(http_client=self.http_client)
27+
2228

2329
class AsyncBilling:
2430
"""Billing MPT API Module."""
@@ -35,3 +41,8 @@ def journals(self) -> AsyncJournalsService:
3541
def ledgers(self) -> AsyncLedgersService:
3642
"""Ledgers service."""
3743
return AsyncLedgersService(http_client=self.http_client)
44+
45+
@property
46+
def invoices(self) -> AsyncInvoicesService:
47+
"""Invoices service."""
48+
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

@@ -20,6 +21,7 @@ def async_billing(async_http_client):
2021
[
2122
("journals", JournalsService),
2223
("ledgers", LedgersService),
24+
("invoices", InvoicesService),
2325
],
2426
)
2527
def test_billing_properties(billing, property_name, expected_service_class):
@@ -35,6 +37,7 @@ def test_billing_properties(billing, property_name, expected_service_class):
3537
[
3638
("journals", AsyncJournalsService),
3739
("ledgers", AsyncLedgersService),
40+
("invoices", AsyncInvoicesService),
3841
],
3942
)
4043
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)