From e778643d7c25e10507272cd9ba47309117f2fb1a Mon Sep 17 00:00:00 2001 From: Robert Segal Date: Sat, 4 Oct 2025 19:54:02 -0600 Subject: [PATCH] Added Accounts account-users endpoints --- .../resources/accounts/account_users.py | 40 +++++++++++++++++++ mpt_api_client/resources/accounts/accounts.py | 14 +++++++ .../resources/accounts/test_account_users.py | 32 +++++++++++++++ tests/resources/accounts/test_accounts.py | 6 +++ 4 files changed, 92 insertions(+) create mode 100644 mpt_api_client/resources/accounts/account_users.py create mode 100644 tests/resources/accounts/test_account_users.py diff --git a/mpt_api_client/resources/accounts/account_users.py b/mpt_api_client/resources/accounts/account_users.py new file mode 100644 index 00000000..95d6ee90 --- /dev/null +++ b/mpt_api_client/resources/accounts/account_users.py @@ -0,0 +1,40 @@ +from mpt_api_client.http import AsyncService, Service +from mpt_api_client.http.mixins import ( + AsyncCreateMixin, + CreateMixin, +) +from mpt_api_client.models import Model +from mpt_api_client.resources.accounts.mixins import ( + AsyncInvitableMixin, + InvitableMixin, +) + + +class AccountUser(Model): + """Account User Model.""" + + +class AccountUsersServiceConfig: + """Account Users Service Configuration.""" + + _endpoint = "/public/v1/accounts/account-users" + _model_class = AccountUser + _collection_key = "data" + + +class AccountUsersService( + CreateMixin[AccountUser], + InvitableMixin[AccountUser], + Service[AccountUser], + AccountUsersServiceConfig, +): + """Account Users Service.""" + + +class AsyncAccountUsersService( + AsyncCreateMixin[AccountUser], + AsyncService[AccountUser], + AsyncInvitableMixin[AccountUser], + AccountUsersServiceConfig, +): + """Asynchronous Account Users Service.""" diff --git a/mpt_api_client/resources/accounts/accounts.py b/mpt_api_client/resources/accounts/accounts.py index 00d707a9..be46715c 100644 --- a/mpt_api_client/resources/accounts/accounts.py +++ b/mpt_api_client/resources/accounts/accounts.py @@ -1,5 +1,9 @@ from mpt_api_client.http import AsyncHTTPClient, HTTPClient from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService +from mpt_api_client.resources.accounts.account_users import ( + AccountUsersService, + AsyncAccountUsersService, +) from mpt_api_client.resources.accounts.api_tokens import ApiTokensService, AsyncApiTokensService from mpt_api_client.resources.accounts.buyers import AsyncBuyersService, BuyersService from mpt_api_client.resources.accounts.cloud_tenants import ( @@ -67,6 +71,11 @@ def buyers(self) -> BuyersService: """Buyers service.""" return BuyersService(http_client=self.http_client) + @property + def account_users(self) -> AccountUsersService: + """Account Users service.""" + return AccountUsersService(http_client=self.http_client) + class AsyncAccounts: """Async Accounts MPT API Module.""" @@ -118,3 +127,8 @@ def cloud_tenants(self) -> AsyncCloudTenantsService: def buyers(self) -> AsyncBuyersService: """Buyers service.""" return AsyncBuyersService(http_client=self.http_client) + + @property + def account_users(self) -> AsyncAccountUsersService: + """Account Users service.""" + return AsyncAccountUsersService(http_client=self.http_client) diff --git a/tests/resources/accounts/test_account_users.py b/tests/resources/accounts/test_account_users.py new file mode 100644 index 00000000..60544589 --- /dev/null +++ b/tests/resources/accounts/test_account_users.py @@ -0,0 +1,32 @@ +import pytest + +from mpt_api_client.resources.accounts.account_users import ( + AccountUsersService, + AsyncAccountUsersService, +) + + +@pytest.fixture +def account_users_service(http_client): + return AccountUsersService(http_client=http_client) + + +@pytest.fixture +def async_account_users_service(http_client): + return AsyncAccountUsersService(http_client=http_client) + + +@pytest.mark.parametrize( + "method", + ["get", "create", "accept_invite", "resend_invite", "send_new_invite"], +) +def test_methods_present(account_users_service, method): + assert hasattr(account_users_service, method) + + +@pytest.mark.parametrize( + "method", + ["get", "create", "accept_invite", "resend_invite", "send_new_invite"], +) +def test_async_methods_present(async_account_users_service, method): + assert hasattr(async_account_users_service, method) diff --git a/tests/resources/accounts/test_accounts.py b/tests/resources/accounts/test_accounts.py index 6c69d339..4f30bf85 100644 --- a/tests/resources/accounts/test_accounts.py +++ b/tests/resources/accounts/test_accounts.py @@ -1,6 +1,10 @@ import pytest from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService +from mpt_api_client.resources.accounts.account_users import ( + AccountUsersService, + AsyncAccountUsersService, +) from mpt_api_client.resources.accounts.accounts import Accounts, AsyncAccounts from mpt_api_client.resources.accounts.api_tokens import ( ApiTokensService, @@ -43,6 +47,7 @@ def async_accounts(async_http_client): ("modules", ModulesService), ("cloud_tenants", CloudTenantsService), ("buyers", BuyersService), + ("account_users", AccountUsersService), ], ) def test_accounts_properties(accounts, property_name, expected_service_class): @@ -65,6 +70,7 @@ def test_accounts_properties(accounts, property_name, expected_service_class): ("modules", AsyncModulesService), ("cloud_tenants", AsyncCloudTenantsService), ("buyers", AsyncBuyersService), + ("account_users", AsyncAccountUsersService), ], ) def test_async_accounts_properties(async_accounts, property_name, expected_service_class):