public Task <RepositoryInvitation> Edit(long repositoryId, int invitationId, InvitationUpdate permissions)
        {
            Ensure.ArgumentNotNull(permissions, nameof(permissions));

            return(ApiConnection.Patch <RepositoryInvitation>(ApiUrls.RepositoryInvitations(repositoryId, invitationId), permissions));
        }
        /// <summary>
        /// Updates a repository invitation.
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/repos/invitations/#update-a-repository-invitation">API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The id of the repository</param>
        /// <param name="invitationId">The id of the invitation</param>
        /// <param name="permissions">The permission for the collsborator</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        public Task <RepositoryInvitation> Edit(int repositoryId, int invitationId, InvitationUpdate permissions)
        {
            Ensure.ArgumentNotNull(permissions, "permissions");

            return(ApiConnection.Patch <RepositoryInvitation>(ApiUrls.RepositoryInvitations(repositoryId, invitationId), permissions, AcceptHeaders.InvitationsApiPreview));
        }
        /// <summary>
        /// Updates a repository invitation.
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/repos/invitations/#update-a-repository-invitation">API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The id of the repository</param>
        /// <param name="invitationId">The id of the invitation</param>
        /// <param name="permissions">The permission for the collsborator</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        public Task<RepositoryInvitation> Edit(int repositoryId, int invitationId, InvitationUpdate permissions)
        {
            Ensure.ArgumentNotNull(permissions, "permissions");

            return ApiConnection.Patch<RepositoryInvitation>(ApiUrls.RepositoryInvitations(repositoryId, invitationId), permissions, AcceptHeaders.InvitationsApiPreview);
        }
        public async Task CanUpdateInvitation()
        {
            var github = Helper.GetAuthenticatedClient();

            var repoName = Helper.MakeNameWithTimestamp("public-repo");

            using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
            {
                var fixture = github.Repository.Collaborator;
                var permission = new CollaboratorRequest(Permission.Push);

                // invite a collaborator
                var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);

                Assert.Equal(context.RepositoryOwner, response.Invitee.Login);
                Assert.Equal(InvitationPermissionType.Write, response.Permissions);

                var updatedInvitation = new InvitationUpdate(InvitationPermissionType.Admin);

                var update = await github.Repository.Invitation.Edit(response.Repository.Id, response.Id, updatedInvitation);

                Assert.Equal(updatedInvitation.Permissions, update.Permissions);
                Assert.Equal(response.Id, update.Id);
                Assert.Equal(response.Repository.Id, update.Repository.Id);
                Assert.Equal(response.Invitee.Login, update.Invitee.Login);
                Assert.Equal(response.Inviter.Login, update.Inviter.Login);
            }
        }
        public async Task RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new RepositoryInvitationsClient(connection);
            var updatedInvitation = new InvitationUpdate(InvitationPermissionType.Read);

            await client.Edit(1, 2, updatedInvitation);

            connection.Received().Patch<RepositoryInvitation>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/invitations/2"), Arg.Is<InvitationUpdate>(updatedInvitation), "application/vnd.github.swamp-thing-preview+json");
        }