Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions mpt_api_client/resources/billing/billing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
from mpt_api_client.resources.billing.invoices import AsyncInvoicesService, InvoicesService
from mpt_api_client.resources.billing.journals import AsyncJournalsService, JournalsService
from mpt_api_client.resources.billing.ledgers import AsyncLedgersService, LedgersService
from mpt_api_client.resources.billing.statements import AsyncStatementsService, StatementsService
Expand All @@ -25,6 +26,11 @@ def statements(self) -> StatementsService:
"""Statements service."""
return StatementsService(http_client=self.http_client)

@property
def invoices(self) -> InvoicesService:
"""Invoices service."""
return InvoicesService(http_client=self.http_client)


class AsyncBilling:
"""Billing MPT API Module."""
Expand All @@ -46,3 +52,8 @@ def ledgers(self) -> AsyncLedgersService:
def statements(self) -> AsyncStatementsService:
"""Statements service."""
return AsyncStatementsService(http_client=self.http_client)

@property
def invoices(self) -> AsyncInvoicesService:
"""Invoices service."""
return AsyncInvoicesService(http_client=self.http_client)
33 changes: 33 additions & 0 deletions mpt_api_client/resources/billing/invoices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import AsyncCreateMixin, AsyncUpdateMixin, CreateMixin, UpdateMixin
from mpt_api_client.models import Model


class Invoice(Model):
"""Invoice resource."""


class InvoicesServiceConfig:
"""Invoices service configuration."""

_endpoint = "/public/v1/billing/invoices"
_model_class = Invoice
_collection_key = "data"


class InvoicesService(
CreateMixin[Invoice],
UpdateMixin[Invoice],
Service[Invoice],
InvoicesServiceConfig,
):
"""Invoices service."""


class AsyncInvoicesService(
AsyncCreateMixin[Invoice],
AsyncUpdateMixin[Invoice],
AsyncService[Invoice],
InvoicesServiceConfig,
):
"""Async Invoices service."""
3 changes: 3 additions & 0 deletions tests/resources/billing/test_billing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest

from mpt_api_client.resources.billing.billing import AsyncBilling, Billing
from mpt_api_client.resources.billing.invoices import AsyncInvoicesService, InvoicesService
from mpt_api_client.resources.billing.journals import AsyncJournalsService, JournalsService
from mpt_api_client.resources.billing.ledgers import AsyncLedgersService, LedgersService
from mpt_api_client.resources.billing.statements import AsyncStatementsService, StatementsService
Expand All @@ -22,6 +23,7 @@ def async_billing(async_http_client):
("journals", JournalsService),
("ledgers", LedgersService),
("statements", StatementsService),
("invoices", InvoicesService),
],
)
def test_billing_properties(billing, property_name, expected_service_class):
Expand All @@ -38,6 +40,7 @@ def test_billing_properties(billing, property_name, expected_service_class):
("journals", AsyncJournalsService),
("ledgers", AsyncLedgersService),
("statements", AsyncStatementsService),
("invoices", AsyncInvoicesService),
],
)
def test_async_billing_properties(async_billing, property_name, expected_service_class):
Expand Down
32 changes: 32 additions & 0 deletions tests/resources/billing/test_invoices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest

from mpt_api_client.resources.billing.invoices import (
AsyncInvoicesService,
InvoicesService,
)


@pytest.fixture
def invoices_service(http_client):
return InvoicesService(http_client=http_client)


@pytest.fixture
def async_invoices_service(async_http_client):
return AsyncInvoicesService(http_client=async_http_client)


@pytest.mark.parametrize(
"method",
["get", "create", "update"],
)
def test_mixins_present(invoices_service, method):
assert hasattr(invoices_service, method)


@pytest.mark.parametrize(
"method",
["get", "create", "update"],
)
def test_async_mixins_present(async_invoices_service, method):
assert hasattr(async_invoices_service, method)