-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
011e926
commit c348d2c
Showing
11 changed files
with
916 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
namespace Cronofy | ||
{ | ||
using System; | ||
using System.Linq; | ||
|
||
/// <summary> | ||
/// Class for representing an availability rule. | ||
/// </summary> | ||
public sealed class AvailabilityRule | ||
{ | ||
/// <summary> | ||
/// Gets or sets the unique identifier of the availability rule. | ||
/// </summary> | ||
/// <value> | ||
/// The unique identifier of the availability rule. | ||
/// </value> | ||
public string AvailabilityRuleId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the time zone for which the availability rule start and end times are represented in. | ||
/// </summary> | ||
/// <value> | ||
/// The time zone for which the availability rule start and end times are represented in. | ||
/// </value> | ||
public string TimeZoneId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the calendars that should impact the user's availability. | ||
/// </summary> | ||
/// <value> | ||
/// The calendars that should impact the user's availability. | ||
/// </value> | ||
public string[] CalendarIds { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the weekly recurring periods for the availability rule. | ||
/// </summary> | ||
/// <value> | ||
/// The weekly recurring periods for the availability rule. | ||
/// </value> | ||
public WeeklyPeriod[] WeeklyPeriods { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public override int GetHashCode() | ||
{ | ||
return this.AvailabilityRuleId.GetHashCode(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, obj)) | ||
{ | ||
return true; | ||
} | ||
|
||
return obj is AvailabilityRule && this.Equals((AvailabilityRule)obj); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether the specified <see cref="AvailabilityRule"/> | ||
/// is equal to the current <see cref="AvailabilityRule"/>. | ||
/// </summary> | ||
/// <param name="other"> | ||
/// The <see cref="AvailabilityRule"/> to compare with the current | ||
/// <see cref="AvailabilityRule"/>. | ||
/// </param> | ||
/// <returns> | ||
/// <c>true</c> if the specified <see cref="AvailabilityRule"/> is | ||
/// equal to the current <see cref="AvailabilityRule"/>; otherwise, | ||
/// <c>false</c>. | ||
/// </returns> | ||
public bool Equals(AvailabilityRule other) | ||
{ | ||
return this.AvailabilityRuleId == other.AvailabilityRuleId && | ||
this.TimeZoneId == other.TimeZoneId && | ||
this.CalendarIds.SequenceEqual(other.CalendarIds) && | ||
this.WeeklyPeriods.SequenceEqual(other.WeeklyPeriods); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override string ToString() | ||
{ | ||
return string.Format( | ||
"<{0} AvailabilityRuleId={1}, TimeZoneId={2}, CalendarIds={3}, WeeklyPeriods={4}>", | ||
this.GetType(), | ||
this.AvailabilityRuleId, | ||
this.TimeZoneId, | ||
this.CalendarIds, | ||
this.WeeklyPeriods); | ||
} | ||
|
||
/// <summary> | ||
/// Class to represent a weekly period. | ||
/// </summary> | ||
public class WeeklyPeriod | ||
{ | ||
/// <summary> | ||
/// Gets or sets the week day the period applies to. | ||
/// </summary> | ||
/// <value> | ||
/// The week day the period applies to. | ||
/// </value> | ||
public string Day { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the time of day the period should start. | ||
/// </summary> | ||
/// <value> | ||
/// The time of day the period should start. | ||
/// </value> | ||
public string StartTime { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the time of day the period should end. | ||
/// </summary> | ||
/// <value> | ||
/// The time of day the period should end. | ||
/// </value> | ||
public string EndTime { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public override int GetHashCode() | ||
{ | ||
return this.Day.GetHashCode() ^ this.StartTime.GetHashCode() ^ this.EndTime.GetHashCode(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, obj)) | ||
{ | ||
return true; | ||
} | ||
|
||
return obj is WeeklyPeriod && this.Equals((WeeklyPeriod)obj); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether the specified <see cref="WeeklyPeriod"/> | ||
/// is equal to the current <see cref="WeeklyPeriod"/>. | ||
/// </summary> | ||
/// <param name="other"> | ||
/// The <see cref="WeeklyPeriod"/> to compare with the current | ||
/// <see cref="WeeklyPeriod"/>. | ||
/// </param> | ||
/// <returns> | ||
/// <c>true</c> if the specified <see cref="WeeklyPeriod"/> is | ||
/// equal to the current <see cref="WeeklyPeriod"/>; otherwise, | ||
/// <c>false</c>. | ||
/// </returns> | ||
public bool Equals(WeeklyPeriod other) | ||
{ | ||
return this.Day == other.Day && | ||
this.StartTime == other.StartTime && | ||
this.EndTime == other.EndTime; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override string ToString() | ||
{ | ||
return string.Format( | ||
"<{0} Day={1}, StartTime={2}, EndTime={3}>", | ||
this.GetType(), | ||
this.Day, | ||
this.StartTime, | ||
this.EndTime); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
namespace Cronofy.Requests | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Newtonsoft.Json; | ||
|
||
/// <summary> | ||
/// Class for the serialization of an upsert availability rule request. | ||
/// </summary> | ||
public sealed class UpsertAvailabilityRuleRequest | ||
{ | ||
/// <summary> | ||
/// Gets or sets the unique identifier of the availability rule. | ||
/// </summary> | ||
/// <value> | ||
/// The unique identifier of the availability rule. | ||
/// </value> | ||
[JsonProperty("availability_rule_id")] | ||
public string AvailabilityRuleId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the time zone for which the availability rule start and end times are represented in. | ||
/// </summary> | ||
/// <value> | ||
/// The time zone for which the availability rule start and end times are represented in. | ||
/// </value> | ||
[JsonProperty("tzid")] | ||
public string TimeZoneId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the calendars that should impact the user's availability. | ||
/// </summary> | ||
/// <value> | ||
/// The calendars that should impact the user's availability. | ||
/// </value> | ||
[JsonProperty("calendar_ids")] | ||
public IEnumerable<string> CalendarIds { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the weekly recurring periods for the availability rule. | ||
/// </summary> | ||
/// <value> | ||
/// The weekly recurring periods for the availability rule. | ||
/// </value> | ||
[JsonProperty("weekly_periods")] | ||
public IEnumerable<WeeklyPeriod> WeeklyPeriods { get; set; } | ||
|
||
/// <summary> | ||
/// Class for the serialization of a weekly period within an availability rule. | ||
/// </summary> | ||
public sealed class WeeklyPeriod | ||
{ | ||
/// <summary> | ||
/// Gets or sets the week day the period applies to. | ||
/// </summary> | ||
/// <value> | ||
/// The week day the period applies to. | ||
/// </value> | ||
[JsonProperty("day")] | ||
public string Day { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the time of day the period should start. | ||
/// </summary> | ||
/// <value> | ||
/// The time of day the period should start. | ||
/// </value> | ||
[JsonProperty("start_time")] | ||
public string StartTime { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the time of day the period should end. | ||
/// </summary> | ||
/// <value> | ||
/// The time of day the period should end. | ||
/// </value> | ||
[JsonProperty("end_time")] | ||
public string EndTime { get; set; } | ||
} | ||
} | ||
} |
Oops, something went wrong.