Skip to content

Commit

Permalink
Merge branch 'release/0.69.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed May 10, 2020
2 parents 9a08797 + 441fcdb commit 8a0039b
Show file tree
Hide file tree
Showing 7 changed files with 296 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public async Task RunAsync(IClient client, TextWriter log, CancellationToken can
await log.WriteLineAsync("Unsubscribe group created").ConfigureAwait(false);
}

var singleSend = await client.SingleSends.CreateAsync("StrongGrid Integration Testing: new single send", sender.Id, default, default, unsubscribeGroup.Id, new[] { list.Id }, default, default, default, cancellationToken).ConfigureAwait(false);
var subject = "This is a test";
var htmlContent = "<html><body><b>This is a test</b></body></html>";
var singleSend = await client.SingleSends.CreateAsync("StrongGrid Integration Testing: new single send", sender.Id, subject, htmlContent, default, default, EditorType.Code, default, default, unsubscribeGroup.Id, new[] { list.Id }, default, default, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Single Send '{singleSend.Name}' created. Id: {singleSend.Id}").ConfigureAwait(false);

singleSend = await client.SingleSends.UpdateAsync(singleSend.Id, categories: new[] { "category1", "category2" }, cancellationToken: cancellationToken).ConfigureAwait(false);
Expand Down
23 changes: 23 additions & 0 deletions Source/StrongGrid/Extensions/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,29 @@ internal static async Task<PaginatedResponse<T>> AsPaginatedResponse<T>(this Htt
]
}
The documentation says that it should look like this:
{
"errors": [
{
"message": <string>,
"field": <string>,
"error_id": <string>
}
]
}
The documentation for "Add or Update a Contact" under the "New Marketing Campaigns" section says that it looks like this:
{
"errors": [
{
"message": <string>,
"field": <string>,
"error_id": <string>,
"parameter": <string>
}
]
}
I have also seen cases where the JSON string looks like this:
{
"error": "Name already exists"
Expand Down
167 changes: 121 additions & 46 deletions Source/StrongGrid/Models/SingleSend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,113 +36,188 @@ public class SingleSend
public string[] Categories { get; set; }

/// <summary>
/// Gets or sets the sender identifier.
/// Gets or sets the status.
/// </summary>
/// <value>
/// The sender identifier.
/// The status.
/// </value>
[JsonProperty("sender_id", NullValueHandling = NullValueHandling.Ignore)]
public long SenderId { get; set; }
[JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)]
public SingleSendStatus Status { get; set; }

/// <summary>
/// Gets or sets the status.
/// Gets or sets the date and time when the single send will be sent.
/// </summary>
/// <value>
/// The status.
/// The date and time when the single send will be sent.
/// </value>
[JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)]
public SingleSendStatus Status { get; set; }
[JsonProperty("send_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTime? SendOn { get; set; }

/// <summary>
/// Gets or sets the custom unsubscribe URL.
/// Gets or sets the date and time when the single send was modified.
/// </summary>
/// <value>
/// The custom unsubscribe URL.
/// The date and time when the single send was modified.
/// </value>
[JsonProperty("custom_unsubscribe_url", NullValueHandling = NullValueHandling.Ignore)]
public string CustomUnsubscribeUrl { get; set; }
[JsonProperty("updated_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTime? UpdatedOn { get; set; }

/// <summary>
/// Gets or sets the suppression group identifier.
/// Gets or sets the date and time when the single send was created.
/// </summary>
/// <value>
/// The suppression group identifier.
/// The date and time when the single send was created.
/// </value>
[JsonProperty("suppression_group_id", NullValueHandling = NullValueHandling.Ignore)]
public long? SuppressionGroupId { get; set; }
[JsonProperty("created_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTime? CreatedOn { get; set; }

/// <summary>
/// Gets or sets the lists.
/// Gets or sets the subject.
/// </summary>
/// <value>
/// The lists.
/// The subject.
/// </value>
[JsonIgnore]
public string[] Lists
public string Subject
{
get { return Filter.Lists; }
set { Filter.Lists = value; }
get => EmailConfig.Subject;
set => EmailConfig.Subject = value;
}

/// <summary>
/// Gets or sets the segments.
/// Gets or sets the HTML content.
/// </summary>
/// <value>
/// The segments.
/// The HTML content.
/// </value>
[JsonIgnore]
public string[] Segments
public string HtmlContent
{
get { return Filter.Segments; }
set { Filter.Segments = value; }
get => EmailConfig.HtmlContent;
set => EmailConfig.HtmlContent = value;
}

/// <summary>
/// Gets or sets the date and time when the single send will be sent.
/// Gets or sets the plain text content.
/// </summary>
/// <value>
/// The date and time when the single send will be sent.
/// The plain text content.
/// </value>
[JsonProperty("send_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTime? SendOn { get; set; }
[JsonIgnore]
public string TextContent
{
get => EmailConfig.TextContent;
set => EmailConfig.TextContent = value;
}

/// <summary>
/// Gets or sets the template.
/// Gets or sets a value indicating whether the plain content should be generated.
/// </summary>
/// <value>
/// The template identifier.
/// The generate_plain_content.
/// </value>
[JsonProperty("template_id", NullValueHandling = NullValueHandling.Ignore)]
public string TemplateId { get; set; }
[JsonIgnore]
public bool GeneratePlainContent
{
get => EmailConfig.GeneratePlainContent;
set => EmailConfig.GeneratePlainContent = value;
}

/// <summary>
/// Gets or sets the date and time when the single send was modified.
/// Gets or sets the type of editor used in the UI.
/// </summary>
/// <value>
/// The date and time when the single send was modified.
/// The type of editor.
/// </value>
[JsonProperty("updated_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTime? UpdatedOn { get; set; }
[JsonIgnore]
public EditorType EditorType
{
get => EmailConfig.EditorType;
set => EmailConfig.EditorType = value;
}

/// <summary>
/// Gets or sets the date and time when the single send was created.
/// Gets or sets the sender identifier.
/// </summary>
/// <value>
/// The date and time when the single send was created.
/// The sender identifier.
/// </value>
[JsonProperty("created_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTime? CreatedOn { get; set; }
[JsonIgnore]
public long SenderId
{
get => EmailConfig.SenderId;
set => EmailConfig.SenderId = value;
}

/// <summary>
/// Gets or sets the custom unsubscribe URL.
/// </summary>
/// <value>
/// The custom unsubscribe URL.
/// </value>
[JsonIgnore]
public string CustomUnsubscribeUrl
{
get => EmailConfig.CustomUnsubscribeUrl;
set => EmailConfig.CustomUnsubscribeUrl = value;
}

/// <summary>
/// Gets or sets the suppression group identifier.
/// </summary>
/// <value>
/// The suppression group identifier.
/// </value>
[JsonIgnore]
public long? SuppressionGroupId
{
get => EmailConfig.SuppressionGroupId;
set => EmailConfig.SuppressionGroupId = value;
}

/// <summary>
/// Gets or sets the ip pool.
/// </summary>
/// <value>
/// The ip pool.
/// </value>
[JsonProperty("ip_pool", NullValueHandling = NullValueHandling.Ignore)]
public string IpPool { get; set; }
[JsonIgnore]
public string IpPool
{
get => EmailConfig.IpPool;
set => EmailConfig.IpPool = value;
}

/// <summary>
/// Gets or sets the lists.
/// </summary>
/// <value>
/// The lists.
/// </value>
[JsonIgnore]
public string[] Lists
{
get => SendTo.Lists;
set => SendTo.Lists = value;
}

/// <summary>
/// Gets or sets the segments.
/// </summary>
/// <value>
/// The segments.
/// </value>
[JsonIgnore]
public string[] Segments
{
get => SendTo.Segments;
set => SendTo.Segments = value;
}

[JsonProperty("email_config", NullValueHandling = NullValueHandling.Ignore)]
private SingleSendEmailConfig EmailConfig { get; set; }

[JsonProperty("filter", NullValueHandling = NullValueHandling.Ignore)]
private SingleSendFilter Filter { get; set; }
[JsonProperty("send_to", NullValueHandling = NullValueHandling.Ignore)]
private SingleSendSendTo SendTo { get; set; }
}
}
91 changes: 91 additions & 0 deletions Source/StrongGrid/Models/SingleSendEmailConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using Newtonsoft.Json;

namespace StrongGrid.Models
{
/// <summary>
/// Single Send email config.
/// </summary>
internal class SingleSendEmailConfig
{
/// <summary>
/// Gets or sets the subject.
/// </summary>
/// <value>
/// The subject.
/// </value>
[JsonProperty("subject", NullValueHandling = NullValueHandling.Ignore)]
public string Subject { get; set; }

/// <summary>
/// Gets or sets the HTML content.
/// </summary>
/// <value>
/// The HTML content.
/// </value>
[JsonProperty("html_content", NullValueHandling = NullValueHandling.Ignore)]
public string HtmlContent { get; set; }

/// <summary>
/// Gets or sets the plain text content.
/// </summary>
/// <value>
/// The plain text content.
/// </value>
[JsonProperty("plain_content", NullValueHandling = NullValueHandling.Ignore)]
public string TextContent { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the plain content should be generated.
/// </summary>
/// <value>
/// The generate_plain_content.
/// </value>
[JsonProperty("generate_plain_content", NullValueHandling = NullValueHandling.Ignore)]
public bool GeneratePlainContent { get; set; }

/// <summary>
/// Gets or sets the type of editor used in the UI.
/// </summary>
/// <value>
/// The type of editor.
/// </value>
[JsonProperty("editor", NullValueHandling = NullValueHandling.Ignore)]
public EditorType EditorType { get; set; }

/// <summary>
/// Gets or sets the suppression group identifier.
/// </summary>
/// <value>
/// The suppression group identifier.
/// </value>
[JsonProperty("suppression_group_id", NullValueHandling = NullValueHandling.Ignore)]
public long? SuppressionGroupId { get; set; }

/// <summary>
/// Gets or sets the custom unsubscribe URL.
/// </summary>
/// <value>
/// The custom unsubscribe URL.
/// </value>
[JsonProperty("custom_unsubscribe_url", NullValueHandling = NullValueHandling.Ignore)]
public string CustomUnsubscribeUrl { get; set; }

/// <summary>
/// Gets or sets the sender identifier.
/// </summary>
/// <value>
/// The sender identifier.
/// </value>
[JsonProperty("sender_id", NullValueHandling = NullValueHandling.Ignore)]
public long SenderId { get; set; }

/// <summary>
/// Gets or sets the ip pool.
/// </summary>
/// <value>
/// The ip pool.
/// </value>
[JsonProperty("ip_pool", NullValueHandling = NullValueHandling.Ignore)]
public string IpPool { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace StrongGrid.Models
{
/// <summary>
/// Single Send filter.
/// Single Send send to.
/// </summary>
public class SingleSendFilter
internal class SingleSendSendTo
{
/// <summary>
/// Gets or sets the lists.
Expand Down
Loading

0 comments on commit 8a0039b

Please sign in to comment.