/// <summary>
        /// Edits a hook for a repository
        /// </summary>
        /// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks>
        /// <returns></returns>
        public IObservable<RepositoryHook> Edit(string owner, string repositoryName, int hookId, EditRepositoryHook hook)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
            Ensure.ArgumentNotNull(hook, "hook");

            return _client.Edit(owner, repositoryName, hookId, hook).ToObservable();
        }
        /// <summary>
        /// Disables a hook for a repository
        /// </summary>
        /// <param name="hookId">The repository's hook id</param>
        /// <returns></returns>
        public async Task <RepositoryHook> DisableRepositoryHookAsync(int hookId)
        {
            var hook = new EditRepositoryHook
            {
                Active = false
            };

            return(await _githubClient.Repository.Hooks.Edit(_owner, _name, hookId, hook));
        }
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoriesClient(connection);
                var hook       = new EditRepositoryHook();

                client.Hooks.Edit("fake", "repo", 12345678, hook);

                connection.Received().Patch <RepositoryHook>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/hooks/12345678"), hook);
            }
Example #4
0
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryHooksClient(gitHubClient);

                var hook = new EditRepositoryHook();

                client.Edit(1, 12345678, hook);

                gitHubClient.Received().Repository.Hooks.Edit(1, 12345678, hook);
            }
            public void UsesTheSuppliedHook()
            {
                var connection         = Substitute.For <IApiConnection>();
                var client             = new RepositoriesClient(connection);
                var editRepositoryHook = new EditRepositoryHook {
                    Active = false
                };

                client.Hooks.Edit("owner", "repo", 12345678, editRepositoryHook);

                connection.Received().Patch <RepositoryHook>(Arg.Any <Uri>(), editRepositoryHook);
            }
            public async Task EditHookWithNoNewConfigRetainsTheOldConfig()
            {
                var github = Helper.GetAuthenticatedClient();

                var editRepositoryHook = new EditRepositoryHook
                {
                    AddEvents = new[] { "pull_request" }
                };

                var actualHook = await github.Repository.Hooks.Edit(_fixture.RepositoryOwner, _fixture.RepositoryName, _fixture.ExpectedHook.Id, editRepositoryHook);

                var expectedConfig = new Dictionary <string, string> {
                    { "content_type", "json" }, { "url", "http://test.com/example" }
                };

                Assert.Equal(new[] { "deployment", "pull_request" }.ToList(), actualHook.Events.ToList());
                Assert.Equal(expectedConfig.Keys, actualHook.Config.Keys);
                Assert.Equal(expectedConfig.Values, actualHook.Config.Values);
            }
            public async Task EditHookWithNewInformation()
            {
                var github = Helper.GetAuthenticatedClient();

                var editRepositoryHook = new EditRepositoryHook(new Dictionary <string, string> {
                    { "project", "GEZDGORQFY2TCNZRGY2TSMBVGUYDK" }
                })
                {
                    AddEvents = new[] { "pull_request" }
                };

                var actualHook = await github.Repository.Hooks.Edit(_fixture.RepositoryOwner, _fixture.RepositoryName, _fixture.ExpectedHook.Id, editRepositoryHook);

                var expectedConfig = new Dictionary <string, string> {
                    { "project", "GEZDGORQFY2TCNZRGY2TSMBVGUYDK" }
                };

                Assert.Equal(new[] { "deployment", "pull_request" }.ToList(), actualHook.Events.ToList());
                Assert.Equal(expectedConfig.Keys, actualHook.Config.Keys);
                Assert.Equal(expectedConfig.Values, actualHook.Config.Values);
            }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryHooksClient(connection);

                var hook = new EditRepositoryHook();

                client.Edit(1, 12345678, hook);

                connection.Received().Patch<RepositoryHook>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/hooks/12345678"), hook);
            }
            public async Task EditHookWithNewInformationWithRepositoryId()
            {
                var github = Helper.GetAuthenticatedClient();

                var editRepositoryHook = new EditRepositoryHook(new Dictionary<string, string> { { "project", "GEZDGORQFY2TCNZRGY2TSMBVGUYDK" } })
                {
                    AddEvents = new[] { "pull_request" }
                };

                var actualHook = await github.Repository.Hooks.Edit(_fixture.RepositoryId, _fixture.ExpectedHooks[3].Id, editRepositoryHook);

                var expectedConfig = new Dictionary<string, string> { { "project", "GEZDGORQFY2TCNZRGY2TSMBVGUYDK" } };
                Assert.Equal(new[] { "deployment", "pull_request" }.ToList(), actualHook.Events.ToList());
                Assert.Equal(expectedConfig.Keys, actualHook.Config.Keys);
                Assert.Equal(expectedConfig.Values, actualHook.Config.Values);
            }
            public async Task EditHookWithNoNewConfigRetainsTheOldConfigWithRepositoryId()
            {
                var github = Helper.GetAuthenticatedClient();

                var editRepositoryHook = new EditRepositoryHook
                {
                    AddEvents = new[] { "pull_request" }
                };

                var actualHook = await github.Repository.Hooks.Edit(_fixture.RepositoryId, _fixture.ExpectedHooks[1].Id, editRepositoryHook);

                var expectedConfig = new Dictionary<string, string> { { "content_type", "json" }, { "url", "http://test.com/example" } };
                Assert.Equal(new[] { "deployment", "pull_request" }.ToList(), actualHook.Events.ToList());
                Assert.Equal(expectedConfig.Keys, actualHook.Config.Keys);
                Assert.Equal(expectedConfig.Values, actualHook.Config.Values);
            }
            public void UsesTheSuppliedHook()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);
                var editRepositoryHook = new EditRepositoryHook() { Active = false };

                client.Hooks.Edit("owner", "repo", 12345678, editRepositoryHook);

                connection.Received().Patch<RepositoryHook>(Arg.Any<Uri>(), editRepositoryHook);
            }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryHooksClient(gitHubClient);

                var hook = new EditRepositoryHook();

                client.Edit(1, 12345678, hook);

                gitHubClient.Received().Repository.Hooks.Edit(1, 12345678, hook);
            }
Example #13
0
        /// <summary>
        /// Edits a hook for a repository
        /// </summary>
        /// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks>
        /// <returns></returns>
        public IObservable <RepositoryHook> Edit(string owner, string repositoryName, int hookId, EditRepositoryHook hook)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
            Ensure.ArgumentNotNull(hook, "hook");

            return(_client.Edit(owner, repositoryName, hookId, hook).ToObservable());
        }
        /// <summary>
        /// Edits a hook for a repository
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="hookId">The repository's hook id</param>
        /// <param name="hook">The requested changes to an edit repository hook</param>
        /// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks>
        public IObservable<RepositoryHook> Edit(long repositoryId, int hookId, EditRepositoryHook hook)
        {
            Ensure.ArgumentNotNull(hook, "hook");

            return _client.Edit(repositoryId, hookId, hook).ToObservable();
        }
        /// <summary>
        /// Edits a hook for a repository
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="hookId">The repository's hook id</param>
        /// <param name="hook">The requested changes to an edit repository hook</param>
        /// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks>
        public IObservable <RepositoryHook> Edit(long repositoryId, int hookId, EditRepositoryHook hook)
        {
            Ensure.ArgumentNotNull(hook, "hook");

            return(_client.Edit(repositoryId, hookId, hook).ToObservable());
        }
        /// <summary>
        /// Edits a hook for a repository
        /// </summary>
        /// <param name="owner">The repository's owner</param>
        /// <param name="name">The repository's name</param>
        /// <param name="hookId">The repository's hook id</param>
        /// <param name="hook">The requested changes to an edit repository hook</param>
        /// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks>
        public IObservable <RepositoryHook> Edit(string owner, string name, int hookId, EditRepositoryHook hook)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
            Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
            Ensure.ArgumentNotNull(hook, nameof(hook));

            return(_client.Edit(owner, name, hookId, hook).ToObservable());
        }