diff --git a/pybotx/__init__.py b/pybotx/__init__.py index e760ac43..fb8f60d5 100644 --- a/pybotx/__init__.py +++ b/pybotx/__init__.py @@ -62,6 +62,8 @@ from pybotx.client.smartapps_api.exceptions import SyncSmartAppEventHandlerNotFoundError from pybotx.client.smartapps_api.smartapp_manifest import ( SmartappManifest, + SmartappManifestAndroidParams, + SmartappManifestIosParams, SmartappManifestUnreadCounterParams, SmartappManifestWebParams, ) @@ -235,8 +237,10 @@ "SmartApp", "SmartAppEvent", "SmartappManifest", - "SmartappManifestWebLayoutChoices", + "SmartappManifestAndroidParams", + "SmartappManifestIosParams", "SmartappManifestUnreadCounterParams", + "SmartappManifestWebLayoutChoices", "SmartappManifestWebParams", "StatusRecipient", "StealthModeDisabledError", diff --git a/pybotx/bot/bot.py b/pybotx/bot/bot.py index 013fb3da..e1e8ce3d 100644 --- a/pybotx/bot/bot.py +++ b/pybotx/bot/bot.py @@ -138,6 +138,8 @@ from pybotx.client.smartapps_api.smartapp_manifest import ( BotXAPISmartAppManifestRequestPayload, SmartappManifest, + SmartappManifestAndroidParams, + SmartappManifestIosParams, SmartAppManifestMethod, SmartappManifestUnreadCounterParams, SmartappManifestWebParams, @@ -1548,12 +1550,16 @@ async def send_smartapp_manifest( self, *, bot_id: UUID, + ios: Missing[SmartappManifestIosParams] = Undefined, + android: Missing[SmartappManifestAndroidParams] = Undefined, web_layout: Missing[SmartappManifestWebParams] = Undefined, unread_counter: Missing[SmartappManifestUnreadCounterParams] = Undefined, ) -> SmartappManifest: """Send smartapp manifest with given parameters. :param bot_id: Bot which should perform the request. + :param ios: Smartapp layout for ios clients. + :param android: Smartapp layout for android clients. :param web_layout: Smartapp layout for web clients. :param unread_counter: Entities that can be subscribed to in the unread counter. @@ -1566,6 +1572,8 @@ async def send_smartapp_manifest( self._bot_accounts_storage, ) payload = BotXAPISmartAppManifestRequestPayload.from_domain( + ios=ios, + android=android, web_layout=web_layout, unread_counter=unread_counter, ) diff --git a/pybotx/client/smartapps_api/smartapp_manifest.py b/pybotx/client/smartapps_api/smartapp_manifest.py index b315b7fb..53e0a4ec 100644 --- a/pybotx/client/smartapps_api/smartapp_manifest.py +++ b/pybotx/client/smartapps_api/smartapp_manifest.py @@ -9,6 +9,14 @@ from pybotx.models.enums import SmartappManifestWebLayoutChoices as WebLayoutChoices +class SmartappManifestIosParams(VerifiedPayloadBaseModel): + fullscreen_layout: bool = False + + +class SmartappManifestAndroidParams(VerifiedPayloadBaseModel): + fullscreen_layout: bool = False + + class SmartappManifestWebParams(VerifiedPayloadBaseModel): default_layout: WebLayoutChoices = WebLayoutChoices.minimal expanded_layout: WebLayoutChoices = WebLayoutChoices.half @@ -22,11 +30,15 @@ class SmartappManifestUnreadCounterParams(VerifiedPayloadBaseModel): class SmartappManifest(VerifiedPayloadBaseModel): + ios: SmartappManifestIosParams + android: SmartappManifestAndroidParams web: SmartappManifestWebParams unread_counter_link: SmartappManifestUnreadCounterParams class SmartappManifestPayload(UnverifiedPayloadBaseModel): + ios: Missing[SmartappManifestIosParams] = Undefined + android: Missing[SmartappManifestAndroidParams] = Undefined web: Missing[SmartappManifestWebParams] = Undefined unread_counter_link: Missing[SmartappManifestUnreadCounterParams] = Undefined @@ -37,6 +49,8 @@ class BotXAPISmartAppManifestRequestPayload(UnverifiedPayloadBaseModel): @classmethod def from_domain( cls, + ios: Missing[SmartappManifestIosParams] = Undefined, + android: Missing[SmartappManifestAndroidParams] = Undefined, web_layout: Missing[SmartappManifestWebParams] = Undefined, unread_counter: Missing[SmartappManifestUnreadCounterParams] = Undefined, ) -> "BotXAPISmartAppManifestRequestPayload": @@ -45,6 +59,8 @@ def from_domain( return cls( manifest=SmartappManifestPayload( + ios=ios, + android=android, web=web_layout, unread_counter_link=unread_counter, ), diff --git a/pyproject.toml b/pyproject.toml index 4e012860..f98875e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pybotx" -version = "0.71.0" +version = "0.72.0" description = "A python library for interacting with eXpress BotX API" authors = [ "Sidnev Nikolay ", diff --git a/tests/client/smartapps_api/test_smartapp_manifest.py b/tests/client/smartapps_api/test_smartapp_manifest.py index d906cfd6..6916882c 100644 --- a/tests/client/smartapps_api/test_smartapp_manifest.py +++ b/tests/client/smartapps_api/test_smartapp_manifest.py @@ -15,6 +15,8 @@ lifespan_wrapper, ) from pybotx.client.smartapps_api.smartapp_manifest import ( + SmartappManifestAndroidParams, + SmartappManifestIosParams, SmartappManifestUnreadCounterParams, ) @@ -37,6 +39,12 @@ async def test__send_smartapp_manifest__all_params_provided__succeed( headers={"Authorization": "Bearer token", "Content-Type": "application/json"}, json={ "manifest": { + "ios": { + "fullscreen_layout": False, + }, + "android": { + "fullscreen_layout": False, + }, "web": { "always_pinned": True, "default_layout": "full", @@ -54,6 +62,12 @@ async def test__send_smartapp_manifest__all_params_provided__succeed( HTTPStatus.ACCEPTED, json={ "result": { + "ios": { + "fullscreen_layout": False, + }, + "android": { + "fullscreen_layout": False, + }, "web": { "always_pinned": True, "default_layout": "full", @@ -76,6 +90,12 @@ async def test__send_smartapp_manifest__all_params_provided__succeed( async with lifespan_wrapper(built_bot) as bot: smartapp_manifest = await bot.send_smartapp_manifest( bot_id=bot_id, + ios=SmartappManifestIosParams( + fullscreen_layout=False, + ), + android=SmartappManifestAndroidParams( + fullscreen_layout=False, + ), web_layout=SmartappManifestWebParams( default_layout=SmartappManifestWebLayoutChoices.full, expanded_layout=SmartappManifestWebLayoutChoices.full, @@ -91,6 +111,12 @@ async def test__send_smartapp_manifest__all_params_provided__succeed( # - Assert - assert endpoint.called assert smartapp_manifest == SmartappManifest( + ios=SmartappManifestIosParams( + fullscreen_layout=False, + ), + android=SmartappManifestAndroidParams( + fullscreen_layout=False, + ), web=SmartappManifestWebParams( default_layout=SmartappManifestWebLayoutChoices.full, expanded_layout=SmartappManifestWebLayoutChoices.full, @@ -122,6 +148,12 @@ async def test__send_smartapp_manifest__only_default_params_provided__succeed( HTTPStatus.ACCEPTED, json={ "result": { + "ios": { + "fullscreen_layout": False, + }, + "android": { + "fullscreen_layout": False, + }, "web": { "always_pinned": False, "default_layout": "minimal", @@ -147,6 +179,12 @@ async def test__send_smartapp_manifest__only_default_params_provided__succeed( # - Assert - assert endpoint.called assert smartapp_manifest == SmartappManifest( + ios=SmartappManifestIosParams( + fullscreen_layout=False, + ), + android=SmartappManifestAndroidParams( + fullscreen_layout=False, + ), web=SmartappManifestWebParams( default_layout=SmartappManifestWebLayoutChoices.minimal, expanded_layout=SmartappManifestWebLayoutChoices.half,