Skip to content

Commit b60c7bb

Browse files
Robert Segald3rky
authored andcommitted
Added billing journal upload endpoint
1 parent e6681f2 commit b60c7bb

File tree

5 files changed

+94
-1
lines changed

5 files changed

+94
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.http.mixins import AsyncFileOperationsMixin, FileOperationsMixin
3+
from mpt_api_client.models import Model
4+
5+
6+
class JournalUpload(Model):
7+
"""Journal Upload resource."""
8+
9+
10+
class JournalUploadServiceConfig:
11+
"""Journal Upload service configuration."""
12+
13+
_endpoint = "/public/v1/billing/journals/{journal_id}/upload"
14+
_model_class = JournalUpload
15+
_collection_key = "data"
16+
17+
18+
class JournalUploadService(
19+
FileOperationsMixin[JournalUpload],
20+
Service[JournalUpload],
21+
JournalUploadServiceConfig,
22+
):
23+
"""Journal Upload service."""
24+
25+
26+
class AsyncJournalUploadService(
27+
AsyncFileOperationsMixin[JournalUpload],
28+
AsyncService[JournalUpload],
29+
JournalUploadServiceConfig,
30+
):
31+
"""Journal Upload service."""

mpt_api_client/resources/billing/journals.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
AsyncJournalSellersService,
2020
JournalSellersService,
2121
)
22+
from mpt_api_client.resources.billing.journal_upload import (
23+
AsyncJournalUploadService,
24+
JournalUploadService,
25+
)
2226
from mpt_api_client.resources.billing.mixins import AsyncRegeneratableMixin, RegeneratableMixin
2327

2428

@@ -63,6 +67,12 @@ def charges(self, journal_id: str) -> JournalChargesService:
6367
http_client=self.http_client, endpoint_params={"journal_id": journal_id}
6468
)
6569

70+
def upload(self, journal_id: str) -> JournalUploadService:
71+
"""Return journal upload service."""
72+
return JournalUploadService(
73+
http_client=self.http_client, endpoint_params={"journal_id": journal_id}
74+
)
75+
6676

6777
class AsyncJournalsService(
6878
AsyncCreateMixin[Journal],
@@ -92,3 +102,9 @@ def charges(self, journal_id: str) -> AsyncJournalChargesService:
92102
return AsyncJournalChargesService(
93103
http_client=self.http_client, endpoint_params={"journal_id": journal_id}
94104
)
105+
106+
def upload(self, journal_id: str) -> AsyncJournalUploadService:
107+
"""Return journal upload service."""
108+
return AsyncJournalUploadService(
109+
http_client=self.http_client, endpoint_params={"journal_id": journal_id}
110+
)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extend-ignore =
3232

3333

3434
per-file-ignores =
35-
mpt_api_client/resources/billing/*.py: WPS215 WPS202 WPS214
35+
mpt_api_client/resources/billing/*.py: WPS215 WPS202 WPS214 WPS204
3636
mpt_api_client/resources/catalog/*.py: WPS110 WPS215 WPS214
3737
mpt_api_client/resources/commerce/*.py: WPS215
3838
mpt_api_client/rql/query_builder.py: WPS110 WPS115 WPS210 WPS214
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pytest
2+
3+
from mpt_api_client.resources.billing.journal_upload import (
4+
AsyncJournalUploadService,
5+
JournalUploadService,
6+
)
7+
8+
9+
@pytest.fixture
10+
def journal_upload_service(http_client):
11+
return JournalUploadService(
12+
http_client=http_client, endpoint_params={"journal_id": "JRN-0000-0001"}
13+
)
14+
15+
16+
@pytest.fixture
17+
def async_journal_upload_service(async_http_client):
18+
return AsyncJournalUploadService(
19+
http_client=async_http_client, endpoint_params={"journal_id": "JRN-0000-0001"}
20+
)
21+
22+
23+
def test_endpoint(journal_upload_service) -> None:
24+
assert journal_upload_service.endpoint == "/public/v1/billing/journals/JRN-0000-0001/upload"
25+
26+
27+
def test_async_endpoint(async_journal_upload_service) -> None:
28+
assert (
29+
async_journal_upload_service.endpoint == "/public/v1/billing/journals/JRN-0000-0001/upload"
30+
)
31+
32+
33+
@pytest.mark.parametrize("method", ["create"])
34+
def test_methods_present(journal_upload_service, method: str) -> None:
35+
assert hasattr(journal_upload_service, method)
36+
37+
38+
@pytest.mark.parametrize("method", ["create"])
39+
def test_async_methods_present(async_journal_upload_service, method: str) -> None:
40+
assert hasattr(async_journal_upload_service, method)

tests/resources/billing/test_journals.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
AsyncJournalSellersService,
1313
JournalSellersService,
1414
)
15+
from mpt_api_client.resources.billing.journal_upload import (
16+
AsyncJournalUploadService,
17+
JournalUploadService,
18+
)
1519
from mpt_api_client.resources.billing.journals import AsyncJournalsService, JournalsService
1620

1721

@@ -47,6 +51,7 @@ def test_async_mixins_present(async_journals_service, method):
4751
("attachments", JournalAttachmentsService),
4852
("sellers", JournalSellersService),
4953
("charges", JournalChargesService),
54+
("upload", JournalUploadService),
5055
],
5156
)
5257
def test_property_services(journals_service, service_method, expected_service_class):
@@ -62,6 +67,7 @@ def test_property_services(journals_service, service_method, expected_service_cl
6267
("attachments", AsyncJournalAttachmentsService),
6368
("sellers", AsyncJournalSellersService),
6469
("charges", AsyncJournalChargesService),
70+
("upload", AsyncJournalUploadService),
6571
],
6672
)
6773
def test_async_property_services(async_journals_service, service_method, expected_service_class):

0 commit comments

Comments
 (0)