Skip to content

Commit 346f011

Browse files
authored
Resolved CustomCallingContextInternal Sip/Voip Header swap issue + Unit Test for IncomingCall Event (Azure#48727)
* Modified headers for CustomCallingContextInternal. * Added unit test for Incoming Call Event. Added IncomingCall to CallAutomationModelFactory. * Exported latest API * Modified CustomCallingContext.cs initialization for SipHeaders and VoipHeaders. * Modified CustomCallingContextInternal initialization of headers in CallAutomationClient.cs * Swapped Sip/Voip Headers in CustomCallingContext.cs and references. Updated headers in Incoming Call unit test. * Fix autorest package.
1 parent a456a9d commit 346f011

10 files changed

+100
-20
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
@@ -229,6 +229,7 @@ public static partial class CallAutomationModelFactory
229229
public static Azure.Communication.CallAutomation.HoldAudioResumed HoldAudioResumed(string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }
230230
public static Azure.Communication.CallAutomation.HoldAudioStarted HoldAudioStarted(string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }
231231
public static Azure.Communication.CallAutomation.HoldFailed HoldFailed(string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }
232+
public static Azure.Communication.CallAutomation.IncomingCall IncomingCall(Azure.Communication.CommunicationIdentifier to = null, Azure.Communication.CommunicationIdentifier from = null, string callerDisplayName = null, string serverCallId = null, Azure.Communication.CallAutomation.CustomCallingContext customContext = null, string incomingCallContext = null, Azure.Communication.CommunicationIdentifier onBehalfOfCallee = null, string correlationId = null) { throw null; }
232233
public static Azure.Communication.CallAutomation.MediaStreamingFailed MediaStreamingFailed(Azure.Communication.CallAutomation.MediaStreamingUpdate mediaStreamingUpdate = null, string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }
233234
public static Azure.Communication.CallAutomation.MediaStreamingStarted MediaStreamingStarted(Azure.Communication.CallAutomation.MediaStreamingUpdate mediaStreamingUpdate = null, string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }
234235
public static Azure.Communication.CallAutomation.MediaStreamingStopped MediaStreamingStopped(Azure.Communication.CallAutomation.MediaStreamingUpdate mediaStreamingUpdate = null, string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { 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
@@ -229,6 +229,7 @@ public static partial class CallAutomationModelFactory
229229
public static Azure.Communication.CallAutomation.HoldAudioResumed HoldAudioResumed(string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }
230230
public static Azure.Communication.CallAutomation.HoldAudioStarted HoldAudioStarted(string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }
231231
public static Azure.Communication.CallAutomation.HoldFailed HoldFailed(string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }
232+
public static Azure.Communication.CallAutomation.IncomingCall IncomingCall(Azure.Communication.CommunicationIdentifier to = null, Azure.Communication.CommunicationIdentifier from = null, string callerDisplayName = null, string serverCallId = null, Azure.Communication.CallAutomation.CustomCallingContext customContext = null, string incomingCallContext = null, Azure.Communication.CommunicationIdentifier onBehalfOfCallee = null, string correlationId = null) { throw null; }
232233
public static Azure.Communication.CallAutomation.MediaStreamingFailed MediaStreamingFailed(Azure.Communication.CallAutomation.MediaStreamingUpdate mediaStreamingUpdate = null, string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }
233234
public static Azure.Communication.CallAutomation.MediaStreamingStarted MediaStreamingStarted(Azure.Communication.CallAutomation.MediaStreamingUpdate mediaStreamingUpdate = null, string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }
234235
public static Azure.Communication.CallAutomation.MediaStreamingStopped MediaStreamingStopped(Azure.Communication.CallAutomation.MediaStreamingUpdate mediaStreamingUpdate = null, string callConnectionId = null, string serverCallId = null, string correlationId = null, string operationContext = null, Azure.Communication.CallAutomation.ResultInformation resultInformation = null) { throw null; }

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ private AnswerCallRequestInternal CreateAnswerCallRequest(AnswerCallOptions opti
258258
request.AnsweredBy = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id);
259259
request.OperationContext = options.OperationContext;
260260
request.CustomCallingContext = new CustomCallingContextInternal(
261-
options.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>(),
262-
options.CustomCallingContext?.VoipHeaders ?? new ChangeTrackingDictionary<string, string>());
261+
options.CustomCallingContext?.VoipHeaders ?? new ChangeTrackingDictionary<string, string>(),
262+
options.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>());
263263

264264
return request;
265265
}
@@ -295,8 +295,8 @@ public virtual async Task<Response> RedirectCallAsync(RedirectCallOptions option
295295
RedirectCallRequestInternal request = new RedirectCallRequestInternal(options.IncomingCallContext, CommunicationIdentifierSerializer.Serialize(options.CallInvite.Target));
296296

297297
request.CustomCallingContext = new CustomCallingContextInternal(
298-
options.CallInvite.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders,
299-
options.CallInvite.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.VoipHeaders);
298+
options.CallInvite.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.VoipHeaders,
299+
options.CallInvite.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders);
300300

301301
return await AzureCommunicationServicesRestClient.RedirectCallAsync(request, cancellationToken).ConfigureAwait(false);
302302
}
@@ -338,8 +338,8 @@ public virtual Response RedirectCall(RedirectCallOptions options, CancellationTo
338338
RedirectCallRequestInternal request = new RedirectCallRequestInternal(options.IncomingCallContext, CommunicationIdentifierSerializer.Serialize(options.CallInvite.Target));
339339

340340
request.CustomCallingContext = new CustomCallingContextInternal(
341-
options.CallInvite.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders,
342-
options.CallInvite.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.VoipHeaders);
341+
options.CallInvite.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.VoipHeaders,
342+
options.CallInvite.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders);
343343

344344
return AzureCommunicationServicesRestClient.RedirectCall(request, cancellationToken);
345345
}
@@ -729,8 +729,8 @@ private CreateCallRequestInternal CreateCallRequest(CreateCallOptions options)
729729
};
730730

731731
request.CustomCallingContext = new CustomCallingContextInternal(
732-
options.CallInvite.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders,
733-
options.CallInvite.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.VoipHeaders);
732+
options.CallInvite.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.VoipHeaders,
733+
options.CallInvite.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders);
734734

735735
// Add CallIntelligenceOptions such as custom cognitive service domain name
736736
string cognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri;
@@ -766,8 +766,8 @@ private CreateCallRequestInternal CreateCallRequest(CreateGroupCallOptions optio
766766
};
767767

768768
request.CustomCallingContext = new CustomCallingContextInternal(
769-
options.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CustomCallingContext.SipHeaders,
770-
options.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CustomCallingContext.VoipHeaders);
769+
options.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CustomCallingContext.VoipHeaders,
770+
options.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CustomCallingContext.SipHeaders);
771771

772772
// Add CallIntelligenceOptions such as custom cognitive service domain name
773773
string cognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ private static TransferToParticipantRequestInternal CreateTransferToParticipantR
283283
TransferToParticipantRequestInternal request = new(CommunicationIdentifierSerializer.Serialize(options.Target))
284284
{
285285
CustomCallingContext = new CustomCallingContextInternal(
286-
options.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>(),
287-
options.CustomCallingContext?.VoipHeaders ?? new ChangeTrackingDictionary<string, string>()),
286+
options.CustomCallingContext?.VoipHeaders ?? new ChangeTrackingDictionary<string, string>(),
287+
options.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>()),
288288
OperationContext = options.OperationContext == default ? Guid.NewGuid().ToString() : options.OperationContext,
289289
Transferee = options.Transferee == default ? null : CommunicationIdentifierSerializer.Serialize(options.Transferee),
290290
OperationCallbackUri = options.OperationCallbackUri?.AbsoluteUri,
@@ -386,8 +386,8 @@ private static AddParticipantRequestInternal CreateAddParticipantRequest(AddPart
386386
AddParticipantRequestInternal request = new(CommunicationIdentifierSerializer.Serialize(options.ParticipantToAdd.Target))
387387
{
388388
CustomCallingContext = new CustomCallingContextInternal(
389-
options.ParticipantToAdd.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>(),
390-
options.ParticipantToAdd.CustomCallingContext?.VoipHeaders ?? new ChangeTrackingDictionary<string, string>()
389+
options.ParticipantToAdd.CustomCallingContext?.VoipHeaders ?? new ChangeTrackingDictionary<string, string>(),
390+
options.ParticipantToAdd.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>()
391391
),
392392
SourceCallerIdNumber = options.ParticipantToAdd.SourceCallerIdNumber == null
393393
? null

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,5 +636,32 @@ public static CreateCallFailed CreateCallFailed(
636636
var createdCallFailedInternal = new CreateCallFailedInternal(callConnectionId, serverCallId, correlationId, operationContext, resultInformation);
637637
return new CreateCallFailed(createdCallFailedInternal);
638638
}
639+
640+
/// <summary> Initializes a new instance of IncomingCall. </summary>
641+
/// <param name="to"> The recipient of the call. </param>
642+
/// <param name="from"> The caller initiating the call.</param>
643+
/// <param name="callerDisplayName"> The display name of the caller. </param>
644+
/// <param name="serverCallId"> Server call ID. </param>
645+
/// <param name="customContext"> Custom Sip and Voip Headers of call.</param>
646+
/// <param name="incomingCallContext"> The context of the incoming call. </param>
647+
/// <param name="onBehalfOfCallee"> The identifier of the user on whose behalf the call is received.</param>
648+
/// <param name="correlationId"> The correlation ID for tracking the event. </param>
649+
/// <returns>A new <see cref="CallAutomation.IncomingCall"/> instance for mocking. </returns>
650+
public static IncomingCall IncomingCall(CommunicationIdentifier to = null, CommunicationIdentifier @from = null, string callerDisplayName = null, string serverCallId = null,
651+
CustomCallingContext customContext = null, string incomingCallContext = null, CommunicationIdentifier onBehalfOfCallee = null, string correlationId = null)
652+
{
653+
var internalObject = new IncomingCallInternal(
654+
to == null ? null : CommunicationIdentifierSerializer.Serialize(to),
655+
@from == null ? null : CommunicationIdentifierSerializer.Serialize(@from),
656+
callerDisplayName,
657+
serverCallId,
658+
customContext == null ? null : new CustomCallingContextInternal(customContext.VoipHeaders, customContext.SipHeaders),
659+
incomingCallContext,
660+
onBehalfOfCallee == null ? null : CommunicationIdentifierSerializer.Serialize(onBehalfOfCallee),
661+
correlationId
662+
);
663+
664+
return new IncomingCall(internalObject);
665+
}
639666
}
640667
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public class CustomCallingContext
2020
/// <summary>
2121
/// Creates a new CustomCallingContext.
2222
/// </summary>
23-
internal CustomCallingContext(IDictionary<string, string> sipHeaders, IDictionary<string, string> voipHeaders)
23+
internal CustomCallingContext(IDictionary<string, string> voipHeaders, IDictionary<string, string> sipHeaders)
2424
{
25-
SipHeaders = sipHeaders;
26-
VoipHeaders = voipHeaders;
25+
SipHeaders = sipHeaders ?? new ChangeTrackingDictionary<string, string>();
26+
VoipHeaders = voipHeaders ?? new ChangeTrackingDictionary<string, string>();
2727
}
2828

2929
/// <summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Azure.Communication.CallAutomation
1010
[CodeGenModel("CustomCallingContext", Usage = new string[] { "output" }, Formats = new string[] { "json" })]
1111
internal partial class CustomCallingContextInternal
1212
{
13-
public CustomCallingContextInternal(IDictionary<string, string> sipHeaders, IDictionary<string, string> voipHeaders)
13+
public CustomCallingContextInternal(IDictionary<string, string> voipHeaders, IDictionary<string, string> sipHeaders)
1414
{
1515
SipHeaders = sipHeaders;
1616
VoipHeaders = voipHeaders;

sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/IncomingCall.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal IncomingCall(IncomingCallInternal internalEvent)
2323
From = CommunicationIdentifierSerializer.Deserialize(internalEvent.From);
2424
ServerCallId = internalEvent.ServerCallId;
2525
CallerDisplayName = internalEvent.CallerDisplayName;
26-
CustomContext = new CustomCallingContext(internalEvent.CustomContext.SipHeaders, internalEvent.CustomContext.VoipHeaders);
26+
CustomContext = new CustomCallingContext(internalEvent.CustomContext.VoipHeaders, internalEvent.CustomContext.SipHeaders);
2727
IncomingCallContext = internalEvent.IncomingCallContext;
2828

2929
if (internalEvent.OnBehalfOfCallee != null)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class TransferToParticipantOptions
1818
public TransferToParticipantOptions(PhoneNumberIdentifier targetPhoneNumberIdentity)
1919
{
2020
Target = targetPhoneNumberIdentity;
21-
CustomCallingContext = new CustomCallingContext(sipHeaders: new Dictionary<string, string>(), null);
21+
CustomCallingContext = new CustomCallingContext(sipHeaders: new Dictionary<string, string>(), voipHeaders: null);
2222
}
2323

2424
/// <summary>

0 commit comments

Comments
 (0)