Skip to content

Commit c11b2e2

Browse files
authored
remove callinvite from transfer (Azure#30247)
1 parent 02f9ebe commit c11b2e2

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_call_connection_client.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6-
from typing import TYPE_CHECKING, Optional, List, Union
6+
from typing import TYPE_CHECKING, Optional, List, Union, Dict
77
from urllib.parse import urlparse
88
from azure.core.paging import ItemPaged
99
from azure.core.tracing.decorator import distributed_trace
@@ -198,29 +198,33 @@ def list_participants(self, **kwargs) -> ItemPaged[CallParticipant]:
198198
@distributed_trace
199199
def transfer_call_to_participant(
200200
self,
201-
target_participant: 'CallInvite',
201+
target_participant: 'CommunicationIdentifier',
202202
*,
203+
sip_headers: Optional[Dict[str, str]] = None,
204+
voip_headers: Optional[Dict[str, str]] = None,
203205
operation_context: Optional[str] = None,
204206
**kwargs
205207
) -> TransferCallResult:
206208
"""Transfer this call to another participant.
207209
208210
:param target_participant: The transfer target.
209-
:type target_participant: CallInvite
211+
:type target_participant: CommunicationIdentifier
212+
:keyword sip_headers: Custom context for PSTN
213+
:paramtype sip_headers: dict[str, str]
214+
:keyword voip_headers: Custom context for VOIP
215+
:paramtype voip_headers: dict[str, str]
210216
:keyword operation_context: Value that can be used to track this call and its associated events.
211217
:paramtype operation_context: str
212218
:return: TransferCallResult
213219
:rtype: ~azure.communication.callautomation.TransferCallResult
214220
:raises ~azure.core.exceptions.HttpResponseError:
215221
"""
216222
user_custom_context = CustomContext(
217-
voip_headers=target_participant.voip_headers,
218-
sip_headers=target_participant.sip_headers
219-
) if target_participant.sip_headers or target_participant.voip_headers else None
223+
voip_headers=voip_headers,
224+
sip_headers=sip_headers
225+
) if sip_headers or voip_headers else None
220226
request = TransferToParticipantRequest(
221-
target_participant=serialize_identifier(target_participant.target),
222-
transferee_caller_id=serialize_identifier(
223-
target_participant.source_caller_id_number) if target_participant.source_caller_id_number else None,
227+
target_participant=serialize_identifier(target_participant),
224228
custom_context=user_custom_context, operation_context=operation_context)
225229

226230
return self._call_connection_client.transfer_to_participant(

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class CallInvite(object):
4949
:ivar source_display_name: Set display name for caller
5050
:vartype source_display_name: str
5151
:ivar sip_headers: Custom context for PSTN
52-
:vartype sip_headers: str
52+
:vartype sip_headers: dict[str, str]
5353
:ivar voip_headers: Custom context for VOIP
54-
:vartype voip_headers: str
54+
:vartype voip_headers: dict[str, str]
5555
"""
5656
def __init__(
5757
self,

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/aio/_call_connection_client_async.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6-
from typing import TYPE_CHECKING, Optional, List, Union
6+
from typing import TYPE_CHECKING, Optional, List, Union, Dict
77
from urllib.parse import urlparse
88
from azure.core.async_paging import AsyncItemPaged
99
from azure.core.tracing.decorator import distributed_trace
@@ -203,29 +203,33 @@ def list_participants(self, **kwargs) -> AsyncItemPaged[CallParticipant]:
203203
@distributed_trace_async
204204
async def transfer_call_to_participant(
205205
self,
206-
target_participant: 'CallInvite',
206+
target_participant: 'CommunicationIdentifier',
207207
*,
208+
sip_headers: Optional[Dict[str, str]] = None,
209+
voip_headers: Optional[Dict[str, str]] = None,
208210
operation_context: Optional[str] = None,
209211
**kwargs
210212
) -> TransferCallResult:
211213
"""Transfer the call to a participant.
212214
213215
:param target_participant: The transfer target.
214-
:type target_participant: CallInvite
216+
:type target_participant: CommunicationIdentifier
217+
:keyword sip_headers: Custom context for PSTN
218+
:paramtype sip_headers: dict[str, str]
219+
:keyword voip_headers: Custom context for VOIP
220+
:paramtype voip_headers: dict[str, str]
215221
:keyword operation_context: Value that can be used to track the call and its associated events.
216222
:paramtype operation_context: str
217223
:return: TransferCallResult
218224
:rtype: ~azure.communication.callautomation.TransferCallResult
219225
:raises ~azure.core.exceptions.HttpResponseError:
220226
"""
221227
user_custom_context = CustomContext(
222-
voip_headers=target_participant.voip_headers,
223-
sip_headers=target_participant.sip_headers
224-
) if target_participant.sip_headers or target_participant.voip_headers else None
228+
voip_headers=voip_headers,
229+
sip_headers=sip_headers
230+
) if sip_headers or voip_headers else None
225231
request = TransferToParticipantRequest(
226-
target_participant=serialize_identifier(target_participant.target),
227-
transferee_caller_id=serialize_identifier(
228-
target_participant.source_caller_id_number) if target_participant.source_caller_id_number else None,
232+
target_participant=serialize_identifier(target_participant),
229233
custom_context=user_custom_context, operation_context=operation_context)
230234

231235
return await self._call_connection_client.transfer_to_participant(

sdk/communication/azure-communication-callautomation/tests/test_call_connection_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ def mock_send(*_, **__):
7878
call_connection_id=self.call_connection_id,
7979
transport=Mock(send=mock_send))
8080
user = CommunicationUserIdentifier(self.communication_user_id)
81-
call_invite = CallInvite(target=user)
8281
try:
83-
response = call_connection.transfer_call_to_participant(call_invite)
82+
response = call_connection.transfer_call_to_participant(user)
8483
except:
8584
raised = True
8685
raise

0 commit comments

Comments
 (0)