Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Participant and Unsubscribe functionnalities #726

Merged
merged 5 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions NGitLab.Mock/Clients/IssueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,14 @@ private IEnumerable<Issue> FilterByQuery(IEnumerable<Issue> issues, IssueQuery q

return issues;
}

public IEnumerable<Participant> GetParticipants(ProjectId projectId, int issueIid)
{
throw new NotImplementedException();
}

public Models.Issue Unsubscribe(ProjectId projectId, int issueIid)
{
throw new NotImplementedException();
}
}
16 changes: 16 additions & 0 deletions NGitLab/IIssueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,20 @@ public interface IIssueClient
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<Issue> CloneAsync(int projectId, int issueIid, IssueClone issueClone, CancellationToken cancellationToken = default);

/// <summary>
/// Get Participants
/// </summary>
/// <param name="projectId">The project id</param>
/// <param name="issueIid">The id of the issue in the project's scope.</param>
/// <returns>The participants of the issue.</returns>
IEnumerable<Participant> GetParticipants(ProjectId projectId, int issueIid);

/// <summary>
/// Unsubscribe to the issue
/// </summary>
/// <param name="projectId">The project id</param>
/// <param name="issueIid">The id of the issue in the project's scope.</param>
/// <returns>The issue that corresponds to the project id and issue id</returns>
Issue Unsubscribe(ProjectId projectId, int issueIid);
}
12 changes: 12 additions & 0 deletions NGitLab/Impl/IssueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class IssueClient : IIssueClient
private const string ClosedByUrl = "/projects/{0}/issues/{1}/closed_by";
private const string TimeStatsUrl = "/projects/{0}/issues/{1}/time_stats";
private const string CloneIssueUrl = "/projects/{0}/issues/{1}/clone";
private const string ParticipantsUrl = "/projects/{0}/issues/{1}/participants";
private const string UnsubscribeUrl = "/projects/{0}/issues/{1}/unsubscribe";

private readonly API _api;

Expand Down Expand Up @@ -192,6 +194,16 @@ public Task<Issue> CloneAsync(int projectId, int issueIid, IssueClone issueClone
return _api.Post().With(issueClone).ToAsync<Issue>(string.Format(CultureInfo.InvariantCulture, CloneIssueUrl, projectId, issueIid), cancellationToken);
}

public IEnumerable<Participant> GetParticipants(ProjectId projectId, int issueIid)
{
return _api.Get().GetAll<Participant>(string.Format(CultureInfo.InvariantCulture, ParticipantsUrl, projectId.ValueAsUriParameter(), issueIid));
}

public Issue Unsubscribe(ProjectId projectId, int issueIid)
{
return _api.Post().To<Issue>(string.Format(CultureInfo.InvariantCulture, UnsubscribeUrl, projectId.ValueAsUriParameter(), issueIid));
}

private GitLabCollectionResponse<Issue> Get(string url, IssueQuery query)
{
url = AddIssueQueryParameters(url, query);
Expand Down
24 changes: 24 additions & 0 deletions NGitLab/Models/Participant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Text.Json.Serialization;

namespace NGitLab.Models;

public class Participant
{
[JsonPropertyName("id")]
public int Id { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("username")]
public string Username { get; set; }

[JsonPropertyName("state")]
public string State { get; set; }

[JsonPropertyName("avatar_url")]
public string AvatarURL { get; set; }

[JsonPropertyName("web_url")]
public string WebUrl { get; set; }
}
18 changes: 18 additions & 0 deletions NGitLab/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ NGitLab.IIssueClient.GetAsync(int projectId, NGitLab.Models.IssueQuery query) ->
NGitLab.IIssueClient.GetAsync(NGitLab.Models.IssueQuery query) -> NGitLab.GitLabCollectionResponse<NGitLab.Models.Issue>
NGitLab.IIssueClient.GetById(int issueId) -> NGitLab.Models.Issue
NGitLab.IIssueClient.GetByIdAsync(int issueId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<NGitLab.Models.Issue>
NGitLab.IIssueClient.GetParticipants(NGitLab.Models.ProjectId projectId, int issueIid) -> System.Collections.Generic.IEnumerable<NGitLab.Models.Participant>
NGitLab.IIssueClient.LinkedToAsync(int projectId, int issueId) -> NGitLab.GitLabCollectionResponse<NGitLab.Models.Issue>
NGitLab.IIssueClient.Owned.get -> System.Collections.Generic.IEnumerable<NGitLab.Models.Issue>
NGitLab.IIssueClient.RelatedTo(int projectId, int issueIid) -> System.Collections.Generic.IEnumerable<NGitLab.Models.MergeRequest>
Expand All @@ -358,6 +359,7 @@ NGitLab.IIssueClient.ResourceMilestoneEventsAsync(int projectId, int issueIid) -
NGitLab.IIssueClient.ResourceStateEvents(int projectId, int issueIid) -> System.Collections.Generic.IEnumerable<NGitLab.Models.ResourceStateEvent>
NGitLab.IIssueClient.ResourceStateEventsAsync(int projectId, int issueIid) -> NGitLab.GitLabCollectionResponse<NGitLab.Models.ResourceStateEvent>
NGitLab.IIssueClient.TimeStatsAsync(int projectId, int issueIid, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<NGitLab.Models.TimeStats>
NGitLab.IIssueClient.Unsubscribe(NGitLab.Models.ProjectId projectId, int issueIid) -> NGitLab.Models.Issue
NGitLab.IJobClient
NGitLab.IJobClient.Get(int jobId) -> NGitLab.Models.Job
NGitLab.IJobClient.GetAsync(int jobId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<NGitLab.Models.Job>
Expand Down Expand Up @@ -640,6 +642,7 @@ NGitLab.Impl.IssueClient.GetAsync(int projectId, NGitLab.Models.IssueQuery query
NGitLab.Impl.IssueClient.GetAsync(NGitLab.Models.IssueQuery query) -> NGitLab.GitLabCollectionResponse<NGitLab.Models.Issue>
NGitLab.Impl.IssueClient.GetById(int issueId) -> NGitLab.Models.Issue
NGitLab.Impl.IssueClient.GetByIdAsync(int issueId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<NGitLab.Models.Issue>
NGitLab.Impl.IssueClient.GetParticipants(NGitLab.Models.ProjectId projectId, int issueIid) -> System.Collections.Generic.IEnumerable<NGitLab.Models.Participant>
NGitLab.Impl.IssueClient.IssueClient(NGitLab.Impl.API api) -> void
NGitLab.Impl.IssueClient.LinkedToAsync(int projectId, int issueId) -> NGitLab.GitLabCollectionResponse<NGitLab.Models.Issue>
NGitLab.Impl.IssueClient.Owned.get -> System.Collections.Generic.IEnumerable<NGitLab.Models.Issue>
Expand All @@ -652,6 +655,7 @@ NGitLab.Impl.IssueClient.ResourceMilestoneEventsAsync(int projectId, int issueIi
NGitLab.Impl.IssueClient.ResourceStateEvents(int projectId, int issueIid) -> System.Collections.Generic.IEnumerable<NGitLab.Models.ResourceStateEvent>
NGitLab.Impl.IssueClient.ResourceStateEventsAsync(int projectId, int issueIid) -> NGitLab.GitLabCollectionResponse<NGitLab.Models.ResourceStateEvent>
NGitLab.Impl.IssueClient.TimeStatsAsync(int projectId, int issueIid, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<NGitLab.Models.TimeStats>
NGitLab.Impl.IssueClient.Unsubscribe(NGitLab.Models.ProjectId projectId, int issueIid) -> NGitLab.Models.Issue
NGitLab.Impl.JobClient
NGitLab.Impl.JobClient.Get(int jobId) -> NGitLab.Models.Job
NGitLab.Impl.JobClient.GetAsync(int jobId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<NGitLab.Models.Job>
Expand Down Expand Up @@ -2750,6 +2754,20 @@ NGitLab.Models.PageQuery<TQueryType>
NGitLab.Models.PageQuery<TQueryType>.PageQuery(int page = 1, int perPage = 20, TQueryType query = default(TQueryType)) -> void
NGitLab.Models.PageQuery<TQueryType>.Query.get -> TQueryType
NGitLab.Models.PageQuery<TQueryType>.Query.set -> void
NGitLab.Models.Participant
NGitLab.Models.Participant.Participant() -> void
NGitLab.Models.Participant.Id.get -> int
NGitLab.Models.Participant.Id.set -> void
NGitLab.Models.Participant.AvatarURL.get -> string
NGitLab.Models.Participant.AvatarURL.set -> void
NGitLab.Models.Participant.Name.get -> string
NGitLab.Models.Participant.Name.set -> void
NGitLab.Models.Participant.State.get -> string
NGitLab.Models.Participant.State.set -> void
NGitLab.Models.Participant.Username.get -> string
NGitLab.Models.Participant.Username.set -> void
NGitLab.Models.Participant.WebUrl.get -> string
NGitLab.Models.Participant.WebUrl.set -> void
NGitLab.Models.PersonInfo
NGitLab.Models.PersonInfo.Email -> string
NGitLab.Models.PersonInfo.Name -> string
Expand Down
Loading