-
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.
* SMS-25 Add support for getting and adding opt outs
- Loading branch information
1 parent
9b6ed4f
commit 7a4489e
Showing
37 changed files
with
1,360 additions
and
163 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 @@ | ||
* -text |
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 |
---|---|---|
@@ -1,86 +1,94 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Xml.Serialization; | ||
|
||
namespace com.esendex.sdk.core | ||
{ | ||
/// <summary> | ||
/// Represents a paged collection of objects which all paged collection are derived. | ||
/// </summary> | ||
/// <typeparam name="T">The type of objects.</typeparam> | ||
public abstract class PagedCollection<T> : IPagedCollection<T> | ||
where T : class | ||
{ | ||
/// <summary> | ||
/// <![CDATA[Initialises a new instance of the com.esendex.sdk.core.PagedCollection<T>]]> | ||
/// </summary> | ||
public PagedCollection() | ||
{ | ||
Items = new List<T>(); | ||
} | ||
|
||
protected List<T> Items { get; set; } | ||
|
||
private int startIndex; | ||
|
||
/// <summary> | ||
/// Gets or sets the page number. | ||
/// </summary> | ||
[XmlAttribute("startindex")] | ||
public int PageNumber | ||
{ | ||
get | ||
{ | ||
// Convert the zero based collection index to a real page number. | ||
return (startIndex/PageSize) + 1; | ||
} | ||
set { startIndex = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the page size. | ||
/// </summary> | ||
[XmlAttribute("count")] | ||
public int PageSize { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the total number of items in the paged resource. | ||
/// </summary> | ||
[XmlAttribute("totalcount")] | ||
public int TotalItems { get; set; } | ||
|
||
/// <summary> | ||
/// Determines whether the specified System.Object are considered equal. | ||
/// </summary> | ||
/// <param name="obj">The System.Object to compare with the current System.Object</param> | ||
/// <returns>true if the specified System.Object is equal to the current System.Object; otherwise, false.</returns> | ||
public override bool Equals(object obj) | ||
{ | ||
var other = obj as PagedCollection<T>; | ||
|
||
if (other == null) return false; | ||
|
||
if (PageNumber != other.PageNumber) return false; | ||
if (PageSize != other.PageSize) return false; | ||
if (TotalItems != other.TotalItems) return false; | ||
|
||
if (Items.Count != other.Items.Count) return false; | ||
|
||
for (var i = 0; i < Items.Count; i++) | ||
{ | ||
if (Items.ElementAt(i) != other.Items.ElementAt(i)) return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/// <summary> | ||
/// Serves as a hash function for a particular type. | ||
/// </summary> | ||
/// <returns>A hash code for the current System.Object</returns> | ||
public override int GetHashCode() | ||
{ | ||
return base.GetHashCode(); | ||
} | ||
} | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Xml.Serialization; | ||
using Newtonsoft.Json; | ||
|
||
namespace com.esendex.sdk.core | ||
{ | ||
/// <summary> | ||
/// Represents a paged collection of objects which all paged collection are derived. | ||
/// </summary> | ||
/// <typeparam name="T">The type of objects.</typeparam> | ||
public abstract class PagedCollection<T> : IPagedCollection<T> | ||
where T : class | ||
{ | ||
/// <summary> | ||
/// <![CDATA[Initialises a new instance of the com.esendex.sdk.core.PagedCollection<T>]]> | ||
/// </summary> | ||
public PagedCollection() | ||
{ | ||
Items = new List<T>(); | ||
} | ||
|
||
protected List<T> Items { get; set; } | ||
|
||
private int startIndex; | ||
|
||
/// <summary> | ||
/// Gets or sets the page number. | ||
/// </summary> | ||
[XmlAttribute("startindex")] | ||
[JsonProperty("startindex")] | ||
public int PageNumber | ||
{ | ||
get | ||
{ | ||
// Convert the zero based collection index to a real page number. | ||
if (PageSize == 0 && TotalItems == 0) | ||
{ | ||
return 1; | ||
} | ||
return (startIndex/PageSize) + 1; | ||
} | ||
set { startIndex = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the page size. | ||
/// </summary> | ||
[XmlAttribute("count")] | ||
[JsonProperty("count")] | ||
public int PageSize { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the total number of items in the paged resource. | ||
/// </summary> | ||
[XmlAttribute("totalcount")] | ||
[JsonProperty("totalcount")] | ||
public int TotalItems { get; set; } | ||
|
||
/// <summary> | ||
/// Determines whether the specified System.Object are considered equal. | ||
/// </summary> | ||
/// <param name="obj">The System.Object to compare with the current System.Object</param> | ||
/// <returns>true if the specified System.Object is equal to the current System.Object; otherwise, false.</returns> | ||
public override bool Equals(object obj) | ||
{ | ||
var other = obj as PagedCollection<T>; | ||
|
||
if (other == null) return false; | ||
|
||
if (PageNumber != other.PageNumber) return false; | ||
if (PageSize != other.PageSize) return false; | ||
if (TotalItems != other.TotalItems) return false; | ||
|
||
if (Items.Count != other.Items.Count) return false; | ||
|
||
for (var i = 0; i < Items.Count; i++) | ||
{ | ||
if (Items.ElementAt(i) != other.Items.ElementAt(i)) return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/// <summary> | ||
/// Serves as a hash function for a particular type. | ||
/// </summary> | ||
/// <returns>A hash code for the current System.Object</returns> | ||
public override int GetHashCode() | ||
{ | ||
return base.GetHashCode(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
using System; | ||
using System.Collections.Specialized; | ||
using System.Web; | ||
|
||
namespace com.esendex.sdk.http | ||
{ | ||
public class HttpUriBuilder | ||
{ | ||
private readonly UriBuilder _uriBuilder; | ||
private readonly NameValueCollection _query; | ||
|
||
private HttpUriBuilder(string url) | ||
{ | ||
_uriBuilder = new UriBuilder(url); | ||
_query = HttpUtility.ParseQueryString(string.Empty); | ||
} | ||
|
||
public static HttpUriBuilder Create(string url) | ||
{ | ||
return new HttpUriBuilder(url); | ||
} | ||
|
||
public HttpUriBuilder WithParameter(string name, string value) | ||
{ | ||
_query[name] = value; | ||
return this; | ||
} | ||
|
||
public Uri Build() | ||
{ | ||
_uriBuilder.Query = _query.ToString(); | ||
return _uriBuilder.Uri; | ||
} | ||
} | ||
} |
Oops, something went wrong.