Skip to content

Commit

Permalink
Add endpoint to subscribe to the issue (#832)
Browse files Browse the repository at this point in the history
* Add endpoint to subscribe to the issue.

* Fix typo in the comment

* Apply PR comment - update methods summary

* Update summaries to full comments from the documentation.
  • Loading branch information
ivan-pavlik authored Jan 16, 2025
1 parent 4bebb6e commit 51c1f22
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions NGitLab.Mock/Clients/IssueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ public IEnumerable<Participant> GetParticipants(ProjectId projectId, long issueI
throw new NotImplementedException();
}

public Models.Issue Subscribe(ProjectId projectId, long issueIid)
{
throw new NotImplementedException();
}

public Models.Issue Unsubscribe(ProjectId projectId, long issueIid)
{
throw new NotImplementedException();
Expand Down
12 changes: 10 additions & 2 deletions NGitLab/IIssueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public interface IIssueClient
Task<Issue> GetByIdAsync(long issueId, CancellationToken cancellationToken = default);

/// <summary>
/// Add an issue witht he proposed title to the GitLab list for the selected proejct id.
/// Add an issue with the proposed title to the GitLab list for the selected project id.
/// </summary>
/// <param name="issueCreate"></param>
/// <returns>The issue if it was created. Null if not.</returns>
Expand Down Expand Up @@ -190,7 +190,15 @@ public interface IIssueClient
IEnumerable<Participant> GetParticipants(ProjectId projectId, long issueIid);

/// <summary>
/// Unsubscribe to the issue
/// Subscribes the authenticated user to an issue to receive notifications.
/// </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 Subscribe(ProjectId projectId, long issueIid);

/// <summary>
/// Unsubscribes the authenticated user from the issue to not receive notifications from it.
/// </summary>
/// <param name="projectId">The project id</param>
/// <param name="issueIid">The id of the issue in the project's scope.</param>
Expand Down
6 changes: 6 additions & 0 deletions NGitLab/Impl/IssueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class IssueClient : IIssueClient
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 SubscribeUrl = "/projects/{0}/issues/{1}/subscribe";
private const string UnsubscribeUrl = "/projects/{0}/issues/{1}/unsubscribe";

private readonly API _api;
Expand Down Expand Up @@ -199,6 +200,11 @@ public IEnumerable<Participant> GetParticipants(ProjectId projectId, long issueI
return _api.Get().GetAll<Participant>(string.Format(CultureInfo.InvariantCulture, ParticipantsUrl, projectId.ValueAsUriParameter(), issueIid));
}

public Issue Subscribe(ProjectId projectId, long issueIid)
{
return _api.Post().To<Issue>(string.Format(CultureInfo.InvariantCulture, SubscribeUrl, projectId.ValueAsUriParameter(), issueIid));
}

public Issue Unsubscribe(ProjectId projectId, long issueIid)
{
return _api.Post().To<Issue>(string.Format(CultureInfo.InvariantCulture, UnsubscribeUrl, projectId.ValueAsUriParameter(), issueIid));
Expand Down
2 changes: 2 additions & 0 deletions NGitLab/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ NGitLab.IIssueClient.ResourceMilestoneEventsAsync(long projectId, long issueIid)
NGitLab.IIssueClient.ResourceStateEvents(long projectId, long issueIid) -> System.Collections.Generic.IEnumerable<NGitLab.Models.ResourceStateEvent>
NGitLab.IIssueClient.ResourceStateEventsAsync(long projectId, long issueIid) -> NGitLab.GitLabCollectionResponse<NGitLab.Models.ResourceStateEvent>
NGitLab.IIssueClient.TimeStatsAsync(long projectId, long issueIid, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<NGitLab.Models.TimeStats>
NGitLab.IIssueClient.Subscribe(NGitLab.Models.ProjectId projectId, long issueIid) -> NGitLab.Models.Issue
NGitLab.IIssueClient.Unsubscribe(NGitLab.Models.ProjectId projectId, long issueIid) -> NGitLab.Models.Issue
NGitLab.IJobClient
NGitLab.IJobClient.Get(long jobId) -> NGitLab.Models.Job
Expand Down Expand Up @@ -617,6 +618,7 @@ NGitLab.Impl.IssueClient.ResourceMilestoneEventsAsync(long projectId, long issue
NGitLab.Impl.IssueClient.ResourceStateEvents(long projectId, long issueIid) -> System.Collections.Generic.IEnumerable<NGitLab.Models.ResourceStateEvent>
NGitLab.Impl.IssueClient.ResourceStateEventsAsync(long projectId, long issueIid) -> NGitLab.GitLabCollectionResponse<NGitLab.Models.ResourceStateEvent>
NGitLab.Impl.IssueClient.TimeStatsAsync(long projectId, long issueIid, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<NGitLab.Models.TimeStats>
NGitLab.Impl.IssueClient.Subscribe(NGitLab.Models.ProjectId projectId, long issueIid) -> NGitLab.Models.Issue
NGitLab.Impl.IssueClient.Unsubscribe(NGitLab.Models.ProjectId projectId, long issueIid) -> NGitLab.Models.Issue
NGitLab.Impl.JobClient
NGitLab.Impl.JobClient.Get(long jobId) -> NGitLab.Models.Job
Expand Down

0 comments on commit 51c1f22

Please sign in to comment.