Skip to content

Commit a179f97

Browse files
author
Robert Segal
committed
Added Accounts licensees endpoints
1 parent 7b59f65 commit a179f97

4 files changed

Lines changed: 96 additions & 2 deletions

File tree

mpt_api_client/resources/accounts/accounts.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
22
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
3+
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
34

45

56
class Accounts:
@@ -13,6 +14,11 @@ def accounts(self) -> AccountsService:
1314
"""Accounts service."""
1415
return AccountsService(http_client=self.http_client)
1516

17+
@property
18+
def licensees(self) -> LicenseesService:
19+
"""Licensees service."""
20+
return LicenseesService(http_client=self.http_client)
21+
1622

1723
class AsyncAccounts:
1824
"""Async Accounts MPT API Module."""
@@ -24,3 +30,8 @@ def __init__(self, *, http_client: AsyncHTTPClient):
2430
def accounts(self) -> AsyncAccountsService:
2531
"""Accounts service."""
2632
return AsyncAccountsService(http_client=self.http_client)
33+
34+
@property
35+
def licensees(self) -> AsyncLicenseesService:
36+
"""Licensees service."""
37+
return AsyncLicenseesService(http_client=self.http_client)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.http.mixins import (
3+
AsyncCreateMixin,
4+
AsyncDeleteMixin,
5+
AsyncUpdateMixin,
6+
CreateMixin,
7+
DeleteMixin,
8+
UpdateMixin,
9+
)
10+
from mpt_api_client.models import Model
11+
from mpt_api_client.resources.accounts.mixins import AsyncEnablableMixin, EnablableMixin
12+
13+
14+
class Licensee(Model):
15+
"""Licensee Model."""
16+
17+
18+
class LicenseesServiceConfig:
19+
"""Licensees Service Configuration."""
20+
21+
_endpoint = "/public/v1/accounts/licensees"
22+
_model_class = Licensee
23+
_collection_key = "data"
24+
25+
26+
class LicenseesService(
27+
CreateMixin[Licensee],
28+
DeleteMixin,
29+
UpdateMixin[Licensee],
30+
EnablableMixin[Licensee],
31+
Service[Licensee],
32+
LicenseesServiceConfig,
33+
):
34+
"""Licensees Service."""
35+
36+
37+
class AsyncLicenseesService(
38+
AsyncCreateMixin[Licensee],
39+
AsyncDeleteMixin,
40+
AsyncUpdateMixin[Licensee],
41+
AsyncEnablableMixin[Licensee],
42+
AsyncService[Licensee],
43+
LicenseesServiceConfig,
44+
):
45+
"""Async Licensees Service."""

tests/resources/accounts/test_accounts.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
44
from mpt_api_client.resources.accounts.accounts import Accounts, AsyncAccounts
5+
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
56

67

78
@pytest.fixture
@@ -15,7 +16,11 @@ def async_accounts(async_http_client):
1516

1617

1718
@pytest.mark.parametrize(
18-
("property_name", "expected_service_class"), [("accounts", AccountsService)]
19+
("property_name", "expected_service_class"),
20+
[
21+
("accounts", AccountsService),
22+
("licensees", LicenseesService),
23+
],
1924
)
2025
def test_accounts_properties(accounts, property_name, expected_service_class):
2126
"""Test that Accounts properties return correct instances."""
@@ -26,7 +31,11 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
2631

2732

2833
@pytest.mark.parametrize(
29-
("property_name", "expected_service_class"), [("accounts", AsyncAccountsService)]
34+
("property_name", "expected_service_class"),
35+
[
36+
("accounts", AsyncAccountsService),
37+
("licensees", AsyncLicenseesService),
38+
],
3039
)
3140
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):
3241
"""Test that AsyncAccounts properties return correct instances."""
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pytest
2+
3+
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
4+
5+
6+
@pytest.fixture
7+
def licensees_service(http_client):
8+
return LicenseesService(http_client=http_client)
9+
10+
11+
@pytest.fixture
12+
def async_licensees_service(async_http_client):
13+
return AsyncLicenseesService(http_client=async_http_client)
14+
15+
16+
@pytest.mark.parametrize(
17+
"method",
18+
["get", "create", "delete", "update", "enable", "disable"],
19+
)
20+
def test_licensees_mixins_present(licensees_service, method):
21+
assert hasattr(licensees_service, method)
22+
23+
24+
@pytest.mark.parametrize(
25+
"method",
26+
["get", "create", "delete", "update", "enable", "disable"],
27+
)
28+
def test_async_licensees_mixins_present(async_licensees_service, method):
29+
assert hasattr(async_licensees_service, method)

0 commit comments

Comments
 (0)