From 05db36dad2bea2b34c1dc1ad348fec51359714c4 Mon Sep 17 00:00:00 2001 From: Arshdeep singh Date: Mon, 14 Sep 2026 22:10:58 +0530 Subject: [PATCH] fix: apply phone alias to recipients lists The TypeScript SDK maps phone to phones on every recipient object. Python only did that for the singular recipient= argument. Co-authored-by: Cursor --- CHANGELOG.md | 5 +++++ src/calle/calls.py | 8 +++++++- tests/test_calls.py | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52a1a81..f5bf989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht ## [Unreleased] +### Fixed + +- `recipients=[{"phone": ...}]` now applies the same `phone` → `phones` alias + as the singular `recipient=` argument. + ## [0.7.1] - 2026-09-04 ### Added diff --git a/src/calle/calls.py b/src/calle/calls.py index a3cb6ee..37466d7 100644 --- a/src/calle/calls.py +++ b/src/calle/calls.py @@ -30,7 +30,13 @@ def create( raise ValueError("Pass either recipient or recipients, not both.") body = { "task": task, - "recipients": [_normalize_recipient(recipient)] if recipient is not None else recipients, + "recipients": ( + [_normalize_recipient(recipient)] + if recipient is not None + else [_normalize_recipient(item) for item in recipients] + if recipients is not None + else None + ), "result_schema": result_schema, "recipient_result_schema": recipient_result_schema, "metadata": metadata, diff --git a/tests/test_calls.py b/tests/test_calls.py index b0b9796..cf4c177 100644 --- a/tests/test_calls.py +++ b/tests/test_calls.py @@ -94,6 +94,20 @@ def test_create_call_sends_auth_and_idempotency_headers() -> None: assert "result_validation" not in call +@respx.mock +def test_create_call_aliases_phone_on_recipients_list() -> None: + route = respx.post("https://api.heycall-e.com/v1/calls").mock(return_value=httpx.Response(200, json=COMPLETED_CALL)) + client = CalleClient(api_key="key_test", base_url="https://api.heycall-e.com") + + client.calls.create( + task="Call.", + recipients=[{"phone": "+14155550100", "region": "US", "locale": "en-US"}], + ) + + payload = json.loads(route.calls.last.request.content) + assert payload["recipients"] == [{"phones": ["+14155550100"], "region": "US", "locale": "en-US"}] + + @respx.mock def test_create_call_can_send_task_only_request() -> None: route = respx.post("https://api.heycall-e.com/v1/calls").mock(return_value=httpx.Response(200, json=COMPLETED_CALL))