Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24eeb6c
commit 5fafadf
Showing
22 changed files
with
216 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
|
||
namespace Braintree | ||
{ | ||
public class AchMandate | ||
{ | ||
public virtual string Text { get; protected set; } | ||
public virtual DateTime? AcceptedAt { get; protected set; } | ||
|
||
protected internal AchMandate(NodeWrapper node) | ||
{ | ||
if (node == null) return; | ||
|
||
Text = node.GetString("text"); | ||
AcceptedAt = node.GetDateTime("accepted-at"); | ||
} | ||
|
||
[Obsolete("Mock Use Only")] | ||
protected AchMandate() { } | ||
} | ||
} |
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,47 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Braintree | ||
{ | ||
public class PaginatedCollection<T> : IEnumerable<T> where T : class | ||
{ | ||
public int Size { get { return TotalItems; } } | ||
|
||
private int PageSize = 0; | ||
private int CurrentPage = 0; | ||
private int Index = 0; | ||
private int TotalItems = 0; | ||
private List<T> Items = new List<T>(); | ||
private System.Func<int, PaginatedResult<T>> Pager; | ||
|
||
public PaginatedCollection(System.Func<int, PaginatedResult<T>> pager) | ||
{ | ||
Pager = pager; | ||
} | ||
|
||
public IEnumerator<T> GetEnumerator() | ||
{ | ||
do | ||
{ | ||
if (CurrentPage == 0 || Index % PageSize == 0) | ||
{ | ||
CurrentPage++; | ||
var results = Pager(CurrentPage); | ||
TotalItems = results.TotalItems; | ||
PageSize = results.PageSize; | ||
Items = results.Items; | ||
} | ||
|
||
foreach (T item in Items) | ||
{ | ||
Index++; | ||
yield return item; | ||
} | ||
} while(Index < TotalItems); | ||
} | ||
|
||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | ||
{ | ||
return this.GetEnumerator(); | ||
} | ||
} | ||
} |
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,18 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Braintree | ||
{ | ||
public class PaginatedResult<T> where T : class | ||
{ | ||
public int TotalItems { get; private set; } | ||
public int PageSize { get; private set; } | ||
public List<T> Items { get; private set; } | ||
|
||
public PaginatedResult(int totalItems, int pageSize, List<T> items) | ||
{ | ||
TotalItems = totalItems; | ||
PageSize = pageSize; | ||
Items = items; | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.