diff --git a/src/Cronofy/Attachment.cs b/src/Cronofy/Attachment.cs
new file mode 100644
index 0000000..f478e56
--- /dev/null
+++ b/src/Cronofy/Attachment.cs
@@ -0,0 +1,98 @@
+namespace Cronofy
+{
+ using Newtonsoft.Json;
+
+ ///
+ /// Class for the deserialization of an attachment summary
+ /// response.
+ ///
+ public sealed class Attachment
+ {
+ ///
+ /// Gets or sets the attachment ID.
+ ///
+ ///
+ /// The ID of the attachment.
+ ///
+ [JsonProperty("attachment_id")]
+ public string AttachmentId { get; set; }
+
+ ///
+ /// Gets or sets the file name for the attachment.
+ ///
+ ///
+ /// The file name for the attachment.
+ ///
+ [JsonProperty("file_name")]
+ public string FileName { get; set; }
+
+ ///
+ /// Gets or sets the MIME content type for the attachment.
+ ///
+ ///
+ /// The MIME content type for the attachment.
+ ///
+ [JsonProperty("content_type")]
+ public string ContentType { get; set; }
+
+ ///
+ /// Gets or sets the MD5 hash of the attachment content.
+ ///
+ ///
+ /// The MD5 hash of the attachment content.
+ ///
+ [JsonProperty("md5")]
+ public string MD5 { get; set; }
+
+ ///
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return obj is Attachment && this.Equals((Attachment)obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ return this.AttachmentId.GetHashCode();
+ }
+
+ ///
+ /// Determines whether the specified
+ /// is equal to the current .
+ ///
+ ///
+ /// The to compare with the current
+ /// .
+ ///
+ ///
+ /// true if the specified is
+ /// equal to the current ; otherwise,
+ /// false.
+ ///
+ public bool Equals(Attachment other)
+ {
+ return this.AttachmentId == other.AttachmentId && this.FileName == other.FileName
+ && this.ContentType == other.ContentType && this.MD5 == other.MD5;
+ }
+
+ ///
+ public override string ToString()
+ {
+ return string.Format(
+ "<{0} AttachmentId={1}, FileName={2}>",
+ this.GetType(),
+ this.AttachmentId,
+ this.FileName);
+ }
+ }
+}
diff --git a/src/Cronofy/CronofyOAuthClient.cs b/src/Cronofy/CronofyOAuthClient.cs
index e941096..de9f240 100644
--- a/src/Cronofy/CronofyOAuthClient.cs
+++ b/src/Cronofy/CronofyOAuthClient.cs
@@ -518,6 +518,28 @@ public ElementToken GetElementToken(ElementTokenRequest elementTokenRequest)
return elementTokenResponse.ToElementToken();
}
+ ///
+ public Attachment CreateAttachment(CreateAttachmentRequest createAttachmentRequest)
+ {
+ Preconditions.NotNull(nameof(createAttachmentRequest), createAttachmentRequest);
+ Preconditions.NotEmpty(nameof(createAttachmentRequest.FileName), createAttachmentRequest.FileName);
+ Preconditions.NotEmpty(nameof(createAttachmentRequest.ContentType), createAttachmentRequest.ContentType);
+ Preconditions.NotEmpty(nameof(createAttachmentRequest.Base64Content), createAttachmentRequest.Base64Content);
+
+ var request = new HttpRequest
+ {
+ Method = "POST",
+ Url = this.urlProvider.AttachmentsUrl,
+ };
+
+ request.AddOAuthAuthorization(this.clientSecret);
+ request.SetJsonBody(createAttachmentRequest);
+
+ var attachmentResponse = this.HttpClient.GetJsonResponse(request);
+
+ return attachmentResponse.ToAttachment();
+ }
+
///
/// Builder class for authorization URLs.
///
diff --git a/src/Cronofy/ICronofyOAuthClient.cs b/src/Cronofy/ICronofyOAuthClient.cs
index 6dc14f1..19e70e8 100644
--- a/src/Cronofy/ICronofyOAuthClient.cs
+++ b/src/Cronofy/ICronofyOAuthClient.cs
@@ -396,5 +396,7 @@ public interface ICronofyOAuthClient
/// Thrown if is null or empty.
///
IAuthorizationUrlBuilder GetEnterpriseConnectAuthorizationUrlBuilder(string redirectUri);
+
+ Attachment CreateAttachment(CreateAttachmentRequest createAttachmentRequest);
}
}
diff --git a/src/Cronofy/Requests/CreateAttachmentRequest.cs b/src/Cronofy/Requests/CreateAttachmentRequest.cs
new file mode 100644
index 0000000..ec94077
--- /dev/null
+++ b/src/Cronofy/Requests/CreateAttachmentRequest.cs
@@ -0,0 +1,86 @@
+namespace Cronofy.Requests
+{
+ using Newtonsoft.Json;
+ using System.Collections.Generic;
+
+ ///
+ /// Class for the serialization of a create attachment request.
+ ///
+ public sealed class CreateAttachmentRequest
+ {
+ ///
+ /// Gets or sets the file name for the attachment.
+ ///
+ ///
+ /// The file name for the attachment.
+ ///
+ [JsonProperty("file_name")]
+ public string FileName { get; set; }
+
+ ///
+ /// Gets or sets the MIME content type for the attachment.
+ ///
+ ///
+ /// The MIME content type for the attachment.
+ ///
+ [JsonProperty("content_type")]
+ public string ContentType { get; set; }
+
+ ///
+ /// Gets or sets the Base64-encoded content of the attachment.
+ ///
+ ///
+ /// The Base64-encoded content of the attachment.
+ ///
+ [JsonProperty("base64_content")]
+ public string Base64Content { get; set; }
+
+ ///
+ /// Class for the serialization of attachment subscriptions.
+ ///
+ public sealed class RequestSubscription
+ {
+ ///
+ /// Gets or sets the type of the subscription.
+ ///
+ ///
+ /// The type of the subscription.
+ ///
+ [JsonProperty("type")]
+ public string Type { get; set; }
+
+ ///
+ /// Gets or sets the destination URI Cronofy will call when the subscription is triggered.
+ ///
+ ///
+ /// The destination URI Cronofy will call when the subscription is triggered.
+ ///
+ [JsonProperty("uri")]
+ public string Uri { get; set; }
+
+ ///
+ /// Gets or sets the interactions subscribed to.
+ ///
+ ///
+ /// The interactions subscribed to.
+ ///
+ [JsonProperty("interactions")]
+ public IEnumerable Interactions { get; set; }
+
+ ///
+ /// Class for the serialization of event subscription interactions.
+ ///
+ public sealed class Interaction
+ {
+ ///
+ /// Gets or sets the type of the interaction.
+ ///
+ ///
+ /// The type of the interaction.
+ ///
+ [JsonProperty("type")]
+ public string Type { get; set; }
+ }
+ }
+ }
+}
diff --git a/src/Cronofy/Responses/AttachmentResponse.cs b/src/Cronofy/Responses/AttachmentResponse.cs
new file mode 100644
index 0000000..ad9d41c
--- /dev/null
+++ b/src/Cronofy/Responses/AttachmentResponse.cs
@@ -0,0 +1,48 @@
+namespace Cronofy.Responses
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Newtonsoft.Json;
+
+ ///
+ /// Class for the deserialization of an availability response.
+ ///
+ internal sealed class AttachmentResponse
+ {
+ ///
+ /// Gets or sets the available periods of the response.
+ ///
+ ///
+ /// The available periods of the response.
+ ///
+ [JsonProperty("attachment")]
+ public AttachmentSummary Attachment { get; set; }
+
+ internal sealed class AttachmentSummary
+ {
+ [JsonProperty("attachment_id")]
+ public string AttachmentId { get; set; }
+
+ [JsonProperty("file_name")]
+ public string FileName { get; set; }
+
+ [JsonProperty("content_type")]
+ public string ContentType { get; set; }
+
+ [JsonProperty("md5")]
+ public string MD5 { get; set; }
+ }
+
+ public Attachment ToAttachment()
+ {
+ return new Attachment
+ {
+ AttachmentId = this.Attachment.AttachmentId,
+ FileName = this.Attachment.FileName,
+ ContentType = this.Attachment.ContentType,
+ MD5 = this.Attachment.MD5,
+ };
+ }
+ }
+}
diff --git a/src/Cronofy/UrlProvider.cs b/src/Cronofy/UrlProvider.cs
index 8f0c50f..130dbbb 100644
--- a/src/Cronofy/UrlProvider.cs
+++ b/src/Cronofy/UrlProvider.cs
@@ -170,6 +170,11 @@ public sealed class UrlProvider
///
private const string ConferencingServiceAuthorizationUrlFormat = "https://api{0}.cronofy.com/v1/conferencing_service_authorizations";
+ ///
+ /// The URL of the Attachments endpoint.
+ ///
+ private const string AttachmentsUrlFormat = "https://api{0}.cronofy.com/v1/attachments";
+
///
/// Initializes a new instance of the class.
///
@@ -218,6 +223,7 @@ internal UrlProvider(string dataCenter)
this.ProvisionApplicationUrl = string.Format(ProvisionApplicationUrlFormat, suffix);
this.ElementTokensUrl = string.Format(ElementTokensUrlFormat, suffix);
this.ConferencingServiceAuthorizationUrl = string.Format(ConferencingServiceAuthorizationUrlFormat, suffix);
+ this.AttachmentsUrl = string.Format(AttachmentsUrlFormat, suffix);
}
///
@@ -567,5 +573,11 @@ public string BatchUrl
///
/// The conferencing service authorization URL.
public string ConferencingServiceAuthorizationUrl { get; private set; }
+
+ ///
+ /// Gets the attachments URL.
+ ///
+ /// The attachments URL.
+ public string AttachmentsUrl { get; private set; }
}
}