mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 19:11:30 +00:00
wireup delete API
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
@@ -17,5 +17,26 @@ namespace Octokit.Tests.Integration.Clients
|
||||
var emails = await github.User.Email.GetAll();
|
||||
Assert.NotEmpty(emails);
|
||||
}
|
||||
|
||||
const string testEmailAddress = "hahaha-not-a-real-email@foo.com";
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanAddAndDeleteEmail()
|
||||
{
|
||||
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
|
||||
await github.User.Email.Add(testEmailAddress);
|
||||
|
||||
var emails = await github.User.Email.GetAll();
|
||||
Assert.Contains(testEmailAddress, emails.Select(x => x.Email));
|
||||
|
||||
await github.User.Email.Delete(testEmailAddress);
|
||||
|
||||
emails = await github.User.Email.GetAll();
|
||||
Assert.DoesNotContain(testEmailAddress, emails.Select(x => x.Email));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,5 +31,15 @@ namespace Octokit
|
||||
/// <param name="emailAddresses">The email addresses to add.</param>
|
||||
/// <returns>Returns the added <see cref="EmailAddress"/>es.</returns>
|
||||
Task<IReadOnlyList<EmailAddress>> Add(params string[] emailAddresses);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes email addresses for the authenticated user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/users/emails/#delete-email-addresses
|
||||
/// </remarks>
|
||||
/// <param name="emailAddresses">The email addresses to add.</param>
|
||||
/// <returns>Returns the added <see cref="EmailAddress"/>es.</returns>
|
||||
Task Delete(params string[] emailAddresses);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,22 @@ namespace Octokit
|
||||
|
||||
return ApiConnection.Post<IReadOnlyList<EmailAddress>>(ApiUrls.Emails(), emailAddresses);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes email addresses for the authenticated user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/users/emails/#delete-email-addresses
|
||||
/// </remarks>
|
||||
/// <param name="emailAddresses">The email addresses to add.</param>
|
||||
/// <returns>Returns the added <see cref="EmailAddress"/>es.</returns>
|
||||
public Task Delete(params string[] emailAddresses)
|
||||
{
|
||||
Ensure.ArgumentNotNull(emailAddresses, "emailAddresses");
|
||||
if (emailAddresses.Any(String.IsNullOrWhiteSpace))
|
||||
throw new ArgumentException("Cannot contain null, empty or whitespace values", "emailAddresses");
|
||||
|
||||
return ApiConnection.Delete(ApiUrls.Emails(), emailAddresses);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user