-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add active lock reason to PR (#2543)
* add active lock reason to PR * update docs * refactor: extract lock and unlock from IIssuesClient create ILockUnlockClient so both IIssuesClient and IPullRequestClient can access lock and unlock methods. * refactor LockUnlock for reactive clients * Update doc to include lock unlock sample code * Use Assert.Null to check null value in test Co-authored-by: notauserx <[email protected]>
- Loading branch information
Showing
20 changed files
with
405 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Reactive; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
/// <summary> | ||
/// Client to manage locking/unlocking a conversation for an Issue or a Pull request | ||
/// </summary> | ||
public interface IObservableLockUnlockClient | ||
{ | ||
/// <summary> | ||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The issue number</param> | ||
/// <param name="lockReason">The reason for locking the issue</param> | ||
IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null); | ||
|
||
/// <summary> | ||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The issue number</param> | ||
/// <param name="lockReason">The reason for locking the issue</param> | ||
IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null); | ||
|
||
/// <summary> | ||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The issue number</param> | ||
IObservable<Unit> Unlock(string owner, string name, int number); | ||
|
||
/// <summary> | ||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The issue number</param> | ||
IObservable<Unit> Unlock(long repositoryId, int number); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using System.Reactive; | ||
using System.Reactive.Threading.Tasks; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
/// <summary> | ||
/// Client to manage locking/unlocking a conversation for an Issue or a Pull request | ||
/// </summary> | ||
public class ObservableLockUnlockClient : IObservableLockUnlockClient | ||
{ | ||
readonly ILockUnlockClient _client; | ||
|
||
public ObservableLockUnlockClient(IGitHubClient client) | ||
{ | ||
Ensure.ArgumentNotNull(client, nameof(client)); | ||
|
||
_client = client.Issue.LockUnlock; | ||
} | ||
|
||
/// <summary> | ||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The issue number</param> | ||
/// <param name="lockReason">The reason for locking the issue</param> | ||
public IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); | ||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); | ||
|
||
return _client.Lock(owner, name, number, lockReason).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The issue number</param> | ||
/// <param name="lockReason">The reason for locking the issue</param> | ||
public IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null) | ||
{ | ||
return _client.Lock(repositoryId, number, lockReason).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The issue number</param> | ||
public IObservable<Unit> Unlock(string owner, string name, int number) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); | ||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); | ||
|
||
return _client.Unlock(owner, name, number).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The issue number</param> | ||
public IObservable<Unit> Unlock(long repositoryId, int number) | ||
{ | ||
return _client.Unlock(repositoryId, number).ToObservable(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.