Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split multi-recipient Smart Invites calls
As the behavior and shape of requests and responses differs, it feels better to use a different branch rather than have a single path which requires null checks and similar.
- Loading branch information
Showing
11 changed files
with
631 additions
and
115 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
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,95 @@ | ||
namespace Cronofy.Requests | ||
{ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
/// <summary> | ||
/// Class for the serialization of an smart invite request. | ||
/// </summary> | ||
public sealed class SmartInviteMultiRecipientRequest | ||
{ | ||
/// <summary> | ||
/// Gets or sets the method for the invite. | ||
/// </summary> | ||
/// <value> | ||
/// The method of the invite. | ||
/// </value> | ||
[JsonProperty("method")] | ||
public string Method { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the Id for the invite. | ||
/// </summary> | ||
/// <value> | ||
/// The Id of the invite. | ||
/// </value> | ||
[JsonProperty("smart_invite_id")] | ||
public string SmartInviteId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the callback url for notifications. | ||
/// </summary> | ||
/// <value> | ||
/// The callback url for notifications. | ||
/// </value> | ||
[JsonProperty("callback_url")] | ||
public string CallbackUrl { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the recipients for the invite. | ||
/// </summary> | ||
/// <value> | ||
/// The recipients for the invite. | ||
/// </value> | ||
[JsonProperty("recipients")] | ||
public IEnumerable<InviteRecipient> Recipients { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the details for the event. | ||
/// </summary> | ||
/// <value> | ||
/// The details for the event. | ||
/// </value> | ||
[JsonProperty("event")] | ||
public SmartInviteEventRequest Event { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the organizer for the invite. | ||
/// </summary> | ||
/// <value> | ||
/// The organizer for the invite. | ||
/// </value> | ||
[JsonProperty("organizer")] | ||
public InviteOrganizer Organizer { get; set; } | ||
|
||
/// <summary> | ||
/// Class for the serialization of an smart invite request recipient. | ||
/// </summary> | ||
public sealed class InviteRecipient | ||
{ | ||
/// <summary> | ||
/// Gets or sets the email address. | ||
/// </summary> | ||
/// <value> | ||
/// The email address. | ||
/// </value> | ||
[JsonProperty("email")] | ||
public string Email { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// Class for the serialization of an smart invite request organizer. | ||
/// </summary> | ||
public sealed class InviteOrganizer | ||
{ | ||
/// <summary> | ||
/// Gets or sets the name. | ||
/// </summary> | ||
/// <value> | ||
/// The name. | ||
/// </value> | ||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
} | ||
} | ||
} |
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
83 changes: 83 additions & 0 deletions
83
src/Cronofy/Responses/SmartInviteMultiRecipientResponse.cs
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,83 @@ | ||
namespace Cronofy.Responses | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Newtonsoft.Json; | ||
|
||
/// <summary> | ||
/// Class to represent a smart invite response. | ||
/// </summary> | ||
internal sealed class SmartInviteMultiRecipientResponse | ||
{ | ||
/// <summary> | ||
/// Gets or sets the method for the invite. | ||
/// </summary> | ||
/// <value> | ||
/// The method of the invite. | ||
/// </value> | ||
[JsonProperty("method")] | ||
public string Method { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the smart invite identifier. | ||
/// </summary> | ||
/// <value>The smart invite identifier.</value> | ||
[JsonProperty("smart_invite_id")] | ||
public string SmartInviteId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the callback URL. | ||
/// </summary> | ||
/// <value>The callback URL.</value> | ||
[JsonProperty("callback_url")] | ||
public string CallbackUrl { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the recipients list. | ||
/// </summary> | ||
/// <value>The recipient.</value> | ||
[JsonProperty("recipients")] | ||
public SmartInviteResponse.ResponseAttendee[] Recipients { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the event. | ||
/// </summary> | ||
/// <value>The event.</value> | ||
[JsonProperty("event")] | ||
public ReadEventsResponse.EventResponse Event { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the attachments. | ||
/// </summary> | ||
/// <value>The attachments.</value> | ||
[JsonProperty("attachments")] | ||
public SmartInviteResponse.AttachmentsResponse Attachments { get; set; } | ||
|
||
/// <summary> | ||
/// Converts this response to a SmartInviteMultiRecipient object. | ||
/// </summary> | ||
/// <returns>A Smart invite object.</returns> | ||
public SmartInviteMultiRecipient ToSmartInvite() | ||
{ | ||
var invite = new SmartInviteMultiRecipient(); | ||
|
||
invite.SmartInviteId = this.SmartInviteId; | ||
invite.CallbackUrl = this.CallbackUrl; | ||
invite.Method = this.Method; | ||
|
||
if (this.Recipients != null) | ||
{ | ||
invite.Recipients = this.Recipients.Select(t => t.ToAttendee()); | ||
} | ||
else | ||
{ | ||
invite.Recipients = Enumerable.Empty<SmartInvite.Attendee>(); | ||
} | ||
|
||
invite.Event = this.Event.ToEvent(); | ||
invite.Attachments = this.Attachments.ToAttachments(); | ||
|
||
return invite; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.