Skip to content

Commit

Permalink
Merge pull request #62 from cronofy/smart-invites-multi-attendees
Browse files Browse the repository at this point in the history
Smart Invites multi attendees
  • Loading branch information
gshutler committed Oct 22, 2018
2 parents a99db83 + a6ef4f8 commit e8b0ec2
Show file tree
Hide file tree
Showing 18 changed files with 735 additions and 67 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## [0.25.0]

* Added support for multi-recipient Smart Invites [#62]

## [0.24.0]

* Added support for sequences, buffers and intervals [#59]
Expand All @@ -9,7 +13,7 @@

## [0.22.0]

* Allow setting of smart invite organizer name [#55]
* Allow setting of Smart Invite organizer name [#55]

## [0.21.0]

Expand All @@ -19,7 +23,7 @@

* Application Calendar support [#49]
* Add subject to oauth token responses [#53]
* Added support for smart invite proposal [#52]
* Added support for Smart Invite proposal [#52]

## [0.19.1]

Expand Down Expand Up @@ -161,6 +165,7 @@
[0.22.0]: https://github.com/cronofy/cronofy-csharp/releases/tag/rel-0.22.0
[0.23.0]: https://github.com/cronofy/cronofy-csharp/releases/tag/rel-0.23.0
[0.24.0]: https://github.com/cronofy/cronofy-csharp/releases/tag/rel-0.24.0
[0.25.0]: https://github.com/cronofy/cronofy-csharp/releases/tag/rel-0.25.0

[#3]: https://github.com/cronofy/cronofy-csharp/pull/3
[#10]: https://github.com/cronofy/cronofy-csharp/pull/10
Expand Down Expand Up @@ -200,3 +205,4 @@
[#58]: https://github.com/cronofy/cronofy-csharp/pull/58
[#59]: https://github.com/cronofy/cronofy-csharp/pull/59
[#60]: https://github.com/cronofy/cronofy-csharp/pull/60
[#62]: https://github.com/cronofy/cronofy-csharp/pull/62
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.24.0
0.25.0
4 changes: 4 additions & 0 deletions src/Cronofy/Cronofy.csproj
Expand Up @@ -164,6 +164,10 @@
<Compile Include="Responses\SequencedAvailabilityResponse.cs" />
<Compile Include="RealTimeSequencingRequestBuilder.cs" />
<Compile Include="Responses\RealTimeSequencingResponse.cs" />
<Compile Include="SmartInviteMultiRecipientRequestBuilder.cs" />
<Compile Include="Requests\SmartInviteMultiRecipientRequest.cs" />
<Compile Include="SmartInviteMultiRecipient.cs" />
<Compile Include="Responses\SmartInviteMultiRecipientResponse.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages/StyleCop.MSBuild.5.0.0\build\StyleCop.MSBuild.targets" />
Expand Down
86 changes: 47 additions & 39 deletions src/Cronofy/CronofyOAuthClient.cs
@@ -1,4 +1,4 @@
namespace Cronofy
namespace Cronofy
{
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -301,18 +301,7 @@ public bool HmacMatches(string sha256Hmac, byte[] requestBytes)
}
}

/// <summary>
/// Creates a smart invite for the given request.
/// </summary>
/// <param name="smartInviteRequest">
/// The details of the invite, must not be <code>null</code>.
/// </param>
/// <returns>
/// A smart invite for the given request.
/// </returns>
/// <exception cref="CronofyException">
/// Thrown if an error is encountered whilst making the request.
/// </exception>
/// <inheritdoc/>
public SmartInvite CreateInvite(SmartInviteRequest smartInviteRequest)
{
var request = new HttpRequest
Expand All @@ -328,19 +317,12 @@ public SmartInvite CreateInvite(SmartInviteRequest smartInviteRequest)
return response.ToSmartInvite();
}

/// <summary>
/// Cancels a smart invite for the given request.
/// </summary>
/// <param name="smartInviteId">The invite id to cancel.</param>
/// <param name="recipientEmail">The recipient for the cancellation.</param>
/// <returns>
/// A smart invite for the given request.
/// </returns>
/// <exception cref="CronofyException">
/// Thrown if an error is encountered whilst making the request.
/// </exception>
/// <inheritdoc/>
public SmartInvite CancelInvite(string smartInviteId, string recipientEmail)
{
Preconditions.NotEmpty("smartInviteId", smartInviteId);
Preconditions.NotEmpty("emailAddress", recipientEmail);

var request = new HttpRequest
{
Method = "POST",
Expand All @@ -356,23 +338,12 @@ public SmartInvite CancelInvite(string smartInviteId, string recipientEmail)
return response.ToSmartInvite();
}

/// <summary>
/// Retreives detials of a smart invite.
/// </summary>
/// <param name="smartInviteId">
/// The invite id.
/// </param>
/// <param name="emailAddress">
/// The email address of the invitee.
/// </param>
/// <returns>
/// A smart invite for the given request.
/// </returns>
/// <exception cref="CronofyException">
/// Thrown if an error is encountered whilst making the request.
/// </exception>
/// <inheritdoc/>
public SmartInvite GetSmartInvite(string smartInviteId, string emailAddress)
{
Preconditions.NotEmpty("smartInviteId", smartInviteId);
Preconditions.NotEmpty("emailAddress", emailAddress);

var request = new HttpRequest
{
Method = "GET",
Expand All @@ -390,6 +361,43 @@ public SmartInvite GetSmartInvite(string smartInviteId, string emailAddress)
return response.ToSmartInvite();
}

/// <inheritdoc/>
public SmartInviteMultiRecipient CreateInvite(SmartInviteMultiRecipientRequest smartInviteRequest)
{
var request = new HttpRequest
{
Method = "POST",
Url = this.urlProvider.SmartInviteUrl
};

request.AddOAuthAuthorization(this.clientSecret);
request.SetJsonBody(smartInviteRequest);

var response = this.HttpClient.GetJsonResponse<SmartInviteMultiRecipientResponse>(request);
return response.ToSmartInvite();
}

/// <inheritdoc/>
public SmartInviteMultiRecipient GetSmartInvite(string smartInviteId)
{
Preconditions.NotEmpty("smartInviteId", smartInviteId);

var request = new HttpRequest
{
Method = "GET",
Url = this.urlProvider.SmartInviteUrl,
QueryString = new HttpRequest.QueryStringCollection
{
{ "smart_invite_id", smartInviteId }
}
};

request.AddOAuthAuthorization(this.clientSecret);

var response = this.HttpClient.GetJsonResponse<SmartInviteMultiRecipientResponse>(request);
return response.ToSmartInvite();
}

/// <inheritdoc />
public OAuthToken ApplicationCalendar(string applicationCalendarId)
{
Expand Down
74 changes: 73 additions & 1 deletion src/Cronofy/ICronofyOAuthClient.cs
@@ -1,4 +1,4 @@
namespace Cronofy
namespace Cronofy
{
using System;
using Cronofy.Requests;
Expand Down Expand Up @@ -138,5 +138,77 @@ public interface ICronofyOAuthClient
/// Thrown if <paramref name="realTimeSequencingRequest"/> is null.
/// </exception>
string RealTimeSequencing(RealTimeSequencingRequest realTimeSequencingRequest);

/// <summary>
/// Creates a Smart Invite for the given request.
/// </summary>
/// <param name="smartInviteRequest">
/// The details of the invite, must not be <code>null</code>.
/// </param>
/// <returns>
/// A Smart Invite for the given request.
/// </returns>
/// <exception cref="CronofyException">
/// Thrown if an error is encountered whilst making the request.
/// </exception>
SmartInvite CreateInvite(SmartInviteRequest smartInviteRequest);

/// <summary>
/// Cancels a Smart Invite for the given request.
/// </summary>
/// <param name="smartInviteId">The invite id to cancel.</param>
/// <param name="recipientEmail">The recipient for the cancellation.</param>
/// <returns>
/// A Smart Invite for the given request.
/// </returns>
/// <exception cref="CronofyException">
/// Thrown if an error is encountered whilst making the request.
/// </exception>
SmartInvite CancelInvite(string smartInviteId, string recipientEmail);

/// <summary>
/// Retreives details of a Smart Invite.
/// </summary>
/// <param name="smartInviteId">
/// The invite id.
/// </param>
/// <param name="emailAddress">
/// The email address of the invitee.
/// </param>
/// <returns>
/// A Smart Invite for the given request.
/// </returns>
/// <exception cref="CronofyException">
/// Thrown if an error is encountered whilst making the request.
/// </exception>
SmartInvite GetSmartInvite(string smartInviteId, string emailAddress);

/// <summary>
/// Creates a Smart Invite for the given request.
/// </summary>
/// <param name="smartInviteRequest">
/// The details of the invite, must not be <code>null</code>.
/// </param>
/// <returns>
/// A Smart Invite for the given request.
/// </returns>
/// <exception cref="CronofyException">
/// Thrown if an error is encountered whilst making the request.
/// </exception>
SmartInviteMultiRecipient CreateInvite(SmartInviteMultiRecipientRequest smartInviteRequest);

/// <summary>
/// Retreives details of a Smart Invite.
/// </summary>
/// <param name="smartInviteId">
/// The invite id.
/// </param>
/// <returns>
/// A Smart Invite for the given request.
/// </returns>
/// <exception cref="CronofyException">
/// Thrown if an error is encountered whilst making the request.
/// </exception>
SmartInviteMultiRecipient GetSmartInvite(string smartInviteId);
}
}
6 changes: 3 additions & 3 deletions src/Cronofy/Requests/SmartInviteCancelRequest.cs
Expand Up @@ -3,14 +3,14 @@
using Newtonsoft.Json;

/// <summary>
/// Class for the serialization of an smart invite cancel request.
/// Class for the serialization of an Smart Invite cancel request.
/// </summary>
public sealed class SmartInviteCancelRequest
{
/// <summary>
/// Initializes a new instance of the <see cref="T:Cronofy.Requests.SmartInviteCancelRequest"/> class.
/// </summary>
/// <param name="smartInviteId">The smart invite identifier.</param>
/// <param name="smartInviteId">The Smart Invite identifier.</param>
/// <param name="recipientEmail">The recipient email.</param>
public SmartInviteCancelRequest(string smartInviteId, string recipientEmail)
{
Expand Down Expand Up @@ -50,7 +50,7 @@ public SmartInviteCancelRequest(string smartInviteId, string recipientEmail)
public InviteRecipient Recipient { get; set; }

/// <summary>
/// Class for the serialization of an smart invite request recipient.
/// Class for the serialization of an Smart Invite request recipient.
/// </summary>
public sealed class InviteRecipient
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cronofy/Requests/SmartInviteEventRequest.cs
@@ -1,7 +1,7 @@
namespace Cronofy.Requests
{
/// <summary>
/// Class to represent a smart invite event.
/// Class to represent a Smart Invite event.
/// </summary>
public sealed class SmartInviteEventRequest : BaseEventRequest
{
Expand Down
95 changes: 95 additions & 0 deletions src/Cronofy/Requests/SmartInviteMultiRecipientRequest.cs
@@ -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; }
}
}
}

0 comments on commit e8b0ec2

Please sign in to comment.