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 void RequestsCorrectUrl() { var gitHub = Substitute.For <IGitHubClient>(); var client = new ObservableRepositoryInvitationsClient(gitHub); var update = new InvitationUpdate(InvitationPermissionType.Write); client.Edit(42, 43, update); gitHub.Received().Repository.Invitation.Edit(42, 43, update); }
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"); }
/// <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 invitatio.n</param> /// <param name="permissions">The permission to set.</param> public IObservable <RepositoryInvitation> Edit(long repositoryId, int invitationId, InvitationUpdate permissions) { Ensure.ArgumentNotNull(permissions, "persmissions"); return(_client.Edit(repositoryId, invitationId, permissions).ToObservable()); }
public void RequestsCorrectUrl() { var gitHub = Substitute.For<IGitHubClient>(); var client = new ObservableRepositoryInvitationsClient(gitHub); var update = new InvitationUpdate(InvitationPermissionType.Write); client.Edit(42, 43, update); gitHub.Received().Repository.Invitation.Edit(42, 43, update); }
public async Task <ActionResult <Invitation> > SetStatus([FromRoute] string id, [FromBody] InvitationUpdate invitationUpdate) { InvitationStatus invitationStatus = invitationUpdate.InvitationStatus; UserModel user = await userManager.GetUserAsync(HttpContext.User); Invitation invitation = await invitationService.GetById(id); if (invitation == null) { return(Status404NotFound("Invitation")); } if (!invitation.Involves(user.UserId)) { return(Status403Forbidden()); } return(invitation.InvitationType switch { InvitationType.SessionInvite => await UpdateSessionInviteStatus( user, invitation, invitationStatus ), InvitationType.FriendRequest => await UpdateFriendRequestStatus( user, invitation, invitationStatus ), _ => throw new ArgumentOutOfRangeException() });
/// <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 invitatio.n</param> /// <param name="permissions">The permission to set.</param> public IObservable<RepositoryInvitation> Edit(long repositoryId, int invitationId, InvitationUpdate permissions) { Ensure.ArgumentNotNull(permissions, "persmissions"); return _client.Edit(repositoryId, invitationId, permissions).ToObservable(); }