Skip to content

Commit

Permalink
[Communication] - Simplify identifier json models (#18389)
Browse files Browse the repository at this point in the history
* [Communication] - Simplify identifier json models

* Add validation for multiple properties being present
  • Loading branch information
RezaJooyandeh authored Feb 3, 2021
1 parent ca256b7 commit 1b5c007
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 209 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
namespace Azure.Communication
{
public partial class CallingApplicationIdentifier : Azure.Communication.CommunicationIdentifier
{
public CallingApplicationIdentifier(string id) { }
public string Id { get { throw null; } }
public override bool Equals(Azure.Communication.CommunicationIdentifier other) { throw null; }
public override int GetHashCode() { throw null; }
public override string ToString() { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct CommunicationCloudEnvironment : System.IEquatable<Azure.Communication.CommunicationCloudEnvironment>
{
Expand Down Expand Up @@ -56,20 +48,20 @@ public CommunicationUserIdentifier(string id) { }
}
public partial class MicrosoftTeamsUserIdentifier : Azure.Communication.CommunicationIdentifier
{
public MicrosoftTeamsUserIdentifier(string userId, bool isAnonymous = false, string id = null, Azure.Communication.CommunicationCloudEnvironment? cloud = default(Azure.Communication.CommunicationCloudEnvironment?)) { }
public MicrosoftTeamsUserIdentifier(string userId, bool isAnonymous = false, Azure.Communication.CommunicationCloudEnvironment? cloud = default(Azure.Communication.CommunicationCloudEnvironment?), string rawId = null) { }
public Azure.Communication.CommunicationCloudEnvironment Cloud { get { throw null; } }
public string Id { get { throw null; } }
public bool IsAnonymous { get { throw null; } }
public string RawId { get { throw null; } }
public string UserId { get { throw null; } }
public override bool Equals(Azure.Communication.CommunicationIdentifier other) { throw null; }
public override int GetHashCode() { throw null; }
public override string ToString() { throw null; }
}
public partial class PhoneNumberIdentifier : Azure.Communication.CommunicationIdentifier
{
public PhoneNumberIdentifier(string phoneNumber, string id = null) { }
public string Id { get { throw null; } }
public PhoneNumberIdentifier(string phoneNumber, string rawId = null) { }
public string PhoneNumber { get { throw null; } }
public string RawId { get { throw null; } }
public override bool Equals(Azure.Communication.CommunicationIdentifier other) { throw null; }
public override int GetHashCode() { throw null; }
public override string ToString() { throw null; }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace Azure.Communication
/// <summary>Represents a Microsoft Teams user.</summary>
public class MicrosoftTeamsUserIdentifier : CommunicationIdentifier
{
/// <summary>The full id of the Microsoft Teams User identifier.</summary>
public string Id { get; }
/// <summary>The optional raw id of the Microsoft Teams User identifier.</summary>
public string RawId { get; }

/// <summary>The id of the Microsoft Teams user. If the user isn't anonymous, the id is the AAD object id of the user.</summary>
public string UserId { get; }
Expand All @@ -25,21 +25,21 @@ public class MicrosoftTeamsUserIdentifier : CommunicationIdentifier
/// </summary>
/// <param name="userId">Id of the Microsoft Teams user. If the user isn't anonymous, the id is the AAD object id of the user.</param>
/// <param name="isAnonymous">Set this to true if the user is anonymous, for example when joining a meeting with a share link.</param>
/// <param name="id">Full id of the Microsoft Teams user, optional.</param>
/// <param name="cloud">The cloud that the Microsoft Team user belongs to. A null value translates to the Public cloud.</param>
/// <param name="rawId">Raw id of the Microsoft Teams user, optional.</param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when the <paramref name="userId"/> is null.
/// </exception>
/// <exception cref="System.ArgumentException">
/// Thrown when the <paramref name="userId"/> is empty.
/// </exception>
public MicrosoftTeamsUserIdentifier(string userId, bool isAnonymous = false, string id = null, CommunicationCloudEnvironment? cloud = null)
public MicrosoftTeamsUserIdentifier(string userId, bool isAnonymous = false, CommunicationCloudEnvironment? cloud = null, string rawId = null)
{
Argument.AssertNotNullOrEmpty(userId, nameof(userId));
UserId = userId;
IsAnonymous = isAnonymous;
Cloud = cloud ?? CommunicationCloudEnvironment.Public;
Id = id;
RawId = rawId;
}

/// <inheritdoc />
Expand All @@ -54,6 +54,6 @@ public override bool Equals(CommunicationIdentifier other)
&& otherId.UserId == UserId
&& otherId.IsAnonymous == IsAnonymous
&& otherId.Cloud == Cloud
&& (Id is null || otherId.Id is null || Id == otherId.Id);
&& (RawId is null || otherId.RawId is null || RawId == otherId.RawId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ namespace Azure.Communication
/// <summary>Represents a Phone Number.</summary>
public class PhoneNumberIdentifier : CommunicationIdentifier
{
/// <summary>The full id of the phone number.</summary>
public string Id { get; }
/// <summary>The optional raw id of the phone number.</summary>
public string RawId { get; }

/// <summary>The phone number in E.164 format.</summary>
public string PhoneNumber { get; }

/// <summary> Initializes a new instance of <see cref="PhoneNumberIdentifier"/>.</summary>
/// <param name="phoneNumber">The phone number in E.164 format.</param>
/// <param name="id">Full id of the phone number.</param>
/// <param name="rawId">Raw id of the phone number, optional.</param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when the <paramref name="phoneNumber"/> is null.
/// </exception>
/// <exception cref="System.ArgumentException">
/// Thrown when the <paramref name="phoneNumber"/> is empty.
/// </exception>
public PhoneNumberIdentifier(string phoneNumber, string id = null)
public PhoneNumberIdentifier(string phoneNumber, string rawId = null)
{
Argument.AssertNotNullOrEmpty(phoneNumber, nameof(phoneNumber));
PhoneNumber = phoneNumber;
Id = id;
RawId = rawId;
}

/// <inheritdoc />
Expand All @@ -38,6 +38,6 @@ public PhoneNumberIdentifier(string phoneNumber, string id = null)

/// <inheritdoc />
public override bool Equals(CommunicationIdentifier other)
=> other is PhoneNumberIdentifier otherId && otherId.PhoneNumber == PhoneNumber && (Id is null || otherId.Id is null || Id == otherId.Id);
=> other is PhoneNumberIdentifier otherId && otherId.PhoneNumber == PhoneNumber && (RawId is null || otherId.RawId is null || RawId == otherId.RawId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<Compile Include="$(AzureCoreSharedSources)ConnectionString.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
<Compile Include="..\..\Shared\src\HMACAuthenticationPolicy.cs" Link="Shared\Communication\%(RecursiveDir)\%(Filename)%(Extension)" />
<Compile Include="..\..\Shared\src\CommunicationBearerTokenCredential.cs" Link="Shared\Communication\%(RecursiveDir)\%(Filename)%(Extension)" />
<Compile Include="..\..\Shared\src\CommunicationIdentifierKind.cs" Link="Shared\Communication\%(RecursiveDir)\%(Filename)%(Extension)" />
<Compile Include="..\..\Shared\src\CommunicationIdentifierModel.cs" Link="Shared\Communication\%(RecursiveDir)\%(Filename)%(Extension)" />
<Compile Include="..\..\Shared\src\CommunicationIdentifierSerializer.cs" Link="Shared\Communication\%(RecursiveDir)\%(Filename)%(Extension)" />
<Compile Include="..\..\Shared\src\CommunicationCloudEnvironmentModel.cs" Link="Shared\Communication\%(RecursiveDir)\%(Filename)%(Extension)" />
Expand Down
Loading

0 comments on commit 1b5c007

Please sign in to comment.