diff --git a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs
index 4131b0e5..4112c010 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs
@@ -10,8 +10,7 @@ namespace Octokit.Reactive
///
/// See API documentation for more information.
///
- [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")]
- IObservable Get(string owner, string repositoryName);
+ IObservable GetAll(string owner, string repositoryName, RepositoryForksListRequest request);
///
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
diff --git a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs
index e8089f61..f3176e0a 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs
@@ -11,15 +11,15 @@ namespace Octokit.Reactive
///
/// See API documentation for more information.
///
- [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")]
- IObservable Get(string owner, string repositoryName);
+ IObservable GetAll(string owner, string repositoryName);
///
/// Gets a single hook defined for a repository by id
///
/// See API documentation for more information.
///
- IObservable GetById(string owner, string repositoryName, int hookId);
+ [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")]
+ IObservable Get(string owner, string repositoryName, int hookId);
///
/// Creates a hook for a repository
@@ -44,6 +44,13 @@ namespace Octokit.Reactive
///
IObservable Test(string owner, string repositoryName, int hookId);
+ ///
+ /// This will trigger a ping event to be sent to the hook.
+ ///
+ /// See API documentation for more information.
+ ///
+ IObservable Ping(string owner, string repositoryName, int hookId);
+
///
/// Deletes a hook for a repository
///
diff --git a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs
index bba8e985..691a55d4 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs
@@ -25,12 +25,15 @@ namespace Octokit.Reactive
///
/// See API documentation for more information.
///
- public IObservable Get(string owner, string repositoryName)
+ public IObservable GetAll(string owner, string repositoryName, RepositoryForksListRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
- return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName));
+ if (request == null)
+ return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName));
+ else
+ return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary());
}
///
diff --git a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs
index 8b8d5fa3..7b229dd2 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs
@@ -23,7 +23,7 @@ namespace Octokit.Reactive
///
/// See API documentation for more information.
///
- public IObservable Get(string owner, string repositoryName)
+ public IObservable GetAll(string owner, string repositoryName)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
@@ -36,12 +36,12 @@ namespace Octokit.Reactive
///
/// See API documentation for more information.
///
- public IObservable GetById(string owner, string repositoryName, int hookId)
+ public IObservable Get(string owner, string repositoryName, int hookId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
- return _client.GetById(owner, repositoryName, hookId).ToObservable();
+ return _client.Get(owner, repositoryName, hookId).ToObservable();
}
///
@@ -87,6 +87,19 @@ namespace Octokit.Reactive
return _client.Test(owner, repositoryName, hookId).ToObservable();
}
+ ///
+ /// This will trigger a ping event to be sent to the hook.
+ ///
+ /// See API documentation for more information.
+ ///
+ public IObservable Ping(string owner, string repositoryName, int hookId)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
+
+ return _client.Ping(owner, repositoryName, hookId).ToObservable();
+ }
+
///
/// Deletes a hook for a repository
///
diff --git a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs
index 892e4550..c85fc4b6 100644
--- a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs
@@ -7,14 +7,14 @@ namespace Octokit.Tests.Integration.Clients
{
public class RepositoryForksClientTests
{
- public class TheGetMethod
+ public class TheGetAllMethod
{
[IntegrationTest]
public async Task ReturnsForksForRepository()
{
var github = Helper.GetAuthenticatedClient();
- var forks = await github.Repository.Forks.Get("octokit", "octokit.net");
+ var forks = await github.Repository.Forks.GetAll("octokit", "octokit.net", null);
var masterFork = forks.FirstOrDefault(fork => fork.FullName == "TeamBinary/octokit.net");
Assert.NotNull(masterFork);
@@ -26,7 +26,7 @@ namespace Octokit.Tests.Integration.Clients
{
var github = Helper.GetAuthenticatedClient();
- var actualForks = (await github.Repository.Forks.Get("octokit", "octokit.net", new RepositoryForksListRequest { Sort = Sort.Oldest })).ToArray();
+ var actualForks = (await github.Repository.Forks.GetAll("octokit", "octokit.net", new RepositoryForksListRequest { Sort = Sort.Oldest })).ToArray();
var sortedForks = actualForks.OrderBy(fork => fork.CreatedAt).ToArray();
for (var index = 0; index < actualForks.Length; index++)
diff --git a/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs
new file mode 100644
index 00000000..2580475c
--- /dev/null
+++ b/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs
@@ -0,0 +1,190 @@
+using System.Linq;
+using System.Threading.Tasks;
+using Octokit.Tests.Integration.fixtures;
+using Xunit;
+
+namespace Octokit.Tests.Integration.Clients
+{
+ public class RepositoryHooksClientTests
+ {
+ [Collection("Repositories Hooks Collection")]
+ public class TheGetAllMethod
+ {
+ readonly RepositoriesHooksFixture _fixture;
+
+ public TheGetAllMethod(RepositoriesHooksFixture fixture)
+ {
+ _fixture = fixture;
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsAllHooksFromRepository()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var hooks = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName);
+
+ Assert.Single(hooks);
+ var actualHook = hooks[0];
+
+ AssertHook(_fixture.ExpectedHook, actualHook);
+ }
+ }
+
+ [Collection("Repositories Hooks Collection")]
+ public class TheGetMethod
+ {
+ readonly RepositoriesHooksFixture _fixture;
+
+ public TheGetMethod(RepositoriesHooksFixture fixture)
+ {
+ _fixture = fixture;
+ }
+
+ [IntegrationTest]
+ public async Task GetHookByCreatedId()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var actualHook = await github.Repository.Hooks.Get(_fixture.RepositoryOwner, _fixture.RepositoryName, _fixture.ExpectedHook.Id);
+
+ AssertHook(_fixture.ExpectedHook, actualHook);
+ }
+ }
+
+ public class TheCreateMethod
+ {
+ [IntegrationTest]
+ public async Task CreateAWebHookForTestRepository()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var repoName = Helper.MakeNameWithTimestamp("create-hooks-test");
+ var repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true });
+
+ var parameters = new NewRepositoryHook("tenxer", new { content_type = "json", url = "http://test.com/example" })
+ {
+ Events = new[] { "delete" },
+ Active = false
+ };
+ var hook = await github.Repository.Hooks.Create(Helper.Credentials.Login, repository.Name, parameters);
+
+ var baseHookUrl = CreateExpectedBaseHookUrl(repository.Url, hook.Id);
+ Assert.Equal("tenxer", hook.Name);
+ Assert.Equal(new[] { "delete" }.ToList(), hook.Events.ToList());
+ Assert.Equal(baseHookUrl, hook.Url);
+ Assert.Equal(baseHookUrl + "/test", hook.TestUrl);
+ Assert.Equal(baseHookUrl + "/pings", hook.PingUrl);
+ Assert.NotNull(hook.CreatedAt);
+ Assert.NotNull(hook.UpdatedAt);
+
+ // TODO: KHA - It seems that even though I provide 'false' to active the response states that it is active
+ //Assert.Equal(false, hook.Active);
+ }
+
+ string CreateExpectedBaseHookUrl(string url, int id)
+ {
+ return url + "/hooks/" + id;
+ }
+ }
+
+ [Collection("Repositories Hooks Collection")]
+ public class TheEditMethod
+ {
+ readonly RepositoriesHooksFixture _fixture;
+
+ public TheEditMethod(RepositoriesHooksFixture fixture)
+ {
+ _fixture = fixture;
+ }
+
+ [IntegrationTest]
+ public async Task EditHookWithNewInformation()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var editRepositoryHook = new EditRepositoryHook
+ {
+ AddEvents = new[] { "follow", "pull_request" }
+ };
+ var actualHook = await github.Repository.Hooks.Edit(_fixture.RepositoryOwner, _fixture.RepositoryName, _fixture.ExpectedHook.Id, editRepositoryHook);
+
+ // TODO: KHA - It seems that the first AddEvent is either not provided or correctly returned by github
+ //Assert.Equal(new[] { "delete", "follow", "pull_request" }.ToList(), actualHook.Events.ToList());
+ }
+ }
+
+ [Collection("Repositories Hooks Collection")]
+ public class TheTestMethod
+ {
+ readonly RepositoriesHooksFixture _fixture;
+
+ public TheTestMethod(RepositoriesHooksFixture fixture)
+ {
+ _fixture = fixture;
+ }
+
+ [IntegrationTest]
+ public async Task TestACreatedHook()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ await github.Repository.Hooks.Test(_fixture.RepositoryOwner, _fixture.RepositoryName, _fixture.ExpectedHook.Id);
+ }
+ }
+
+ [Collection("Repositories Hooks Collection")]
+ public class ThePingMethod
+ {
+ readonly RepositoriesHooksFixture _fixture;
+
+ public ThePingMethod(RepositoriesHooksFixture fixture)
+ {
+ _fixture = fixture;
+ }
+
+ [IntegrationTest]
+ public async Task PingACreatedHook()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ await github.Repository.Hooks.Ping(_fixture.RepositoryOwner, _fixture.RepositoryName, _fixture.ExpectedHook.Id);
+ }
+ }
+
+ [Collection("Repositories Hooks Collection")]
+ public class TheDeleteMethod
+ {
+ readonly RepositoriesHooksFixture _fixture;
+
+ public TheDeleteMethod(RepositoriesHooksFixture fixture)
+ {
+ _fixture = fixture;
+ }
+
+ [IntegrationTest]
+ public async Task DeleteCreatedWebHook()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ await github.Repository.Hooks.Delete(_fixture.RepositoryOwner, _fixture.RepositoryName, _fixture.ExpectedHook.Id);
+ var hooks = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName);
+
+ Assert.Empty(hooks);
+ }
+ }
+
+ static void AssertHook(RepositoryHook expectedHook, RepositoryHook actualHook)
+ {
+ Assert.Equal(expectedHook.Id, actualHook.Id);
+ Assert.Equal(expectedHook.Active, actualHook.Active);
+ Assert.Equal(expectedHook.Config, actualHook.Config);
+ Assert.Equal(expectedHook.CreatedAt, actualHook.CreatedAt);
+ Assert.Equal(expectedHook.Name, actualHook.Name);
+ Assert.Equal(expectedHook.PingUrl, actualHook.PingUrl);
+ Assert.Equal(expectedHook.TestUrl, actualHook.TestUrl);
+ Assert.Equal(expectedHook.UpdatedAt, actualHook.UpdatedAt);
+ Assert.Equal(expectedHook.Url, actualHook.Url);
+ }
+ }
+}
diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
index 2f3f616e..58c045a7 100644
--- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
+++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
@@ -90,12 +90,15 @@
+
+
+
diff --git a/Octokit.Tests.Integration/fixtures/RepositoriesHooksCollection.cs b/Octokit.Tests.Integration/fixtures/RepositoriesHooksCollection.cs
new file mode 100644
index 00000000..dd6b98cf
--- /dev/null
+++ b/Octokit.Tests.Integration/fixtures/RepositoriesHooksCollection.cs
@@ -0,0 +1,9 @@
+using Xunit;
+
+namespace Octokit.Tests.Integration.fixtures
+{
+ [CollectionDefinition("Repositories Hooks Collection")]
+ public class RepositoriesHooksCollection : ICollectionFixture
+ {
+ }
+}
diff --git a/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs b/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs
new file mode 100644
index 00000000..671674f6
--- /dev/null
+++ b/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs
@@ -0,0 +1,49 @@
+using System;
+
+namespace Octokit.Tests.Integration.fixtures
+{
+ public class RepositoriesHooksFixture : IDisposable
+ {
+ readonly IGitHubClient _github;
+ readonly Repository _repository;
+ readonly RepositoryHook _hook;
+
+ public RepositoriesHooksFixture()
+ {
+ _github = Helper.GetAuthenticatedClient();
+ _repository = CreateRepository(_github);
+ _hook = CreateHook(_github, _repository);
+ }
+
+ public string RepositoryOwner { get { return _repository.Owner.Login; } }
+
+ public string RepositoryName { get { return _repository.Name; } }
+
+ public RepositoryHook ExpectedHook { get { return _hook; } }
+
+ public void Dispose()
+ {
+ _github.Repository.Delete(_repository.Owner.Login, _repository.Name);
+ }
+
+ static Repository CreateRepository(IGitHubClient github)
+ {
+ var repoName = Helper.MakeNameWithTimestamp("create-hooks-test");
+ var repository = github.Repository.Create(new NewRepository(repoName) { AutoInit = true });
+
+ return repository.Result;
+ }
+
+ static RepositoryHook CreateHook(IGitHubClient github, Repository repository)
+ {
+ var parameters = new NewRepositoryHook("tenxer", new { content_type = "json", url = "http://test.com/example" })
+ {
+ Events = new[] { "delete" },
+ Active = false
+ };
+ var createdHook = github.Repository.Hooks.Create(Helper.Credentials.Login, repository.Name, parameters);
+
+ return createdHook.Result;
+ }
+ }
+}
diff --git a/Octokit.Tests/Clients/RepositoryForksClientTests.cs b/Octokit.Tests/Clients/RepositoryForksClientTests.cs
index 56da3833..8503fc8e 100644
--- a/Octokit.Tests/Clients/RepositoryForksClientTests.cs
+++ b/Octokit.Tests/Clients/RepositoryForksClientTests.cs
@@ -9,7 +9,7 @@ namespace Octokit.Tests.Clients
{
public class RepositoryForksClientTests
{
- public class TheGetMethod
+ public class TheGetAllMethod
{
[Fact]
public void RequestsCorrectUrl()
@@ -17,7 +17,7 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For();
var client = new RepositoriesClient(connection);
- client.Forks.Get("fake", "repo");
+ client.Forks.GetAll("fake", "repo", null);
connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/forks"));
}
@@ -28,7 +28,7 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For();
var client = new RepositoriesClient(connection);
- client.Forks.Get("fake", "repo", new RepositoryForksListRequest{Sort = Sort.Stargazers});
+ client.Forks.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers });
connection.Received().GetAll(
Arg.Is(u => u.ToString() == "repos/fake/repo/forks"),
@@ -40,8 +40,8 @@ namespace Octokit.Tests.Clients
{
var client = new RepositoriesClient(Substitute.For());
- await AssertEx.Throws(async () => await client.Forks.Get(null, "name"));
- await AssertEx.Throws(async () => await client.Forks.Get("owner", null));
+ await AssertEx.Throws(async () => await client.Forks.GetAll(null, "name", null));
+ await AssertEx.Throws(async () => await client.Forks.GetAll("owner", null, null));
}
}
diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs
index c94dc0a4..6ed139b8 100644
--- a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs
+++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs
@@ -1,14 +1,14 @@
-using System;
-using System.Threading.Tasks;
-using NSubstitute;
+using NSubstitute;
using Octokit.Tests.Helpers;
+using System;
+using System.Threading.Tasks;
using Xunit;
namespace Octokit.Tests.Clients
{
public class RepositoryHooksClientTests
{
- public class TheGetMethod
+ public class TheGetAllMethod
{
[Fact]
public void RequestsCorrectUrl()
@@ -16,7 +16,7 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For();
var client = new RepositoriesClient(connection);
- client.Hooks.Get("fake", "repo");
+ client.Hooks.GetAll("fake", "repo");
connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks"));
}
@@ -26,12 +26,12 @@ namespace Octokit.Tests.Clients
{
var client = new RepositoriesClient(Substitute.For());
- await AssertEx.Throws(async () => await client.Hooks.Get(null, "name"));
- await AssertEx.Throws(async () => await client.Hooks.Get("owner", null));
+ await AssertEx.Throws(async () => await client.Hooks.GetAll(null, "name"));
+ await AssertEx.Throws(async () => await client.Hooks.GetAll("owner", null));
}
}
- public class TheGetByIdMethod
+ public class TheGetMethod
{
[Fact]
public void RequestsCorrectUrl()
@@ -39,7 +39,7 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For();
var client = new RepositoriesClient(connection);
- client.Hooks.GetById("fake", "repo", 12345678);
+ client.Hooks.Get("fake", "repo", 12345678);
connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678"), null);
}
@@ -49,8 +49,8 @@ namespace Octokit.Tests.Clients
{
var client = new RepositoriesClient(Substitute.For());
- await AssertEx.Throws(async () => await client.Hooks.GetById(null, "name", 123));
- await AssertEx.Throws(async () => await client.Hooks.GetById("owner", null, 123));
+ await AssertEx.Throws(async () => await client.Hooks.Get(null, "name", 123));
+ await AssertEx.Throws(async () => await client.Hooks.Get("owner", null, 123));
}
}
@@ -61,7 +61,7 @@ namespace Octokit.Tests.Clients
{
var connection = Substitute.For();
var client = new RepositoriesClient(connection);
- var hook = new NewRepositoryHook();
+ var hook = new NewRepositoryHook("name", new { config = "" });
client.Hooks.Create("fake", "repo", hook);
@@ -73,8 +73,8 @@ namespace Octokit.Tests.Clients
{
var client = new RepositoriesClient(Substitute.For());
- await AssertEx.Throws(async () => await client.Hooks.Create(null, "name", new NewRepositoryHook()));
- await AssertEx.Throws(async () => await client.Hooks.Create("owner", null, new NewRepositoryHook()));
+ await AssertEx.Throws(async () => await client.Hooks.Create(null, "name", new NewRepositoryHook("name", new { config = "" })));
+ await AssertEx.Throws(async () => await client.Hooks.Create("owner", null, new NewRepositoryHook("name", new { config = "" })));
await AssertEx.Throws(async () => await client.Hooks.Create("owner", "name", null));
}
@@ -83,7 +83,7 @@ namespace Octokit.Tests.Clients
{
var connection = Substitute.For();
var client = new RepositoriesClient(connection);
- var newRepositoryHook = new NewRepositoryHook { Name = "aName" };
+ var newRepositoryHook = new NewRepositoryHook("name", new { config = "" });
client.Hooks.Create("owner", "repo", newRepositoryHook);
@@ -138,7 +138,7 @@ namespace Octokit.Tests.Clients
client.Hooks.Test("fake", "repo", 12345678);
- connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678/tests"), Arg.Any());
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678/tests"), Arg.Any());
}
[Fact]
@@ -149,16 +149,28 @@ namespace Octokit.Tests.Clients
await AssertEx.Throws(async () => await client.Hooks.Test(null, "name", 12345678));
await AssertEx.Throws(async () => await client.Hooks.Test("owner", null, 12345678));
}
+ }
+
+ public class ThePingMethod
+ {
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var client = new RepositoriesClient(Substitute.For());
+
+ await AssertEx.Throws(async () => await client.Hooks.Ping(null, "name", 12345678));
+ await AssertEx.Throws(async () => await client.Hooks.Ping("owner", null, 12345678));
+ }
[Fact]
- public void CallsPost()
+ public void RequestsCorrectUrl()
{
var connection = Substitute.For();
var client = new RepositoriesClient(connection);
- client.Hooks.Test("owner", "repo", 12345678);
+ client.Hooks.Ping("fake", "repo", 12345678);
- connection.Received().Post(Arg.Any(), Arg.Any());
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678/pings"), Arg.Any());
}
}
diff --git a/Octokit/Clients/IRepositoryForksClient.cs b/Octokit/Clients/IRepositoryForksClient.cs
index 4fae2c86..8d026244 100644
--- a/Octokit/Clients/IRepositoryForksClient.cs
+++ b/Octokit/Clients/IRepositoryForksClient.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
namespace Octokit
@@ -11,16 +10,7 @@ namespace Octokit
///
/// See API documentation for more information.
///
- [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")]
- Task> Get(string owner, string repositoryName);
-
- ///
- /// Gets the list of forks defined for a repository
- ///
- /// See API documentation for more information.
- ///
- [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")]
- Task> Get(string owner, string repositoryName, RepositoryForksListRequest request);
+ Task> GetAll(string owner, string repositoryName, RepositoryForksListRequest request);
///
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
diff --git a/Octokit/Clients/IRepositoryHooksClient.cs b/Octokit/Clients/IRepositoryHooksClient.cs
index c9ba580e..c282a372 100644
--- a/Octokit/Clients/IRepositoryHooksClient.cs
+++ b/Octokit/Clients/IRepositoryHooksClient.cs
@@ -11,8 +11,7 @@ namespace Octokit
///
/// See API documentation for more information.
///
- [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")]
- Task> Get(string owner, string repositoryName);
+ Task> GetAll(string owner, string repositoryName);
///
/// Gets a single hook by Id
@@ -22,7 +21,8 @@ namespace Octokit
///
///
/// See API documentation for more information.
- Task GetById(string owner, string repositoryName, int hookId);
+ [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keywords")]
+ Task Get(string owner, string repositoryName, int hookId);
///
/// Creates a hook for a repository
@@ -47,12 +47,16 @@ namespace Octokit
///
Task Test(string owner, string repositoryName, int hookId);
+ ///
+ /// This will trigger a ping event to be sent to the hook.
+ ///
+ /// See API documentation for more information.
+ ///
+ Task Ping(string owner, string repositoryName, int hookId);
+
///
/// Deletes a hook for a repository
///
- ///
- ///
- ///
/// See API documentation for more information.
///
Task Delete(string owner, string repositoryName, int hookId);
diff --git a/Octokit/Clients/RepositoryForksClient.cs b/Octokit/Clients/RepositoryForksClient.cs
index 1fb49c2b..85dacf2b 100644
--- a/Octokit/Clients/RepositoryForksClient.cs
+++ b/Octokit/Clients/RepositoryForksClient.cs
@@ -19,17 +19,7 @@ namespace Octokit
///
/// See API documentation for more information.
///
- public Task> Get(string owner, string repositoryName)
- {
- return Get(owner, repositoryName, null);
- }
-
- ///
- /// Gets the list of forks defined for a repository
- ///
- /// See API documentation for more information.
- ///
- public Task> Get(string owner, string repositoryName, RepositoryForksListRequest request)
+ public Task> GetAll(string owner, string repositoryName, RepositoryForksListRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs
index b6d98b69..ecceab3a 100644
--- a/Octokit/Clients/RepositoryHooksClient.cs
+++ b/Octokit/Clients/RepositoryHooksClient.cs
@@ -9,7 +9,8 @@ namespace Octokit
/// Initializes a new GitHub Repos API client.
///
/// An API connection.
- public RepositoryHooksClient(IApiConnection apiConnection) : base(apiConnection)
+ public RepositoryHooksClient(IApiConnection apiConnection)
+ : base(apiConnection)
{
}
@@ -18,7 +19,7 @@ namespace Octokit
///
/// See API documentation for more information.
///
- public Task> Get(string owner, string repositoryName)
+ public Task> GetAll(string owner, string repositoryName)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
@@ -34,7 +35,7 @@ namespace Octokit
///
///
/// See API documentation for more information.
- public Task GetById(string owner, string repositoryName, int hookId)
+ public Task Get(string owner, string repositoryName, int hookId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
@@ -82,15 +83,25 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
- return ApiConnection.Post(ApiUrls.RepositoryHookTest(owner, repositoryName, hookId), new TestRepositoryHook());
+ return ApiConnection.Post(ApiUrls.RepositoryHookTest(owner, repositoryName, hookId), new RepositoryHookTestRequest());
+ }
+
+ ///
+ /// This will trigger a ping event to be sent to the hook.
+ ///
+ /// See API documentation for more information.
+ ///
+ public Task Ping(string owner, string repositoryName, int hookId)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
+
+ return ApiConnection.Post(ApiUrls.RepositoryHookPing(owner, repositoryName, hookId), new RepositoryHooksPingRequest());
}
///
/// Deletes a hook for a repository
///
- ///
- ///
- ///
/// See API documentation for more information.
///
public Task Delete(string owner, string repositoryName, int hookId)
diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs
index c480544d..8b9ae86e 100644
--- a/Octokit/Helpers/ApiUrls.cs
+++ b/Octokit/Helpers/ApiUrls.cs
@@ -590,6 +590,18 @@ namespace Octokit
{
return "repos/{0}/{1}/hooks/{2}/tests".FormatUri(owner, repositoryName, hookId);
}
+
+ ///
+ /// Returns the that can ping a specified repository hook
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The identifier of the repository hook
+ ///
+ public static Uri RepositoryHookPing(string owner, string repositoryName, int hookId)
+ {
+ return "repos/{0}/{1}/hooks/{2}/pings".FormatUri(owner, repositoryName, hookId);
+ }
///
/// Returns the that lists the commit statuses for the specified reference.
diff --git a/Octokit/Models/Request/EditRepositoryHook.cs b/Octokit/Models/Request/EditRepositoryHook.cs
index acff18c0..5814c355 100644
--- a/Octokit/Models/Request/EditRepositoryHook.cs
+++ b/Octokit/Models/Request/EditRepositoryHook.cs
@@ -1,4 +1,5 @@
-using System;
+using Octokit.Internal;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
@@ -8,11 +9,20 @@ namespace Octokit
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class EditRepositoryHook
{
+ [Parameter(Key = "config")]
public dynamic Config { get; set; }
+
+ [Parameter(Key = "events")]
public IEnumerable Events { get; set; }
+
+ [Parameter(Key = "add_events")]
public IEnumerable AddEvents { get; set; }
+
+ [Parameter(Key = "remove_events")]
public IEnumerable RemoveEvents { get; set; }
- public bool Active { get; set; }
+
+ [Parameter(Key = "active")]
+ public bool? Active { get; set; }
internal string DebuggerDisplay
{
diff --git a/Octokit/Models/Request/NewRepositoryHook.cs b/Octokit/Models/Request/NewRepositoryHook.cs
index 2f9f5ac0..384ae9f4 100644
--- a/Octokit/Models/Request/NewRepositoryHook.cs
+++ b/Octokit/Models/Request/NewRepositoryHook.cs
@@ -1,4 +1,5 @@
-using System;
+using Octokit.Internal;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
@@ -8,9 +9,25 @@ namespace Octokit
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class NewRepositoryHook
{
+ public NewRepositoryHook(string name, dynamic config)
+ {
+ Name = name;
+ Config = config;
+ }
+
+ [Parameter(Key = "name")]
public string Name { get; set; }
+
+ ///
+ /// Is a key value structure determined by the web hook being created
+ ///
+ [Parameter(Key = "config")]
public dynamic Config { get; set; }
+
+ [Parameter(Key = "events")]
public IEnumerable Events { get; set; }
+
+ [Parameter(Key = "active")]
public bool Active { get; set; }
internal string DebuggerDisplay
@@ -18,7 +35,7 @@ namespace Octokit
get
{
return String.Format(CultureInfo.InvariantCulture,
- "Repository Hook: Name: {0}, Events: {1}", Name,string.Join(", ", Events));
+ "Repository Hook: Name: {0}, Events: {1}", Name, string.Join(", ", Events));
}
}
}
diff --git a/Octokit/Models/Request/TestRepositoryHook.cs b/Octokit/Models/Request/RepositoryHookTestRequest.cs
similarity index 78%
rename from Octokit/Models/Request/TestRepositoryHook.cs
rename to Octokit/Models/Request/RepositoryHookTestRequest.cs
index f04f1f70..c06dc222 100644
--- a/Octokit/Models/Request/TestRepositoryHook.cs
+++ b/Octokit/Models/Request/RepositoryHookTestRequest.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Octokit
{
- public class TestRepositoryHook
+ public class RepositoryHookTestRequest
{
}
}
diff --git a/Octokit/Models/Request/RepositoryHooksPingRequest.cs b/Octokit/Models/Request/RepositoryHooksPingRequest.cs
new file mode 100644
index 00000000..f9b948b1
--- /dev/null
+++ b/Octokit/Models/Request/RepositoryHooksPingRequest.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Octokit
+{
+ public class RepositoryHooksPingRequest
+ {
+ }
+}
diff --git a/Octokit/Models/Response/RepositoryHook.cs b/Octokit/Models/Response/RepositoryHook.cs
index 93d9af51..6b6b482e 100644
--- a/Octokit/Models/Response/RepositoryHook.cs
+++ b/Octokit/Models/Response/RepositoryHook.cs
@@ -2,15 +2,20 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
+using Octokit.Internal;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RepositoryHook
{
- public RepositoryHook(int id, string url, DateTimeOffset createdAt, DateTimeOffset updatedAt, string name, IEnumerable events, bool active, RepositoryHookConfiguration config)
+ public RepositoryHook() { }
+
+ public RepositoryHook(int id, string url, string testUrl, string pingUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, string name, IReadOnlyList events, bool active, dynamic config)
{
Url = url;
+ TestUrl = testUrl;
+ PingUrl = pingUrl;
CreatedAt = createdAt;
UpdatedAt = updatedAt;
Name = name;
@@ -24,17 +29,23 @@ namespace Octokit
public string Url { get; private set; }
+ [Parameter(Key = "test_url")]
+ public string TestUrl { get; private set; }
+
+ [Parameter(Key = "ping_url")]
+ public string PingUrl { get; private set; }
+
public DateTimeOffset CreatedAt { get; private set; }
public DateTimeOffset UpdatedAt { get; private set; }
public string Name { get; private set; }
- public IEnumerable Events { get; private set; }
+ public IReadOnlyList Events { get; private set; }
public bool Active { get; private set; }
- public RepositoryHookConfiguration Config { get; private set; }
+ public dynamic Config { get; private set; }
internal string DebuggerDisplay
{
diff --git a/Octokit/Models/Response/RepositoryHookConfiguration.cs b/Octokit/Models/Response/RepositoryHookConfiguration.cs
deleted file mode 100644
index b8cbd203..00000000
--- a/Octokit/Models/Response/RepositoryHookConfiguration.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Globalization;
-
-namespace Octokit
-{
- [DebuggerDisplay("{DebuggerDisplay,nq}")]
- public class RepositoryHookConfiguration
- {
- public RepositoryHookConfiguration(string contentType, string url)
- {
- ContentType = contentType;
- Url = url;
- }
-
- public string Url { get; private set; }
-
- public string ContentType { get; private set; }
-
- internal string DebuggerDisplay
- {
- get
- {
- return String.Format(CultureInfo.InvariantCulture,
- "Send {0} to {1}", ContentType, Url);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj
index 51e8f4d1..ec789bd7 100644
--- a/Octokit/Octokit-Mono.csproj
+++ b/Octokit/Octokit-Mono.csproj
@@ -125,7 +125,6 @@
-
@@ -387,12 +386,13 @@
-
+
+
\ No newline at end of file
diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj
index 465c74a5..99491bf6 100644
--- a/Octokit/Octokit-MonoAndroid.csproj
+++ b/Octokit/Octokit-MonoAndroid.csproj
@@ -405,6 +405,9 @@
+
+
+
\ No newline at end of file
diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj
index d56e8cbf..fde678d0 100644
--- a/Octokit/Octokit-Monotouch.csproj
+++ b/Octokit/Octokit-Monotouch.csproj
@@ -398,6 +398,9 @@
+
+
+
diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj
index f4b2069e..805f6d1f 100644
--- a/Octokit/Octokit-Portable.csproj
+++ b/Octokit/Octokit-Portable.csproj
@@ -212,7 +212,6 @@
-
@@ -385,12 +384,13 @@
-
+
+
diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj
index 0679e462..ec5fa401 100644
--- a/Octokit/Octokit-netcore45.csproj
+++ b/Octokit/Octokit-netcore45.csproj
@@ -216,7 +216,6 @@
-
@@ -275,7 +274,6 @@
-
@@ -395,6 +393,8 @@
+
+
@@ -403,11 +403,11 @@
-
-
\ No newline at end of file
+
diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj
index 28986fbc..465033ac 100644
--- a/Octokit/Octokit.csproj
+++ b/Octokit/Octokit.csproj
@@ -83,6 +83,7 @@
+
@@ -117,7 +118,6 @@
-
@@ -271,7 +271,7 @@
-
+