Skip to content

Commit 05ca5d8

Browse files
Updated to fix Transfer API so that it supports MicrosoftTeamsApp identifier (Azure#47477)
1 parent 1cf4ae5 commit 05ca5d8

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.net8.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,7 @@ internal TransferCallToParticipantResult() { }
18731873
public partial class TransferToParticipantOptions
18741874
{
18751875
public TransferToParticipantOptions(Azure.Communication.CommunicationUserIdentifier targetIdentity) { }
1876+
public TransferToParticipantOptions(Azure.Communication.MicrosoftTeamsAppIdentifier targetIdentity) { }
18761877
public TransferToParticipantOptions(Azure.Communication.MicrosoftTeamsUserIdentifier targetIdentity) { }
18771878
public TransferToParticipantOptions(Azure.Communication.PhoneNumberIdentifier targetPhoneNumberIdentity) { }
18781879
public Azure.Communication.CallAutomation.CustomCallingContext CustomCallingContext { get { throw null; } }

sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.netstandard2.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,7 @@ internal TransferCallToParticipantResult() { }
18721872
public partial class TransferToParticipantOptions
18731873
{
18741874
public TransferToParticipantOptions(Azure.Communication.CommunicationUserIdentifier targetIdentity) { }
1875+
public TransferToParticipantOptions(Azure.Communication.MicrosoftTeamsAppIdentifier targetIdentity) { }
18751876
public TransferToParticipantOptions(Azure.Communication.MicrosoftTeamsUserIdentifier targetIdentity) { }
18761877
public TransferToParticipantOptions(Azure.Communication.PhoneNumberIdentifier targetPhoneNumberIdentity) { }
18771878
public Azure.Communication.CallAutomation.CustomCallingContext CustomCallingContext { get { throw null; } }

sdk/communication/Azure.Communication.CallAutomation/src/CallConnection.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ public virtual async Task<Response<TransferCallToParticipantResult>> TransferCal
172172
{
173173
options = new TransferToParticipantOptions(targetParticipant as MicrosoftTeamsUserIdentifier);
174174
}
175+
else if (targetParticipant is MicrosoftTeamsAppIdentifier)
176+
{
177+
options = new TransferToParticipantOptions(targetParticipant as MicrosoftTeamsAppIdentifier);
178+
}
175179
else
176180
{
177181
throw new ArgumentException("targetParticipant type is invalid.", nameof(targetParticipant));

sdk/communication/Azure.Communication.CallAutomation/src/Models/TransferToParticipantOptions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ public TransferToParticipantOptions(MicrosoftTeamsUserIdentifier targetIdentity)
4141
CustomCallingContext = new CustomCallingContext(sipHeaders: null, voipHeaders: new Dictionary<string, string>());
4242
}
4343

44+
/// <summary>
45+
/// Creates a new TransferToParticipantOptions object.
46+
/// </summary>
47+
/// <param name="targetIdentity"> The target to transfer the call to. </param>
48+
public TransferToParticipantOptions(MicrosoftTeamsAppIdentifier targetIdentity)
49+
{
50+
Target = targetIdentity;
51+
CustomCallingContext = new CustomCallingContext(sipHeaders: null, voipHeaders: new Dictionary<string, string>());
52+
}
53+
4454
/// <summary>
4555
/// The target callee.
4656
/// </summary>

sdk/communication/Azure.Communication.CallAutomation/tests/CallConnections/CallConnectionTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ public async Task TransferCallToParticipantAsync_simpleMethod_202Accepted(CallIn
132132
verifyOperationContext(response);
133133
}
134134

135+
[TestCaseSource(nameof(TestData_TransferCallToParticipant_MicrosoftTeamsAppTarget))]
136+
public async Task TransferCallToParticipantAsync_simpleMethod_MicrosoftTeamsAppAsTarget_202Accepted(CallInvite callInvite)
137+
{
138+
var callConnection = CreateMockCallConnection(202, OperationContextPayload);
139+
140+
var response = await callConnection.TransferCallToParticipantAsync(callInvite.Target).ConfigureAwait(false);
141+
Assert.AreEqual((int)HttpStatusCode.Accepted, response.GetRawResponse().Status);
142+
verifyOperationContext(response);
143+
}
144+
135145
[TestCaseSource(nameof(TestData_TransferCallToParticipant))]
136146
public async Task TransferCallToParticipantAsync_202Accepted(CallInvite callInvite)
137147
{
@@ -555,6 +565,19 @@ private CallConnection CreateMockCallConnection(int responseCode, string? respon
555565
};
556566
}
557567

568+
private static IEnumerable<object?[]> TestData_TransferCallToParticipant_MicrosoftTeamsAppTarget()
569+
{
570+
var callInvite = new CallInvite(new MicrosoftTeamsAppIdentifier("userId"));
571+
callInvite.CustomCallingContext.AddVoip("key1", "value1");
572+
return new[]
573+
{
574+
new object?[]
575+
{
576+
callInvite
577+
},
578+
};
579+
}
580+
558581
private static IEnumerable<object?[]> TestData_GetParticipant()
559582
{
560583
return new[]

0 commit comments

Comments
 (0)