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
28 changes: 28 additions & 0 deletions mpt_api_client/resources/billing/journal_sellers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.models import Model


class JournalSeller(Model):
"""Journal Seller resource."""


class JournalSellersServiceConfig:
"""Journal Sellers service configuration."""

_endpoint = "/public/v1/billing/journals/{journal_id}/sellers"
_model_class = JournalSeller
_collection_key = "data"


class JournalSellersService(
Service[JournalSeller],
JournalSellersServiceConfig,
):
"""Journal Sellers service."""


class AsyncJournalSellersService(
AsyncService[JournalSeller],
JournalSellersServiceConfig,
):
"""Async Journal Sellers service."""
16 changes: 16 additions & 0 deletions mpt_api_client/resources/billing/journals.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
AsyncJournalAttachmentsService,
JournalAttachmentsService,
)
from mpt_api_client.resources.billing.journal_sellers import (
AsyncJournalSellersService,
JournalSellersService,
)
from mpt_api_client.resources.billing.mixins import AsyncRegeneratableMixin, RegeneratableMixin


Expand Down Expand Up @@ -43,6 +47,12 @@ def attachments(self, journal_id: str) -> JournalAttachmentsService:
endpoint_params={"journal_id": journal_id},
)

def sellers(self, journal_id: str) -> JournalSellersService:
"""Return journal sellers service."""
return JournalSellersService(
http_client=self.http_client, endpoint_params={"journal_id": journal_id}
)


class AsyncJournalsService(
AsyncCreateMixin[Journal],
Expand All @@ -60,3 +70,9 @@ def attachments(self, journal_id: str) -> AsyncJournalAttachmentsService:
http_client=self.http_client,
endpoint_params={"journal_id": journal_id},
)

def sellers(self, journal_id: str) -> AsyncJournalSellersService:
"""Return journal sellers service."""
return AsyncJournalSellersService(
http_client=self.http_client, endpoint_params={"journal_id": journal_id}
)
41 changes: 41 additions & 0 deletions tests/resources/billing/test_journal_sellers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import pytest

from mpt_api_client.resources.billing.journal_sellers import (
AsyncJournalSellersService,
JournalSellersService,
)


@pytest.fixture
def journal_sellers_service(http_client):
return JournalSellersService(
http_client=http_client, endpoint_params={"journal_id": "JRN-0000-0001"}
)


@pytest.fixture
def async_journal_sellers_service(async_http_client):
return AsyncJournalSellersService(
http_client=async_http_client, endpoint_params={"journal_id": "JRN-0000-0001"}
)


def test_endpoint(journal_sellers_service):
assert journal_sellers_service.endpoint == "/public/v1/billing/journals/JRN-0000-0001/sellers"


def test_async_endpoint(async_journal_sellers_service):
assert (
async_journal_sellers_service.endpoint
== "/public/v1/billing/journals/JRN-0000-0001/sellers"
)


@pytest.mark.parametrize("method", ["get"])
def test_methods_present(journal_sellers_service, method):
assert hasattr(journal_sellers_service, method)


@pytest.mark.parametrize("method", ["get"])
def test_async_methods_present(async_journal_sellers_service, method):
assert hasattr(async_journal_sellers_service, method)
6 changes: 6 additions & 0 deletions tests/resources/billing/test_journals.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
AsyncJournalAttachmentsService,
JournalAttachmentsService,
)
from mpt_api_client.resources.billing.journal_sellers import (
AsyncJournalSellersService,
JournalSellersService,
)
from mpt_api_client.resources.billing.journals import AsyncJournalsService, JournalsService


Expand Down Expand Up @@ -37,6 +41,7 @@ def test_async_mixins_present(async_journals_service, method):
("service_method", "expected_service_class"),
[
("attachments", JournalAttachmentsService),
("sellers", JournalSellersService),
],
)
def test_property_services(journals_service, service_method, expected_service_class):
Expand All @@ -50,6 +55,7 @@ def test_property_services(journals_service, service_method, expected_service_cl
("service_method", "expected_service_class"),
[
("attachments", AsyncJournalAttachmentsService),
("sellers", AsyncJournalSellersService),
],
)
def test_async_property_services(async_journals_service, service_method, expected_service_class):
Expand Down