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
11 changes: 11 additions & 0 deletions mpt_api_client/resources/accounts/accounts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
from mpt_api_client.resources.accounts.users import AsyncUsersService, UsersService

Expand All @@ -25,6 +26,11 @@ def sellers(self) -> SellersService:
"""Sellers service."""
return SellersService(http_client=self.http_client)

@property
def licensees(self) -> LicenseesService:
"""Licensees service."""
return LicenseesService(http_client=self.http_client)


class AsyncAccounts:
"""Async Accounts MPT API Module."""
Expand All @@ -46,3 +52,8 @@ def users(self) -> AsyncUsersService:
def sellers(self) -> AsyncSellersService:
"""Sellers service."""
return AsyncSellersService(http_client=self.http_client)

@property
def licensees(self) -> AsyncLicenseesService:
"""Licensees service."""
return AsyncLicenseesService(http_client=self.http_client)
45 changes: 45 additions & 0 deletions mpt_api_client/resources/accounts/licensees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCreateMixin,
AsyncDeleteMixin,
AsyncUpdateMixin,
CreateMixin,
DeleteMixin,
UpdateMixin,
)
from mpt_api_client.models import Model
from mpt_api_client.resources.accounts.mixins import AsyncEnablableMixin, EnablableMixin


class Licensee(Model):
"""Licensee Model."""


class LicenseesServiceConfig:
"""Licensees Service Configuration."""

_endpoint = "/public/v1/accounts/licensees"
_model_class = Licensee
_collection_key = "data"


class LicenseesService(
CreateMixin[Licensee],
DeleteMixin,
UpdateMixin[Licensee],
EnablableMixin[Licensee],
Service[Licensee],
LicenseesServiceConfig,
):
"""Licensees Service."""


class AsyncLicenseesService(
AsyncCreateMixin[Licensee],
AsyncDeleteMixin,
AsyncUpdateMixin[Licensee],
AsyncEnablableMixin[Licensee],
AsyncService[Licensee],
LicenseesServiceConfig,
):
"""Async Licensees Service."""
3 changes: 3 additions & 0 deletions tests/resources/accounts/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
from mpt_api_client.resources.accounts.accounts import Accounts, AsyncAccounts
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
from mpt_api_client.resources.accounts.users import AsyncUsersService, UsersService

Expand All @@ -22,6 +23,7 @@ def async_accounts(async_http_client):
("accounts", AccountsService),
("users", UsersService),
("sellers", SellersService),
("licensees", LicenseesService),
],
)
def test_accounts_properties(accounts, property_name, expected_service_class):
Expand All @@ -38,6 +40,7 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
("accounts", AsyncAccountsService),
("users", AsyncUsersService),
("sellers", AsyncSellersService),
("licensees", AsyncLicenseesService),
],
)
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):
Expand Down
29 changes: 29 additions & 0 deletions tests/resources/accounts/test_licensees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest

from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService


@pytest.fixture
def licensees_service(http_client):
return LicenseesService(http_client=http_client)


@pytest.fixture
def async_licensees_service(async_http_client):
return AsyncLicenseesService(http_client=async_http_client)


@pytest.mark.parametrize(
"method",
["get", "create", "delete", "update", "enable", "disable"],
)
def test_licensees_mixins_present(licensees_service, method):
assert hasattr(licensees_service, method)


@pytest.mark.parametrize(
"method",
["get", "create", "delete", "update", "enable", "disable"],
)
def test_async_licensees_mixins_present(async_licensees_service, method):
assert hasattr(async_licensees_service, method)