diff --git a/mpt_api_client/resources/notifications/messages.py b/mpt_api_client/resources/notifications/messages.py new file mode 100644 index 0000000..c74343b --- /dev/null +++ b/mpt_api_client/resources/notifications/messages.py @@ -0,0 +1,28 @@ +from mpt_api_client.http import AsyncService, Service +from mpt_api_client.models import Model + + +class Message(Model): + """Notifications Message resource.""" + + +class MessagesServiceConfig: + """Notifications Messages service configuration.""" + + _endpoint = "/public/v1/notifications/messages" + _model_class = Message + _collection_key = "data" + + +class MessagesService( + Service[Message], + MessagesServiceConfig, +): + """Notifications Messages service (no CRUD, no block/unblock).""" + + +class AsyncMessagesService( + AsyncService[Message], + MessagesServiceConfig, +): + """Async Notifications Messages service (no CRUD, no block/unblock).""" diff --git a/mpt_api_client/resources/notifications/notifications.py b/mpt_api_client/resources/notifications/notifications.py index 7c283d6..22a3380 100644 --- a/mpt_api_client/resources/notifications/notifications.py +++ b/mpt_api_client/resources/notifications/notifications.py @@ -4,6 +4,7 @@ CategoriesService, ) from mpt_api_client.resources.notifications.contacts import AsyncContactsService, ContactsService +from mpt_api_client.resources.notifications.messages import AsyncMessagesService, MessagesService class Notifications: @@ -22,6 +23,11 @@ def contacts(self) -> ContactsService: """Contacts service.""" return ContactsService(http_client=self.http_client) + @property + def messages(self) -> MessagesService: + """Messages service.""" + return MessagesService(http_client=self.http_client) + class AsyncNotifications: """Notifications MPT API Module.""" @@ -38,3 +44,8 @@ def categories(self) -> AsyncCategoriesService: def contacts(self) -> AsyncContactsService: """Async Contacts service.""" return AsyncContactsService(http_client=self.http_client) + + @property + def messages(self) -> AsyncMessagesService: + """Async Messages service.""" + return AsyncMessagesService(http_client=self.http_client) diff --git a/tests/resources/notifications/test_messages.py b/tests/resources/notifications/test_messages.py new file mode 100644 index 0000000..64aaa71 --- /dev/null +++ b/tests/resources/notifications/test_messages.py @@ -0,0 +1,34 @@ +import pytest + +from mpt_api_client.resources.notifications.messages import ( + AsyncMessagesService, + MessagesService, +) + + +@pytest.fixture +def messages_service(http_client): + return MessagesService(http_client=http_client) + + +@pytest.fixture +def async_messages_service(async_http_client): + return AsyncMessagesService(http_client=async_http_client) + + +def test_messages_service_instance(messages_service): + assert isinstance(messages_service, MessagesService) + + +def test_async_messages_service_instance(async_messages_service): + assert isinstance(async_messages_service, AsyncMessagesService) + + +@pytest.mark.parametrize("method", ["get", "iterate"]) +def test_sync_messages_service_methods(messages_service, method): + assert hasattr(messages_service, method) + + +@pytest.mark.parametrize("method", ["get", "iterate"]) +def test_async_messages_service_methods(async_messages_service, method): + assert hasattr(async_messages_service, method) diff --git a/tests/resources/notifications/test_notifications.py b/tests/resources/notifications/test_notifications.py index 21eecc3..f06aabf 100644 --- a/tests/resources/notifications/test_notifications.py +++ b/tests/resources/notifications/test_notifications.py @@ -6,6 +6,7 @@ CategoriesService, ) from mpt_api_client.resources.notifications.contacts import AsyncContactsService, ContactsService +from mpt_api_client.resources.notifications.messages import AsyncMessagesService, MessagesService def test_notifications_init(http_client): @@ -27,6 +28,7 @@ def test_async_notifications_init(async_http_client): [ ("categories", CategoriesService), ("contacts", ContactsService), + ("messages", MessagesService), ], ) def test_notifications_properties(http_client, attr_name, expected): @@ -42,6 +44,7 @@ def test_notifications_properties(http_client, attr_name, expected): [ ("categories", AsyncCategoriesService), ("contacts", AsyncContactsService), + ("messages", AsyncMessagesService), ], ) def test_async_notifications_properties(http_client, attr_name, expected):