Skip to content

Commit

Permalink
Merge pull request #132 from lavy-blaggan/add-conferencing-profiles
Browse files Browse the repository at this point in the history
Added support for conferencing_profiles in userinfo endpoint
  • Loading branch information
CronofyMatt committed Mar 26, 2024
2 parents 6a2d4a5 + 48b08fc commit 16f3703
Show file tree
Hide file tree
Showing 3 changed files with 295 additions and 72 deletions.
85 changes: 82 additions & 3 deletions src/Cronofy/Responses/UserInfoResponse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Cronofy.Responses
namespace Cronofy.Responses
{
using System;
using System.Linq;
Expand Down Expand Up @@ -46,6 +46,7 @@ public UserInfo ToUserInfo()
Sub = this.Sub,
CronofyType = this.CronofyType,
Profiles = this.Data?.Profiles?.Select((p) => p.ToProfile()).ToArray(),
ConferencingProfiles = this.Data?.ConferencingProfiles?.Select((cp) => cp.ToConferencingProfile()).ToArray(),
ServiceAccountInfo = this.Data?.ServiceAccount?.ToServiceAccount(),
AuthorizationInfo = this.Data?.Authorization?.ToAuthorization(),
Email = this.Email,
Expand Down Expand Up @@ -77,7 +78,14 @@ internal sealed class CronofyData
/// <value>The profiles.</value>
[JsonProperty("profiles")]
public ProfileResponse[] Profiles { get; set; }
}

/// <summary>
/// Gets or sets the profiles.
/// </summary>
/// <value>The conferencing profiles.</value>
[JsonProperty("conferencing_profiles")]
public ConferencingProfileResponse[] ConferencingProfiles { get; set; }
}

/// <summary>
/// Class for the deserialization of a service account within a UserProfile.
Expand Down Expand Up @@ -264,5 +272,76 @@ public UserInfo.Profile ToProfile()
};
}
}
}

/// <summary>
/// Class for the deserialization of a conferencing profile response.
/// </summary>
internal sealed class ConferencingProfileResponse
{
/// <summary>
/// Gets or sets the name of the provider.
/// </summary>
/// <value>
/// The name of the provider.
/// </value>
[JsonProperty("provider_name")]
public string ProviderName { get; set; }

/// <summary>
/// Gets or sets the ID of the profile.
/// </summary>
/// <value>
/// The ID of the profile.
/// </value>
[JsonProperty("profile_id")]
public string ProfileId { get; set; }

/// <summary>
/// Gets or sets the name of the profile.
/// </summary>
/// <value>
/// The name of the profile.
/// </value>
[JsonProperty("profile_name")]
public string ProfileName { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this profile is
/// connected.
/// </summary>
/// <value>
/// <c>true</c> if the profile is connected; otherwise,
/// <c>false</c>.
/// </value>
[JsonProperty("profile_connected")]
public bool ProfileConnected { get; set; }

/// <summary>
/// Gets or sets the relink URL for the profile.
/// </summary>
/// <value>
/// The relink URL for the profile.
/// </value>
[JsonProperty("profile_relink_url")]
public string ProfileRelinkUrl { get; set; }

/// <summary>
/// Converts the response into a <see cref="Cronofy.UserInfo.ConferencingProfile"/>.
/// </summary>
/// <returns>
/// A <see cref="Cronofy.UserInfo.ConferencingProfile"/> based upon the response.
/// </returns>
public UserInfo.ConferencingProfile ToConferencingProfile()
{
return new UserInfo.ConferencingProfile
{
ProviderName = this.ProviderName,
Id = this.ProfileId,
Name = this.ProfileName,
Connected = this.ProfileConnected,
RelinkUrl = this.ProfileRelinkUrl,
};
}
}
}
}
245 changes: 178 additions & 67 deletions src/Cronofy/UserInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Cronofy
namespace Cronofy
{
using System.Linq;

Expand Down Expand Up @@ -29,6 +29,12 @@ public class UserInfo
/// <value>The profiles.</value>
public Profile[] Profiles { get; set; }

/// <summary>
/// Gets or sets the profiles.
/// </summary>
/// <value>The conferencing profiles.</value>
public ConferencingProfile[] ConferencingProfiles { get; set; }

/// <summary>
/// Gets or sets the authorization of the account.
/// </summary>
Expand Down Expand Up @@ -85,6 +91,7 @@ public bool Equals(UserInfo other)
&& this.Sub == other.Sub
&& this.CronofyType == other.CronofyType
&& EnumerableUtils.NullTolerantSequenceEqual(this.Profiles, other.Profiles)
&& EnumerableUtils.NullTolerantSequenceEqual(this.ConferencingProfiles, other.ConferencingProfiles)
&& object.Equals(this.AuthorizationInfo, other.AuthorizationInfo)
&& object.Equals(this.ServiceAccountInfo, other.ServiceAccountInfo)
&& this.Email == other.Email;
Expand Down Expand Up @@ -225,85 +232,189 @@ public override string ToString()
}

/// <summary>
/// Class representing an authorization for an account.
/// Class representing a conferencing profile for an account.
/// </summary>
public sealed class Authorization
public sealed class ConferencingProfile
{
/// <summary>
/// Gets or sets the scope of the authorization of the account.
/// </summary>
/// <value>
/// The scope of the authorization for the account.
/// </value>
public string Scope { get; set; }

/// <summary>
/// Gets or sets the status of the authorization of the account.
/// </summary>
/// <value>
/// The status of the authorization for the account.
/// </value>
public string Status { get; set; }

/// <summary>
/// Gets or sets the delegated scope of the account.
/// </summary>
/// <value>
/// The delegated scope of the account.
/// </value>
public string DelegatedScope { get; set; }
/// <summary>
/// Gets or sets the name of the provider of the profile.
/// </summary>
/// <value>
/// The name of the provider for the profile.
/// </value>
public string ProviderName { get; set; }

/// <summary>
/// Gets or sets the ID of the profile.
/// </summary>
/// <value>
/// The ID of the profile.
/// </value>
public string Id { get; set; }

/// <summary>
/// Gets or sets the name of the profile.
/// </summary>
/// <value>
/// The name of the profile.
/// </value>
public string Name { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this profile is connected.
/// </summary>
/// <value>
/// <c>true</c> if this profile is connected; otherwise, <c>false</c>.
/// </value>
public bool Connected { get; set; }

/// <summary>
/// Gets or sets the relink URL for the profile.
/// </summary>
/// <value>
/// The relink URL for the profile.
/// </value>
/// <remarks>
/// <c>null</c> unless <see cref="Connected"/> is false.
/// </remarks>
public string RelinkUrl { get; set; }

/// <inheritdoc/>
public override int GetHashCode()
{
return this.Id.GetHashCode();
}

/// <inheritdoc/>
public override bool Equals(object obj)
{
var other = obj as ConferencingProfile;

/// <inheritdoc/>
public override int GetHashCode()
if (other == null)
{
return this.Scope.GetHashCode();
return false;
}

/// <inheritdoc/>
public override bool Equals(object obj)
{
var other = obj as Authorization;
return this.Equals(other);
}

/// <summary>
/// Determines whether the specified <see cref="Cronofy.UserInfo.ConferencingProfile"/> is
/// equal to the current <see cref="Cronofy.UserInfo.ConferencingProfile"/>.
/// </summary>
/// <param name="other">
/// The <see cref="Cronofy.UserInfo.ConferencingProfile"/> to compare with the current
/// <see cref="Cronofy.UserInfo.ConferencingProfile"/>.
/// </param>
/// <returns>
/// <c>true</c> if the specified <see cref="Cronofy.UserInfo.ConferencingProfile"/> is equal
/// to the current <see cref="Cronofy.UserInfo.ConferencingProfile"/>; otherwise,
/// <c>false</c>.
/// </returns>
public bool Equals(ConferencingProfile other)
{
return other != null
&& this.Id == other.Id
&& this.Name == other.Name
&& this.ProviderName == other.ProviderName
&& this.Connected == other.Connected
&& this.RelinkUrl == other.RelinkUrl;
}

/// <inheritdoc/>
public override string ToString()
{
return string.Format(
"<{0} ProviderName={1}, Id={2}, Name={3}, Connected={4}, RelinkUrl={5}>",
this.GetType(),
this.ProviderName,
this.Id,
this.Name,
this.Connected,
this.RelinkUrl);
}
}

if (other == null)
/// <summary>
/// Class representing an authorization for an account.
/// </summary>
public sealed class Authorization
{
/// <summary>
/// Gets or sets the scope of the authorization of the account.
/// </summary>
/// <value>
/// The scope of the authorization for the account.
/// </value>
public string Scope { get; set; }

/// <summary>
/// Gets or sets the status of the authorization of the account.
/// </summary>
/// <value>
/// The status of the authorization for the account.
/// </value>
public string Status { get; set; }

/// <summary>
/// Gets or sets the delegated scope of the account.
/// </summary>
/// <value>
/// The delegated scope of the account.
/// </value>
public string DelegatedScope { get; set; }

/// <inheritdoc/>
public override int GetHashCode()
{
return false;
return this.Scope.GetHashCode();
}

return this.Equals(other);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
var other = obj as Authorization;

/// <summary>
/// Determines whether the specified <see cref="Cronofy.UserInfo.Authorization"/> is
/// equal to the current <see cref="Cronofy.UserInfo.Authorization"/>.
/// </summary>
/// <param name="other">
/// The <see cref="Cronofy.UserInfo.Authorization"/> to compare with the current
/// <see cref="Cronofy.UserInfo.Authorization"/>.
/// </param>
/// <returns>
/// <c>true</c> if the specified <see cref="Cronofy.UserInfo.Authorization"/> is equal
/// to the current <see cref="Cronofy.UserInfo.Authorization"/>; otherwise,
/// <c>false</c>.
/// </returns>
public bool Equals(Authorization other)
{
return other != null
&& this.Scope == other.Scope
&& this.Status == other.Status
&& this.DelegatedScope == other.DelegatedScope;
}
if (other == null)
{
return false;
}

/// <inheritdoc/>
public override string ToString()
{
return string.Format(
"<{0} Scope={1}, Status={2}, DelegatedScope={3}>",
this.GetType(),
this.Scope,
this.Status,
this.DelegatedScope);
return this.Equals(other);
}

/// <summary>
/// Determines whether the specified <see cref="Cronofy.UserInfo.Authorization"/> is
/// equal to the current <see cref="Cronofy.UserInfo.Authorization"/>.
/// </summary>
/// <param name="other">
/// The <see cref="Cronofy.UserInfo.Authorization"/> to compare with the current
/// <see cref="Cronofy.UserInfo.Authorization"/>.
/// </param>
/// <returns>
/// <c>true</c> if the specified <see cref="Cronofy.UserInfo.Authorization"/> is equal
/// to the current <see cref="Cronofy.UserInfo.Authorization"/>; otherwise,
/// <c>false</c>.
/// </returns>
public bool Equals(Authorization other)
{
return other != null
&& this.Scope == other.Scope
&& this.Status == other.Status
&& this.DelegatedScope == other.DelegatedScope;
}

/// <inheritdoc/>
public override string ToString()
{
return string.Format(
"<{0} Scope={1}, Status={2}, DelegatedScope={3}>",
this.GetType(),
this.Scope,
this.Status,
this.DelegatedScope);
}
}
}

/// <summary>
/// Class representing additional information from the service account authorization.
Expand Down
Loading

0 comments on commit 16f3703

Please sign in to comment.