-
Notifications
You must be signed in to change notification settings - Fork 584
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from sendgrid/stats
Stats
- Loading branch information
Showing
9 changed files
with
167 additions
and
21 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
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,48 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using System.Web; | ||
|
||
namespace SendGrid.Resources | ||
{ | ||
public class GlobalStats | ||
{ | ||
private string _endpoint; | ||
private Client _client; | ||
|
||
/// <summary> | ||
/// Constructs the SendGrid GlobalStats object. | ||
/// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Stats/global.html | ||
/// </summary> | ||
/// <param name="client">SendGrid Web API v3 client</param> | ||
/// <param name="endpoint">Resource endpoint, do not prepend slash</param> | ||
public GlobalStats(Client client, string endpoint = "v3/stats") | ||
{ | ||
_endpoint = endpoint; | ||
_client = client; | ||
} | ||
|
||
/// <summary> | ||
/// https://sendgrid.com/docs/API_Reference/Web_API_v3/Stats/global.html | ||
/// </summary> | ||
/// <param name="startDate">The starting date of the statistics to retrieve, formatted as YYYY-MM-DD.</param> | ||
/// <param name="endDate">The end date of the statistics to retrieve, formatted as YYYY-MM-DD. Defaults to today.</param> | ||
/// <param name="aggregatedBy">How to group the statistics, must be day|week|month</param> | ||
/// <returns>https://sendgrid.com/docs/API_Reference/Web_API_v3/Stats/global.html</returns> | ||
public async Task<HttpResponseMessage> Get(string startDate, string endDate = null, string aggregatedBy = null) | ||
{ | ||
var query = HttpUtility.ParseQueryString(string.Empty); | ||
query["start_date"] = startDate; | ||
if (endDate != null) | ||
{ | ||
query["end_date"] = endDate; | ||
} | ||
if (aggregatedBy != null) | ||
{ | ||
query["aggregated_by"] = aggregatedBy; | ||
} | ||
return await _client.Get(_endpoint + "?" + query); | ||
} | ||
|
||
} | ||
} |
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