Merge branch 'v20260203-11-autotask-resolution-get-put-required-fields' into main

This commit is contained in:
Ivo Oskamp 2026-02-06 13:23:31 +01:00
commit 02d7bdd5b8
2 changed files with 19 additions and 1 deletions

View File

@ -1 +1 @@
v20260203-10-autotask-resolution-field-aliases v20260203-11-autotask-resolution-get-put-required-fields

View File

@ -605,9 +605,27 @@ class AutotaskClient:
} }
def _get_first(ticket_obj: Dict[str, Any], keys: list[str]) -> Any: def _get_first(ticket_obj: Dict[str, Any], keys: list[str]) -> Any:
"""Return first matching value for any of the given keys.
Autotask field casing / suffixes can vary by tenant and API surface.
We therefore try direct lookups first and then fall back to a
case-insensitive scan of the ticket payload keys.
"""
if not isinstance(ticket_obj, dict):
return None
# Direct lookups (fast path)
for k in keys: for k in keys:
if k in ticket_obj: if k in ticket_obj:
return ticket_obj.get(k) return ticket_obj.get(k)
# Case-insensitive fallback
lower_map = {str(k).lower(): k for k in ticket_obj.keys()}
for k in keys:
lk = str(k).lower()
if lk in lower_map:
return ticket_obj.get(lower_map[lk])
return None return None
stabilising_fields = list(field_sources.keys()) stabilising_fields = list(field_sources.keys())