Skip to content

Commit

Permalink
Merge branch 'release/0.9.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Oct 2, 2020
2 parents 477a7bf + 8763bb1 commit acee9ce
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 1 deletion.
47 changes: 47 additions & 0 deletions Source/ZoomNet/Models/Webinar.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Newtonsoft.Json;
using StrongGrid.Models;
using System;
using System.Collections.Generic;
using ZoomNet.Utilities;

namespace ZoomNet.Models
{
Expand Down Expand Up @@ -36,6 +38,15 @@ public abstract class Webinar
[JsonProperty("host_id", NullValueHandling = NullValueHandling.Ignore)]
public string HostId { get; set; }

/// <summary>
/// Gets or sets the email address of the host of the webinar.
/// </summary>
/// <value>
/// The user id.
/// </value>
[JsonProperty("host_email", NullValueHandling = NullValueHandling.Ignore)]
public string HostEmail { get; set; }

/// <summary>
/// Gets or sets the topic of the meeting.
/// </summary>
Expand All @@ -59,6 +70,13 @@ public abstract class Webinar
[JsonProperty(PropertyName = "duration", NullValueHandling = NullValueHandling.Ignore)]
public int Duration { get; set; }

/// <summary>
/// Gets or sets the webinar agenda.
/// </summary>
/// <value>The agenda.</value>
[JsonProperty(PropertyName = "agenda", NullValueHandling = NullValueHandling.Ignore)]
public string Agenda { get; set; }

/// <summary>
/// Gets or sets the date and time when the meeting was created.
/// </summary>
Expand All @@ -72,5 +90,34 @@ public abstract class Webinar
/// <value>The join URL.</value>
[JsonProperty(PropertyName = "join_url", NullValueHandling = NullValueHandling.Ignore)]
public string JoinUrl { get; set; }

/// <summary>
/// Gets or sets the URL for the host to start the meeting.
/// </summary>
/// <value>The start URL.</value>
[JsonProperty(PropertyName = "start_url", NullValueHandling = NullValueHandling.Ignore)]
public string StartUrl { get; set; }

/// <summary>
/// Gets or sets the tracking fields.
/// </summary>
/// <value>The tracking fields.</value>
[JsonProperty(PropertyName = "tracking_fields", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(TrackingFieldsConverter))]
public KeyValuePair<string, string>[] TrackingFields { get; set; }

/// <summary>
/// Gets or sets the webinar settings.
/// </summary>
/// <value>The webinar settings.</value>
[JsonProperty(PropertyName = "settings", NullValueHandling = NullValueHandling.Ignore)]
public WebinarSettings Settings { get; set; }

/// <summary>
/// Gets or sets the webinar password.
/// </summary>
/// <value>The password.</value>
[JsonProperty(PropertyName = "password", NullValueHandling = NullValueHandling.Ignore)]
public string Password { get; set; }
}
}
96 changes: 96 additions & 0 deletions Source/ZoomNet/Utilities/TrackingFieldsConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ZoomNet.Utilities
{
/// <summary>
/// Converts a JSON string into and array of tracking fields.
/// </summary>
/// <seealso cref="Newtonsoft.Json.JsonConverter" />
internal class TrackingFieldsConverter : JsonConverter
{
/// <summary>
/// Determines whether this instance can convert the specified object type.
/// </summary>
/// <param name="objectType">Type of the object.</param>
/// <returns>
/// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>.
/// </returns>
public override bool CanConvert(Type objectType)
{
return objectType == typeof(IEnumerable<KeyValuePair<string, string>>);
}

/// <summary>
/// Gets a value indicating whether this <see cref="T:Newtonsoft.Json.JsonConverter" /> can read JSON.
/// </summary>
/// <value>
/// <c>true</c> if this <see cref="T:Newtonsoft.Json.JsonConverter" /> can read JSON; otherwise, <c>false</c>.
/// </value>
public override bool CanRead
{
get { return true; }
}

/// <summary>
/// Gets a value indicating whether this <see cref="T:Newtonsoft.Json.JsonConverter" /> can write JSON.
/// </summary>
/// <value>
/// <c>true</c> if this <see cref="T:Newtonsoft.Json.JsonConverter" /> can write JSON; otherwise, <c>false</c>.
/// </value>
public override bool CanWrite
{
get { return false; }
}

/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
/// <param name="value">The value.</param>
/// <param name="serializer">The calling serializer.</param>
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}

/// <summary>
/// Reads the JSON representation of the object.
/// </summary>
/// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
/// <param name="objectType">Type of the object.</param>
/// <param name="existingValue">The existing value of object being read.</param>
/// <param name="serializer">The calling serializer.</param>
/// <returns>
/// The object value.
/// </returns>
/// <exception cref="System.Exception">Unable to determine the field type.</exception>
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.StartArray)
{
var jArray = JArray.Load(reader);
var items = jArray
.OfType<JObject>()
.Select(item => Convert(item, serializer))
.Where(item => !string.IsNullOrEmpty(item.Key))
.ToArray();

return items;
}

throw new Exception("Unable to convert to tracking fields");
}

private KeyValuePair<string, string> Convert(JObject jsonObject, JsonSerializer serializer)
{
var fieldName = jsonObject.Value<string>("field");
var fieldValue = jsonObject.Value<string>("value");

return new KeyValuePair<string, string>(fieldName, fieldValue);
}
}
}
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#tool nuget:?package=GitVersion.CommandLine&version=5.3.7
#tool nuget:?package=GitReleaseManager&version=0.11.0
#tool nuget:?package=OpenCover&version=4.7.922
#tool nuget:?package=ReportGenerator&version=4.6.6
#tool nuget:?package=ReportGenerator&version=4.6.7
#tool nuget:?package=coveralls.io&version=1.4.2
#tool nuget:?package=xunit.runner.console&version=2.4.1

Expand Down

0 comments on commit acee9ce

Please sign in to comment.