-
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 #166 from sendgrid/asm_groups_get_post
Asm groups [GET, POST, DELETE]
- Loading branch information
Showing
11 changed files
with
235 additions
and
10 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
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,70 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace SendGrid.Resources | ||
{ | ||
public class UnsubscribeGroups | ||
{ | ||
private string _endpoint; | ||
private Client _client; | ||
|
||
/// <summary> | ||
/// Constructs the SendGrid UnsubscribeGroups object. | ||
/// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html | ||
/// </summary> | ||
/// <param name="client">SendGrid Web API v3 client</param> | ||
/// <param name="endpoint">Resource endpoint, do not prepend slash</param> | ||
public UnsubscribeGroups(Client client, string endpoint = "v3/asm/groups") | ||
{ | ||
_endpoint = endpoint; | ||
_client = client; | ||
} | ||
|
||
/// <summary> | ||
/// Retrieve all suppression groups associated with the user.s | ||
/// </summary> | ||
/// <returns>https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html</returns> | ||
public async Task<HttpResponseMessage> Get() | ||
{ | ||
return await _client.Get(_endpoint); | ||
} | ||
|
||
/// <summary> | ||
/// Retrieve all suppression groups associated with the user.s | ||
/// </summary> | ||
/// <returns>https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html</returns> | ||
public async Task<HttpResponseMessage> Get(int unsubscribeGroupID) | ||
{ | ||
string endpoint = _endpoint + "/" + unsubscribeGroupID; | ||
return await _client.Get(endpoint); | ||
} | ||
|
||
/// <summary> | ||
/// Create a new suppression group. | ||
/// </summary> | ||
/// <param name="unsubscribeGroupName">The name of the new suppression group</param> | ||
/// <param name="unsubscribeGroupDescription">A description of the suppression group</param> | ||
/// <param name="unsubscribeGroupIsDefault">Default value is false</param> | ||
/// <returns>https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html</returns> | ||
public async Task<HttpResponseMessage> Post(string unsubscribeGroupName, | ||
string unsubscribeGroupDescription, | ||
bool unsubscribeGroupIsDefault) | ||
{ | ||
var data = new JObject {{"name", unsubscribeGroupName}, | ||
{"description", unsubscribeGroupDescription}, | ||
{"is_default", unsubscribeGroupIsDefault}}; | ||
return await _client.Post(_endpoint, data); | ||
} | ||
|
||
/// <summary> | ||
/// Delete a suppression group. | ||
/// </summary> | ||
/// <param name="unsubscribeGroupId">ID of the suppression group to delete</param> | ||
/// <returns>https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html</returns> | ||
public async Task<HttpResponseMessage> Delete(string unsubscribeGroupId) | ||
{ | ||
return await _client.Delete(_endpoint + "/" + unsubscribeGroupId); | ||
} | ||
} | ||
} |
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