Skip to content

Commit 1a591d9

Browse files
authored
[MPT-13820] Added billing journal sellers endpoint (#52)
Added billing journal sellers endpoint https://softwareone.atlassian.net/browse/MPT-13820
2 parents 835e706 + 28b9cc4 commit 1a591d9

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.models import Model
3+
4+
5+
class JournalSeller(Model):
6+
"""Journal Seller resource."""
7+
8+
9+
class JournalSellersServiceConfig:
10+
"""Journal Sellers service configuration."""
11+
12+
_endpoint = "/public/v1/billing/journals/{journal_id}/sellers"
13+
_model_class = JournalSeller
14+
_collection_key = "data"
15+
16+
17+
class JournalSellersService(
18+
Service[JournalSeller],
19+
JournalSellersServiceConfig,
20+
):
21+
"""Journal Sellers service."""
22+
23+
24+
class AsyncJournalSellersService(
25+
AsyncService[JournalSeller],
26+
JournalSellersServiceConfig,
27+
):
28+
"""Async Journal Sellers service."""

mpt_api_client/resources/billing/journals.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
AsyncJournalAttachmentsService,
1212
JournalAttachmentsService,
1313
)
14+
from mpt_api_client.resources.billing.journal_sellers import (
15+
AsyncJournalSellersService,
16+
JournalSellersService,
17+
)
1418
from mpt_api_client.resources.billing.mixins import AsyncRegeneratableMixin, RegeneratableMixin
1519

1620

@@ -43,6 +47,12 @@ def attachments(self, journal_id: str) -> JournalAttachmentsService:
4347
endpoint_params={"journal_id": journal_id},
4448
)
4549

50+
def sellers(self, journal_id: str) -> JournalSellersService:
51+
"""Return journal sellers service."""
52+
return JournalSellersService(
53+
http_client=self.http_client, endpoint_params={"journal_id": journal_id}
54+
)
55+
4656

4757
class AsyncJournalsService(
4858
AsyncCreateMixin[Journal],
@@ -60,3 +70,9 @@ def attachments(self, journal_id: str) -> AsyncJournalAttachmentsService:
6070
http_client=self.http_client,
6171
endpoint_params={"journal_id": journal_id},
6272
)
73+
74+
def sellers(self, journal_id: str) -> AsyncJournalSellersService:
75+
"""Return journal sellers service."""
76+
return AsyncJournalSellersService(
77+
http_client=self.http_client, endpoint_params={"journal_id": journal_id}
78+
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import pytest
2+
3+
from mpt_api_client.resources.billing.journal_sellers import (
4+
AsyncJournalSellersService,
5+
JournalSellersService,
6+
)
7+
8+
9+
@pytest.fixture
10+
def journal_sellers_service(http_client):
11+
return JournalSellersService(
12+
http_client=http_client, endpoint_params={"journal_id": "JRN-0000-0001"}
13+
)
14+
15+
16+
@pytest.fixture
17+
def async_journal_sellers_service(async_http_client):
18+
return AsyncJournalSellersService(
19+
http_client=async_http_client, endpoint_params={"journal_id": "JRN-0000-0001"}
20+
)
21+
22+
23+
def test_endpoint(journal_sellers_service):
24+
assert journal_sellers_service.endpoint == "/public/v1/billing/journals/JRN-0000-0001/sellers"
25+
26+
27+
def test_async_endpoint(async_journal_sellers_service):
28+
assert (
29+
async_journal_sellers_service.endpoint
30+
== "/public/v1/billing/journals/JRN-0000-0001/sellers"
31+
)
32+
33+
34+
@pytest.mark.parametrize("method", ["get"])
35+
def test_methods_present(journal_sellers_service, method):
36+
assert hasattr(journal_sellers_service, method)
37+
38+
39+
@pytest.mark.parametrize("method", ["get"])
40+
def test_async_methods_present(async_journal_sellers_service, method):
41+
assert hasattr(async_journal_sellers_service, method)

tests/resources/billing/test_journals.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
AsyncJournalAttachmentsService,
55
JournalAttachmentsService,
66
)
7+
from mpt_api_client.resources.billing.journal_sellers import (
8+
AsyncJournalSellersService,
9+
JournalSellersService,
10+
)
711
from mpt_api_client.resources.billing.journals import AsyncJournalsService, JournalsService
812

913

@@ -37,6 +41,7 @@ def test_async_mixins_present(async_journals_service, method):
3741
("service_method", "expected_service_class"),
3842
[
3943
("attachments", JournalAttachmentsService),
44+
("sellers", JournalSellersService),
4045
],
4146
)
4247
def test_property_services(journals_service, service_method, expected_service_class):
@@ -50,6 +55,7 @@ def test_property_services(journals_service, service_method, expected_service_cl
5055
("service_method", "expected_service_class"),
5156
[
5257
("attachments", AsyncJournalAttachmentsService),
58+
("sellers", AsyncJournalSellersService),
5359
],
5460
)
5561
def test_async_property_services(async_journals_service, service_method, expected_service_class):

0 commit comments

Comments
 (0)