public static TeamMember ( int id, string login ) : Uri | ||
id | int | The team id |
login | string | The user login. |
Результат | Uri |
/// <summary> /// Adds a <see cref="User"/> to a <see cref="Team"/>. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/orgs/teams/#add-team-member">API documentation</a> for more information. /// </remarks> /// <param name="id">The team identifier.</param> /// <param name="login">The user to add to the team.</param> /// <exception cref="ApiValidationException">Thrown if you attempt to add an organization to a team.</exception> /// <returns>A <see cref="TeamMembership"/> result indicating the membership status</returns> public async Task <TeamMembership> AddMembership(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); var endpoint = ApiUrls.TeamMember(id, login); Dictionary <string, string> response; try { response = await ApiConnection.Put <Dictionary <string, string> >(endpoint, RequestBody.Empty); } catch (NotFoundException) { return(TeamMembership.NotFound); } if (response == null || !response.ContainsKey("state")) { return(TeamMembership.NotFound); } return(response["state"] == "active" ? TeamMembership.Active : TeamMembership.Pending); }
public Task <TeamMembershipDetails> GetMembershipDetails(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, nameof(login)); var endpoint = ApiUrls.TeamMember(id, login); return(ApiConnection.Get <TeamMembershipDetails>(endpoint)); }
/// <summary> /// Add a member to the team /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> public Task AddMember(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); var endpoint = ApiUrls.TeamMember(id, login); return(ApiConnection.Put(endpoint)); }
public Task <TeamMembershipDetails> AddOrEditMembership(int id, string login, UpdateTeamMembership request) { Ensure.ArgumentNotNullOrEmptyString(login, nameof(login)); Ensure.ArgumentNotNull(request, nameof(request)); var endpoint = ApiUrls.TeamMember(id, login); return(ApiConnection.Put <TeamMembershipDetails>(endpoint, request)); }
public async Task <bool> IsMember(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); var endpoint = ApiUrls.TeamMember(id, login); try { var response = await ApiConnection.Connection.GetResponse <string>(endpoint); return(response.HttpResponse.StatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Removes a <see cref="User"/> from a <see cref="Team"/>. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/orgs/teams/#remove-team-member">API documentation</a> for more information. /// </remarks> /// <param name="id">The team identifier.</param> /// <param name="login">The user to remove from the team.</param> /// <returns><see langword="true"/> if the user was removed from the team; <see langword="false"/> otherwise.</returns> public async Task <bool> RemoveMembership(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); var endpoint = ApiUrls.TeamMember(id, login); try { var httpStatusCode = await ApiConnection.Connection.Delete(endpoint); return(httpStatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Removes a <see cref="User"/> from a <see cref="Team"/>. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/orgs/teams/#remove-team-member">API documentation</a> for more information. /// </remarks> /// <param name="id">The team identifier.</param> /// <param name="login">The user to remove from the team.</param> /// <returns><see langword="true"/> if the user was removed from the team; <see langword="false"/> otherwise.</returns> public async Task <bool> RemoveMembership(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, nameof(login)); var endpoint = ApiUrls.TeamMember(id, login); try { var httpStatusCode = await ApiConnection.Connection.Delete(endpoint, null, AcceptHeaders.NestedTeamsPreview).ConfigureAwait(false); return(httpStatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Gets whether the user with the given <paramref name="login"/> /// is a member of the team with the given <paramref name="id"/>. /// </summary> /// <param name="id">The team to check.</param> /// <param name="login">The user to check.</param> /// <returns>A <see cref="TeamMembership"/> result indicating the membership status</returns> public async Task <TeamMembership> GetMembership(int id, string login) { var endpoint = ApiUrls.TeamMember(id, login); Dictionary <string, string> response; try { response = await ApiConnection.Get <Dictionary <string, string> >(endpoint); } catch (NotFoundException) { return(TeamMembership.NotFound); } return(response["state"] == "active" ? TeamMembership.Active : TeamMembership.Pending); }
/// <summary> /// Gets whether the user with the given <paramref name="login"/> /// is a member of the team with the given <paramref name="id"/>. /// </summary> /// <param name="id">The team to check.</param> /// <param name="login">The user to check.</param> /// <returns>A <see cref="TeamMembership"/> result indicating the membership status</returns> public async Task <TeamMembership> GetMembership(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); var endpoint = ApiUrls.TeamMember(id, login); Dictionary <string, string> response; try { response = await ApiConnection.Get <Dictionary <string, string> >(endpoint).ConfigureAwait(false); } catch (NotFoundException) { return(TeamMembership.NotFound); } return(response["state"] == "active" ? TeamMembership.Active : TeamMembership.Pending); }
/// <summary> /// Remove a member from the team /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> public Task RemoveMember(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); return(ApiConnection.Delete(ApiUrls.TeamMember(id, login))); }