2121)
2222from backoff .types import Details
2323
24- from pyoverkiz ._case import decamelize
2524from pyoverkiz .action_queue import ActionQueue , ActionQueueSettings
2625from pyoverkiz .auth import AuthStrategy , Credentials , build_auth_strategy
2726from pyoverkiz .const import SUPPORTED_SERVERS , USER_AGENT
28- from pyoverkiz .converter import converter
27+ from pyoverkiz .converter import converter , structure_response
2928from pyoverkiz .enums import APIType , ExecutionMode , Protocol , Server
3029from pyoverkiz .exceptions import (
3130 ExecutionQueueFullError ,
@@ -325,7 +324,7 @@ async def get_setup(self, refresh: bool = False) -> Setup:
325324
326325 response = await self ._get ("setup" )
327326
328- setup = converter . structure ( decamelize ( response ) , Setup )
327+ setup = structure_response ( response , Setup )
329328
330329 # Cache response
331330 self .setup = setup
@@ -373,7 +372,7 @@ async def get_devices(self, refresh: bool = False) -> list[Device]:
373372 return self .devices
374373
375374 response = await self ._get ("setup/devices" )
376- devices = converter . structure ( decamelize ( response ) , list [Device ])
375+ devices = structure_response ( response , list [Device ])
377376
378377 # Cache response
379378 self .devices = devices
@@ -392,7 +391,7 @@ async def get_gateways(self, refresh: bool = False) -> list[Gateway]:
392391 return self .gateways
393392
394393 response = await self ._get ("setup/gateways" )
395- gateways = converter . structure ( decamelize ( response ) , list [Gateway ])
394+ gateways = structure_response ( response , list [Gateway ])
396395
397396 # Cache response
398397 self .gateways = gateways
@@ -405,7 +404,7 @@ async def get_gateways(self, refresh: bool = False) -> list[Gateway]:
405404 async def get_execution_history (self ) -> list [HistoryExecution ]:
406405 """List past executions and their outcomes."""
407406 response = await self ._get ("history/executions" )
408- return converter . structure ( decamelize ( response ) , list [HistoryExecution ])
407+ return structure_response ( response , list [HistoryExecution ])
409408
410409 @retry_on_auth_error
411410 async def get_device_definition (self , deviceurl : str ) -> dict [str , Any ] | None :
@@ -422,7 +421,7 @@ async def get_state(self, deviceurl: str) -> list[State]:
422421 response = await self ._get (
423422 f"setup/devices/{ urllib .parse .quote_plus (deviceurl )} /states"
424423 )
425- return converter . structure ( decamelize ( response ) , list [State ])
424+ return structure_response ( response , list [State ])
426425
427426 @retry_on_auth_error
428427 async def refresh_states (self ) -> None :
@@ -465,7 +464,7 @@ async def fetch_events(self) -> list[Event]:
465464 operation (polling).
466465 """
467466 response = await self ._post (f"events/{ self .event_listener_id } /fetch" )
468- return converter . structure ( decamelize ( response ) , list [Event ])
467+ return structure_response ( response , list [Event ])
469468
470469 async def unregister_event_listener (self ) -> None :
471470 """Unregister an event listener.
@@ -485,13 +484,13 @@ async def get_current_execution(self, exec_id: str) -> Execution | None:
485484 if not response or not isinstance (response , dict ):
486485 return None
487486
488- return converter . structure ( decamelize ( response ) , Execution )
487+ return structure_response ( response , Execution )
489488
490489 @retry_on_auth_error
491490 async def get_current_executions (self ) -> list [Execution ]:
492491 """Get all currently running executions."""
493492 response = await self ._get ("exec/current" )
494- return converter . structure ( decamelize ( response ) , list [Execution ])
493+ return structure_response ( response , list [Execution ])
495494
496495 @retry_on_auth_error
497496 async def get_api_version (self ) -> str :
@@ -629,7 +628,7 @@ async def cancel_execution(self, exec_id: str) -> None:
629628 async def get_action_groups (self ) -> list [PersistedActionGroup ]:
630629 """List action groups persisted on the server."""
631630 response = await self ._get ("actionGroups" )
632- return converter . structure ( decamelize ( response ) , list [PersistedActionGroup ])
631+ return structure_response ( response , list [PersistedActionGroup ])
633632
634633 @retry_on_auth_error
635634 async def get_places (self ) -> Place :
@@ -644,7 +643,7 @@ async def get_places(self) -> Place:
644643 - `sub_places`: List of nested places within this location
645644 """
646645 response = await self ._get ("setup/places" )
647- return converter . structure ( decamelize ( response ) , Place )
646+ return structure_response ( response , Place )
648647
649648 @retry_on_auth_error
650649 async def execute_persisted_action_group (self , oid : str ) -> str :
@@ -666,7 +665,7 @@ async def get_setup_options(self) -> list[Option]:
666665 Access scope : Full enduser API access (enduser/*).
667666 """
668667 response = await self ._get ("setup/options" )
669- return converter . structure ( decamelize ( response ) , list [Option ])
668+ return structure_response ( response , list [Option ])
670669
671670 @retry_on_auth_error
672671 async def get_setup_option (self , option : str ) -> Option | None :
@@ -677,7 +676,7 @@ async def get_setup_option(self, option: str) -> Option | None:
677676 response = await self ._get (f"setup/options/{ option } " )
678677
679678 if response :
680- return converter . structure ( decamelize ( response ) , Option )
679+ return structure_response ( response , Option )
681680
682681 return None
683682
@@ -695,7 +694,7 @@ async def get_setup_option_parameter(
695694 response = await self ._get (f"setup/options/{ option } /{ parameter } " )
696695
697696 if response :
698- return converter . structure ( decamelize ( response ) , OptionParameter )
697+ return structure_response ( response , OptionParameter )
699698
700699 return None
701700
@@ -762,7 +761,7 @@ async def get_reference_ui_profile(self, profile_name: str) -> UIProfileDefiniti
762761 response = await self ._get (
763762 f"reference/ui/profile/{ urllib .parse .quote_plus (profile_name )} "
764763 )
765- return converter . structure ( decamelize ( response ) , UIProfileDefinition )
764+ return structure_response ( response , UIProfileDefinition )
766765
767766 @retry_on_auth_error
768767 async def get_reference_ui_profile_names (self ) -> list [str ]:
@@ -778,7 +777,7 @@ async def get_reference_ui_widgets(self) -> list[str]:
778777 async def get_devices_not_up_to_date (self ) -> list [Device ]:
779778 """Get all devices whose firmware is not up to date."""
780779 response = await self ._get ("setup/devices/notUpToDate" )
781- return converter . structure ( decamelize ( response ) , list [Device ])
780+ return structure_response ( response , list [Device ])
782781
783782 @retry_on_auth_error
784783 async def get_device_firmware_status (self , deviceurl : str ) -> FirmwareStatus | None :
@@ -792,7 +791,7 @@ async def get_device_firmware_status(self, deviceurl: str) -> FirmwareStatus | N
792791 )
793792 except UnsupportedOperationError :
794793 return None
795- return converter . structure ( decamelize ( response ) , FirmwareStatus )
794+ return structure_response ( response , FirmwareStatus )
796795
797796 @retry_on_auth_error
798797 async def get_device_firmware_update_capability (self , deviceurl : str ) -> bool :
0 commit comments