public async Task <bool> Decline(int invitationId) { var endpoint = ApiUrls.UserInvitations(invitationId); try { var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return(httpStatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Accept a repository invitation. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation">API documentation</a> for more information. /// </remarks> /// <param name="invitationId">The id of the invitation</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public async Task <bool> Accept(int invitationId) { var endpoint = ApiUrls.UserInvitations(invitationId); try { var httpStatusCode = await Connection.Patch(endpoint, AcceptHeaders.InvitationsApiPreview).ConfigureAwait(false); return(httpStatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
public Task <IReadOnlyList <RepositoryInvitation> > GetAllForCurrent(ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); return(ApiConnection.GetAll <RepositoryInvitation>(ApiUrls.UserInvitations(), options)); }
/// <summary> /// Gets all invitations for the current user. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations">API documentation</a> for more information. /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public Task <IReadOnlyList <RepositoryInvitation> > GetAllForCurrent() { return(ApiConnection.GetAll <RepositoryInvitation>(ApiUrls.UserInvitations(), AcceptHeaders.InvitationsApiPreview)); }
/// <summary> /// Gets all invitations for the current user. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations">API documentation</a> for more information. /// </remarks> /// <param name="options">Options for changing the API response</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public Task <IReadOnlyList <RepositoryInvitation> > GetAllForCurrent(ApiOptions options) { Ensure.ArgumentNotNull(options, "options"); return(ApiConnection.GetAll <RepositoryInvitation>(ApiUrls.UserInvitations(), null, AcceptHeaders.InvitationsApiPreview, options)); }