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
13 changes: 5 additions & 8 deletions mpt_api_client/resources/billing/credit_memo_attachments.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCollectionMixin,
AsyncFilesOperationsMixin,
AsyncModifiableResourceMixin,
CollectionMixin,
FilesOperationsMixin,
ModifiableResourceMixin,
)
from mpt_api_client.models import Model
from mpt_api_client.resources.billing.mixins import AsyncAttachmentMixin, AttachmentMixin


class CreditMemoAttachment(Model):
Expand All @@ -20,11 +17,12 @@ class CreditMemoAttachmentsServiceConfig:
_endpoint = "/public/v1/billing/credit-memos/{credit_memo_id}/attachments"
_model_class = CreditMemoAttachment
_collection_key = "data"
_upload_file_key = "file"
_upload_data_key = "attachment"


class CreditMemoAttachmentsService(
FilesOperationsMixin[CreditMemoAttachment],
ModifiableResourceMixin[CreditMemoAttachment],
AttachmentMixin[CreditMemoAttachment],
CollectionMixin[CreditMemoAttachment],
Service[CreditMemoAttachment],
CreditMemoAttachmentsServiceConfig,
Expand All @@ -33,8 +31,7 @@ class CreditMemoAttachmentsService(


class AsyncCreditMemoAttachmentsService(
AsyncFilesOperationsMixin[CreditMemoAttachment],
AsyncModifiableResourceMixin[CreditMemoAttachment],
AsyncAttachmentMixin[CreditMemoAttachment],
AsyncCollectionMixin[CreditMemoAttachment],
AsyncService[CreditMemoAttachment],
CreditMemoAttachmentsServiceConfig,
Expand Down
13 changes: 5 additions & 8 deletions mpt_api_client/resources/billing/custom_ledger_attachments.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCollectionMixin,
AsyncFilesOperationsMixin,
AsyncModifiableResourceMixin,
CollectionMixin,
FilesOperationsMixin,
ModifiableResourceMixin,
)
from mpt_api_client.models import Model
from mpt_api_client.resources.billing.mixins import AsyncAttachmentMixin, AttachmentMixin


class CustomLedgerAttachment(Model):
Expand All @@ -20,11 +17,12 @@ class CustomLedgerAttachmentsServiceConfig:
_endpoint = "/public/v1/billing/custom-ledgers/{custom_ledger_id}/attachments"
_model_class = CustomLedgerAttachment
_collection_key = "data"
_upload_file_key = "file"
_upload_data_key = "attachment"


class CustomLedgerAttachmentsService(
FilesOperationsMixin[CustomLedgerAttachment],
ModifiableResourceMixin[CustomLedgerAttachment],
AttachmentMixin[CustomLedgerAttachment],
CollectionMixin[CustomLedgerAttachment],
Service[CustomLedgerAttachment],
CustomLedgerAttachmentsServiceConfig,
Expand All @@ -33,8 +31,7 @@ class CustomLedgerAttachmentsService(


class AsyncCustomLedgerAttachmentsService(
AsyncFilesOperationsMixin[CustomLedgerAttachment],
AsyncModifiableResourceMixin[CustomLedgerAttachment],
AsyncAttachmentMixin[CustomLedgerAttachment],
AsyncCollectionMixin[CustomLedgerAttachment],
AsyncService[CustomLedgerAttachment],
CustomLedgerAttachmentsServiceConfig,
Expand Down
13 changes: 5 additions & 8 deletions mpt_api_client/resources/billing/invoice_attachments.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCollectionMixin,
AsyncFilesOperationsMixin,
AsyncModifiableResourceMixin,
CollectionMixin,
FilesOperationsMixin,
ModifiableResourceMixin,
)
from mpt_api_client.models import Model
from mpt_api_client.resources.billing.mixins import AsyncAttachmentMixin, AttachmentMixin


class InvoiceAttachment(Model):
Expand All @@ -20,11 +17,12 @@ class InvoiceAttachmentsServiceConfig:
_endpoint = "/public/v1/billing/invoices/{invoice_id}/attachments"
_model_class = InvoiceAttachment
_collection_key = "data"
_upload_file_key = "file"
_upload_data_key = "attachment"


class InvoiceAttachmentsService(
FilesOperationsMixin[InvoiceAttachment],
ModifiableResourceMixin[InvoiceAttachment],
AttachmentMixin[InvoiceAttachment],
CollectionMixin[InvoiceAttachment],
Service[InvoiceAttachment],
InvoiceAttachmentsServiceConfig,
Expand All @@ -33,8 +31,7 @@ class InvoiceAttachmentsService(


class AsyncInvoiceAttachmentsService(
AsyncFilesOperationsMixin[InvoiceAttachment],
AsyncModifiableResourceMixin[InvoiceAttachment],
AsyncAttachmentMixin[InvoiceAttachment],
AsyncCollectionMixin[InvoiceAttachment],
AsyncService[InvoiceAttachment],
InvoiceAttachmentsServiceConfig,
Expand Down
23 changes: 3 additions & 20 deletions mpt_api_client/resources/billing/journal_attachments.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCollectionMixin,
AsyncCreateFileMixin,
AsyncDeleteMixin,
AsyncDownloadFileMixin,
AsyncGetMixin,
AsyncUpdateMixin,
CollectionMixin,
CreateFileMixin,
DeleteMixin,
DownloadFileMixin,
GetMixin,
UpdateMixin,
)
from mpt_api_client.models import Model
from mpt_api_client.resources.billing.mixins import AsyncAttachmentMixin, AttachmentMixin


class JournalAttachment(Model):
Expand All @@ -31,11 +22,7 @@ class JournalAttachmentsServiceConfig:


class JournalAttachmentsService(
CreateFileMixin[JournalAttachment],
UpdateMixin[JournalAttachment],
DownloadFileMixin[JournalAttachment],
DeleteMixin,
GetMixin[JournalAttachment],
AttachmentMixin[JournalAttachment],
CollectionMixin[JournalAttachment],
Service[JournalAttachment],
JournalAttachmentsServiceConfig,
Expand All @@ -44,11 +31,7 @@ class JournalAttachmentsService(


class AsyncJournalAttachmentsService(
AsyncCreateFileMixin[JournalAttachment],
AsyncUpdateMixin[JournalAttachment],
AsyncDownloadFileMixin[JournalAttachment],
AsyncDeleteMixin,
AsyncGetMixin[JournalAttachment],
AsyncAttachmentMixin[JournalAttachment],
AsyncCollectionMixin[JournalAttachment],
AsyncService[JournalAttachment],
JournalAttachmentsServiceConfig,
Expand Down
13 changes: 5 additions & 8 deletions mpt_api_client/resources/billing/ledger_attachments.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCollectionMixin,
AsyncFilesOperationsMixin,
AsyncModifiableResourceMixin,
CollectionMixin,
FilesOperationsMixin,
ModifiableResourceMixin,
)
from mpt_api_client.models import Model
from mpt_api_client.resources.billing.mixins import AsyncAttachmentMixin, AttachmentMixin


class LedgerAttachment(Model):
Expand All @@ -20,11 +17,12 @@ class LedgerAttachmentsServiceConfig:
_endpoint = "/public/v1/billing/ledgers/{ledger_id}/attachments"
_model_class = LedgerAttachment
_collection_key = "data"
_upload_file_key = "file"
_upload_data_key = "attachment"


class LedgerAttachmentsService(
FilesOperationsMixin[LedgerAttachment],
ModifiableResourceMixin[LedgerAttachment],
AttachmentMixin[LedgerAttachment],
CollectionMixin[LedgerAttachment],
Service[LedgerAttachment],
LedgerAttachmentsServiceConfig,
Expand All @@ -33,8 +31,7 @@ class LedgerAttachmentsService(


class AsyncLedgerAttachmentsService(
AsyncFilesOperationsMixin[LedgerAttachment],
AsyncModifiableResourceMixin[LedgerAttachment],
AsyncAttachmentMixin[LedgerAttachment],
AsyncCollectionMixin[LedgerAttachment],
AsyncService[LedgerAttachment],
LedgerAttachmentsServiceConfig,
Expand Down
32 changes: 32 additions & 0 deletions mpt_api_client/resources/billing/mixins.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
from mpt_api_client.http.mixins import (
AsyncCreateFileMixin,
AsyncDeleteMixin,
AsyncDownloadFileMixin,
AsyncGetMixin,
AsyncUpdateMixin,
CreateFileMixin,
DeleteMixin,
DownloadFileMixin,
GetMixin,
UpdateMixin,
)
from mpt_api_client.models import ResourceData


Expand Down Expand Up @@ -392,3 +404,23 @@ async def queue(self, resource_id: str, resource_data: ResourceData | None = Non
return await self._resource_action( # type: ignore[attr-defined, no-any-return]
resource_id, "POST", "queue", json=resource_data
)


class AttachmentMixin[Model](
CreateFileMixin[Model],
UpdateMixin[Model],
DeleteMixin,
DownloadFileMixin[Model],
GetMixin[Model],
):
"""Attachment mixin."""


class AsyncAttachmentMixin[Model](
AsyncCreateFileMixin[Model],
AsyncUpdateMixin[Model],
AsyncDeleteMixin,
AsyncDownloadFileMixin[Model],
AsyncGetMixin[Model],
):
"""Async Attachment mixin."""
39 changes: 39 additions & 0 deletions mpt_api_client/resources/billing/statement_attachments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCollectionMixin,
CollectionMixin,
)
from mpt_api_client.models import Model
from mpt_api_client.resources.billing.mixins import AsyncAttachmentMixin, AttachmentMixin


class StatementAttachment(Model):
"""Statement Attachment resource."""


class StatementAttachmentsServiceConfig:
"""Statement Attachments service configuration."""

_endpoint = "/public/v1/billing/statements/{statement_id}/attachments"
_model_class = StatementAttachment
_collection_key = "data"
_upload_file_key = "file"
_upload_data_key = "attachment"


class StatementAttachmentsService(
AttachmentMixin[StatementAttachment],
CollectionMixin[StatementAttachment],
Service[StatementAttachment],
StatementAttachmentsServiceConfig,
):
"""Statement Attachments service."""


class AsyncStatementAttachmentsService(
AsyncAttachmentMixin[StatementAttachment],
AsyncCollectionMixin[StatementAttachment],
AsyncService[StatementAttachment],
StatementAttachmentsServiceConfig,
):
"""Statement Attachments service."""
18 changes: 18 additions & 0 deletions mpt_api_client/resources/billing/statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
)
from mpt_api_client.models import Model
from mpt_api_client.resources.billing.mixins import AsyncIssuableMixin, IssuableMixin
from mpt_api_client.resources.billing.statement_attachments import (
AsyncStatementAttachmentsService,
StatementAttachmentsService,
)
from mpt_api_client.resources.billing.statement_charges import (
AsyncStatementChargesService,
StatementChargesService,
Expand Down Expand Up @@ -44,6 +48,13 @@ def charges(self, statement_id: str) -> StatementChargesService:
endpoint_params={"statement_id": statement_id},
)

def attachments(self, statement_id: str) -> StatementAttachmentsService:
"""Return statement attachments service."""
return StatementAttachmentsService(
http_client=self.http_client,
endpoint_params={"statement_id": statement_id},
)


class AsyncStatementsService(
AsyncUpdateMixin[Statement],
Expand All @@ -61,3 +72,10 @@ def charges(self, statement_id: str) -> AsyncStatementChargesService:
http_client=self.http_client,
endpoint_params={"statement_id": statement_id},
)

def attachments(self, statement_id: str) -> AsyncStatementAttachmentsService:
"""Return statement attachments service."""
return AsyncStatementAttachmentsService(
http_client=self.http_client,
endpoint_params={"statement_id": statement_id},
)
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ def test_async_endpoint(async_credit_memo_attachments_service):
assert result is True


@pytest.mark.parametrize("method", ["get", "create", "update", "delete"])
@pytest.mark.parametrize("method", ["get", "create", "update", "delete", "iterate", "download"])
def test_methods_present(credit_memo_attachments_service, method: str):
result = hasattr(credit_memo_attachments_service, method)

assert result is True


@pytest.mark.parametrize("method", ["get", "create", "update", "delete"])
@pytest.mark.parametrize("method", ["get", "create", "update", "delete", "iterate", "download"])
def test_async_methods_present(async_credit_memo_attachments_service, method: str):
result = hasattr(async_credit_memo_attachments_service, method)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def test_async_endpoint(async_custom_ledger_attachments_service):
assert result is True


@pytest.mark.parametrize("method", ["get", "create", "update", "delete"])
@pytest.mark.parametrize("method", ["get", "create", "update", "delete", "iterate", "download"])
def test_methods_present(custom_ledger_attachments_service, method: str):
result = hasattr(custom_ledger_attachments_service, method)

assert result is True


@pytest.mark.parametrize("method", ["get", "create", "update", "delete"])
@pytest.mark.parametrize("method", ["get", "create", "update", "delete", "iterate", "download"])
def test_async_methods_present(async_custom_ledger_attachments_service, method: str):
result = hasattr(async_custom_ledger_attachments_service, method)

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/resources/billing/test_invoice_attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ def test_async_endpoint(async_invoice_attachments_service):
assert result is True


@pytest.mark.parametrize("method", ["get", "create", "update", "delete"])
@pytest.mark.parametrize("method", ["get", "create", "update", "delete", "iterate", "download"])
def test_methods_present(invoice_attachments_service, method: str):
result = hasattr(invoice_attachments_service, method)

assert result is True


@pytest.mark.parametrize("method", ["get", "create", "update", "delete"])
@pytest.mark.parametrize("method", ["get", "create", "update", "delete", "iterate", "download"])
def test_async_methods_present(async_invoice_attachments_service, method: str):
result = hasattr(async_invoice_attachments_service, method)

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/resources/billing/test_ledger_attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ def test_async_endpoint(async_ledger_attachments_service) -> None:
assert result is True


@pytest.mark.parametrize("method", ["get", "create", "update", "delete"])
@pytest.mark.parametrize("method", ["get", "create", "update", "delete", "iterate", "download"])
def test_methods_present(ledger_attachments_service, method: str) -> None:
result = hasattr(ledger_attachments_service, method)

assert result is True


@pytest.mark.parametrize("method", ["get", "create", "update", "delete"])
@pytest.mark.parametrize("method", ["get", "create", "update", "delete", "iterate", "download"])
def test_async_methods_present(async_ledger_attachments_service, method: str) -> None:
result = hasattr(async_ledger_attachments_service, method)

Expand Down
Loading