Skip to content

Commit

Permalink
(GH-176) GetSurvey, DeleteSurvey and UpdateSurvey
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Feb 19, 2022
1 parent 138ee45 commit 6055f64
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Source/ZoomNet.IntegrationTests/Tests/Meetings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,53 @@ public async Task RunAsync(string userId, IZoomClient client, TextWriter log, Ca
var approvedRegistrations = await client.Meetings.GetRegistrantsAsync(scheduledMeeting.Id, RegistrantStatus.Approved, null, 30, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"This meeting has {pendingRegistrations.TotalRecords} registrations awaiting approval and {approvedRegistrations.TotalRecords} approved registrations").ConfigureAwait(false);

var surveyQuestions = new[]
{
new SurveyQuestion
{
Name = "Did you like the meeting?",
IsRequired = true,
ShowAsDropdown = false,
Type = SurveyQuestionType.Single,
Answers = new[] { "Yes", "No"}
},
new SurveyQuestion
{
Name = "Rate the presenter",
IsRequired = true,
ShowAsDropdown = false,
Type = SurveyQuestionType.Rating_Scale,
RatingMinimumValue = 1,
RatingMaximumValue = 10,
RatingLowScoreLabel = "Mediocre",
RatingHighScoreLabel = "Excellent"
},
new SurveyQuestion
{
Name = "Select the product(s) that interest you",
IsRequired = false,
ShowAsDropdown = false,
Type = SurveyQuestionType.Multiple,
Answers = new[] { "Gizmo number 1", "Gizmo number 2", "SuperDuper Gizmo"}
},
new SurveyQuestion
{
Name = "Comment",
IsRequired = false,
Type = SurveyQuestionType.Long,
MinimumNumberOfCharacters = 10,
MaximumNumberOfCharacters = 1999
},
};
await client.Meetings.UpdateSurveyAsync(scheduledMeeting.Id, surveyQuestions, true, true, "https://jeremiedesautels.com", cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync("Survey was updated").ConfigureAwait(false);

var survey = await client.Meetings.GetSurveyAsync(scheduledMeeting.Id, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync("Survey was retrieved").ConfigureAwait(false);

await client.Meetings.DeleteSurveyAsync(scheduledMeeting.Id, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync("Survey was deleted").ConfigureAwait(false);

await client.Meetings.CancelRegistrantAsync(scheduledMeeting.Id, registrantInfo1.Id, "[email protected]", null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Registration {registrant1.Id} was canceled").ConfigureAwait(false);

Expand Down
28 changes: 28 additions & 0 deletions Source/ZoomNet/Models/Survey.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Newtonsoft.Json;

namespace ZoomNet.Models
{
/// <summary>
/// Survey.
/// </summary>
public class Survey
{
/// <summary>
/// Gets or sets the link to the third party meeting survey.
/// </summary>
[JsonProperty("third_party_survey")]
public string ThirdPartySurveyLink { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the survey will be displayed in the attendee's browser.
/// </summary>
[JsonProperty(PropertyName = "show_in_the_browser")]
public bool ShowInBrowser { get; set; }

/// <summary>
/// Gets or sets the information about the customized survey.
/// </summary>
[JsonProperty(PropertyName = "custom_survey")]
public SurveyDetails Details { get; set; }
}
}
22 changes: 22 additions & 0 deletions Source/ZoomNet/Models/SurveyDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Newtonsoft.Json;

namespace ZoomNet.Models
{
/// <summary>
/// Survey details.
/// </summary>
public class SurveyDetails
{
/// <summary>
/// Gets or sets a value indicating whether to allow participants to anonymously answer survey questions.
/// </summary>
[JsonProperty("anonymous")]
public bool AllowAnonymous { get; set; }

/// <summary>
/// Gets or sets the survey questions.
/// </summary>
[JsonProperty(PropertyName = "questions")]
public SurveyQuestion[] Questions { get; set; }
}
}
87 changes: 87 additions & 0 deletions Source/ZoomNet/Models/SurveyQuestion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using Newtonsoft.Json;

namespace ZoomNet.Models
{
/// <summary>
/// Survey question.
/// </summary>
public class SurveyQuestion
{
/// <summary>
/// Gets or sets the survey question.
/// </summary>
/// <remarks>Up to 255 characters.</remarks>
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// Gets or sets the question type.
/// </summary>
[JsonProperty(PropertyName = "type")]
public SurveyQuestionType Type { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the possible answers will be displayed as a drop-down box.
/// </summary>
[JsonProperty(PropertyName = "show_as_dropdown")]
public bool ShowAsDropdown { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the question must be answered.
/// </summary>
[JsonProperty(PropertyName = "answer_required")]
public bool IsRequired { get; set; }

/// <summary>
/// Gets or sets the possible answers to chose from.
/// </summary>
[JsonProperty(PropertyName = "answers")]
public string[] Answers { get; set; }

/// <summary>
/// Gets or sets the minimum number of characters.
/// This field only applies to questions of type 'Long'.
/// </summary>
/// <remarks>Must be greather or equal to 1.</remarks>
[JsonProperty(PropertyName = "answer_min_character")]
public int? MinimumNumberOfCharacters { get; set; }

/// <summary>
/// Gets or sets the maximum number of characters.
/// This field only applies to questions of type 'Long'.
/// </summary>
/// <remarks>Must be smaller or equal to 2,000.</remarks>
[JsonProperty(PropertyName = "answer_max_character")]
public int? MaximumNumberOfCharacters { get; set; }

/// <summary>
/// Gets or sets the rating minimum value.
/// This field only applies to questions of type 'Rating'.
/// </summary>
/// <remarks>Must be greather or equal to 0.</remarks>
[JsonProperty(PropertyName = "rating_min_value")]
public int? RatingMinimumValue { get; set; }

/// <summary>
/// Gets or sets the rating maximum value.
/// This field only applies to questions of type 'Rating'.
/// </summary>
/// <remarks>Must be smaller or equal to 10.</remarks>
[JsonProperty(PropertyName = "rating_max_value")]
public int? RatingMaximumValue { get; set; }

/// <summary>
/// Gets or sets the low score label.
/// This field only applies to questions of type 'Rating'.
/// </summary>
[JsonProperty(PropertyName = "rating_min_label")]
public string RatingLowScoreLabel { get; set; }

/// <summary>
/// Gets or sets the high score label.
/// This field only applies to questions of type 'Rating'.
/// </summary>
[JsonProperty(PropertyName = "rating_max_label")]
public string RatingHighScoreLabel { get; set; }
}
}
34 changes: 34 additions & 0 deletions Source/ZoomNet/Resources/IMeetings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,5 +504,39 @@ public interface IMeetings
/// An array of <see cref="InviteLink" />.
/// </returns>
Task<InviteLink[]> CreateInviteLinksAsync(long meetingId, IEnumerable<string> names, long timeToLive = 7200, CancellationToken cancellationToken = default);

/// <summary>
/// Delete a meeting survey.
/// </summary>
/// <param name="meetingId">The meeting ID.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The async task.
/// </returns>
Task DeleteSurveyAsync(long meetingId, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieve the survey for a meeting.
/// </summary>
/// <param name="meetingId">The meeting ID.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// A <see cref="Survey"/>.
/// </returns>
Task<Survey> GetSurveyAsync(long meetingId, CancellationToken cancellationToken = default);

/// <summary>
/// Update a meeting's survey.
/// </summary>
/// <param name="meetingId">The meeting ID.</param>
/// <param name="questions">The custom questions.</param>
/// <param name="allowAnonymous">Whether to allow participants to anonymously answer survey questions.</param>
/// <param name="showInBrowser">Whether the survey will be displayed in the attendee's browser.</param>
/// <param name="thirdPartySurveyLink">The link to the third party meeting survey.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The async task.
/// </returns>
Task UpdateSurveyAsync(long meetingId, IEnumerable<SurveyQuestion> questions = null, bool allowAnonymous = true, bool showInBrowser = true, string thirdPartySurveyLink = null, CancellationToken cancellationToken = default);
}
}
34 changes: 34 additions & 0 deletions Source/ZoomNet/Resources/Meetings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,40 @@ public Task<InviteLink[]> CreateInviteLinksAsync(long meetingId, IEnumerable<str
.AsObject<InviteLink[]>("attendees");
}

/// <inheritdoc/>
public Task DeleteSurveyAsync(long meetingId, CancellationToken cancellationToken = default)
{
return _client
.DeleteAsync($"meetings/{meetingId}/survey")
.WithCancellationToken(cancellationToken)
.AsMessage();
}

/// <inheritdoc/>
public Task<Survey> GetSurveyAsync(long meetingId, CancellationToken cancellationToken = default)
{
return _client
.GetAsync($"meetings/{meetingId}/survey")
.WithCancellationToken(cancellationToken)
.AsObject<Survey>();
}

/// <inheritdoc/>
public Task UpdateSurveyAsync(long meetingId, IEnumerable<SurveyQuestion> questions = null, bool allowAnonymous = true, bool showInBrowser = true, string thirdPartySurveyLink = null, CancellationToken cancellationToken = default)
{
var data = new JObject();
data.AddPropertyIfValue("third_party_survey", thirdPartySurveyLink);
data.AddPropertyIfValue("show_in_the_browser", showInBrowser);
data.AddPropertyIfValue("custom_survey/anonymous", allowAnonymous);
data.AddPropertyIfValue("custom_survey/questions", questions?.ToArray());

return _client
.PatchAsync($"meetings/{meetingId}/survey")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsMessage();
}

private Task UpdateRegistrantsStatusAsync(long meetingId, IEnumerable<(string RegistrantId, string RegistrantEmail)> registrantsInfo, string status, string occurrenceId = null, CancellationToken cancellationToken = default)
{
var data = new JObject();
Expand Down

0 comments on commit 6055f64

Please sign in to comment.