Skip to content

Commit

Permalink
Add ApiOptions overloads to repository invitations.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdziadkiewicz committed Oct 18, 2017
1 parent 0f0a0dc commit 7e4112c
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 4 deletions.
20 changes: 20 additions & 0 deletions Octokit.Reactive/Clients/IObservableRepositoryInvitationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ public interface IObservableRepositoryInvitationsClient
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
IObservable<RepositoryInvitation> GetAllForCurrent();

/// <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>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
IObservable<RepositoryInvitation> GetAllForCurrent(ApiOptions options);

/// <summary>
/// Gets all the invitations on a repository.
/// </summary>
Expand All @@ -52,6 +62,16 @@ public interface IObservableRepositoryInvitationsClient
/// <param name="repositoryId">The id of the repository</param>
IObservable<RepositoryInvitation> GetAllForRepository(long repositoryId);

/// <summary>
/// Gets all the invitations on a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// /// <param name="options">Options for changing the API response</param>
IObservable<RepositoryInvitation> GetAllForRepository(long repositoryId, ApiOptions options);

/// <summary>
/// Updates a repository invitation.
/// </summary>
Expand Down
29 changes: 27 additions & 2 deletions Octokit.Reactive/Clients/ObservableRepositoryInvitationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,19 @@ public IObservable<RepositoryInvitation> Edit(long repositoryId, int invitationI
/// </remarks>
public IObservable<RepositoryInvitation> GetAllForCurrent()
{
return _connection.GetAndFlattenAllPages<RepositoryInvitation>(ApiUrls.UserInvitations(), null, AcceptHeaders.InvitationsApiPreview, ApiOptions.None);
return GetAllForCurrent(ApiOptions.None);
}

/// <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>
public IObservable<RepositoryInvitation> GetAllForCurrent(ApiOptions options)
{
return _connection.GetAndFlattenAllPages<RepositoryInvitation>(ApiUrls.UserInvitations(), null, AcceptHeaders.InvitationsApiPreview, options);
}

/// <summary>
Expand All @@ -92,7 +104,20 @@ public IObservable<RepositoryInvitation> GetAllForCurrent()
/// <param name="repositoryId">The id of the repository</param>
public IObservable<RepositoryInvitation> GetAllForRepository(long repositoryId)
{
return _connection.GetAndFlattenAllPages<RepositoryInvitation>(ApiUrls.RepositoryInvitations(repositoryId), null, AcceptHeaders.InvitationsApiPreview, ApiOptions.None);
return GetAllForRepository(repositoryId, ApiOptions.None);
}

/// <summary>
/// Gets all the invitations on a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RepositoryInvitation> GetAllForRepository(long repositoryId, ApiOptions options)
{
return _connection.GetAndFlattenAllPages<RepositoryInvitation>(ApiUrls.RepositoryInvitations(repositoryId), null, AcceptHeaders.InvitationsApiPreview, options);
}
}
}
22 changes: 22 additions & 0 deletions Octokit/Clients/IRepositoryInvitationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ public interface IRepositoryInvitationsClient
[ExcludeFromPaginationApiOptionsConventionTest("TODO: Implement pagination for this method")]
Task<IReadOnlyList<RepositoryInvitation>> GetAllForCurrent();

/// <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>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
Task<IReadOnlyList<RepositoryInvitation>> GetAllForCurrent(ApiOptions options);

/// <summary>
/// Gets all the invitations on a repository.
/// </summary>
Expand All @@ -65,6 +76,17 @@ public interface IRepositoryInvitationsClient
[ExcludeFromPaginationApiOptionsConventionTest("TODO: Implement pagination for this method")]
Task<IReadOnlyList<RepositoryInvitation>> GetAllForRepository(long repositoryId);

/// <summary>
/// Gets all the invitations on a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<IReadOnlyList<RepositoryInvitation>> GetAllForRepository(long repositoryId, ApiOptions options);

/// <summary>
/// Updates a repository invitation.
/// </summary>
Expand Down
31 changes: 29 additions & 2 deletions Octokit/Clients/RepositoryInvitationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,20 @@ public async Task<bool> Delete(long repositoryId, int invitationId)
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public Task<IReadOnlyList<RepositoryInvitation>> GetAllForCurrent()
{
return ApiConnection.GetAll<RepositoryInvitation>(ApiUrls.UserInvitations(), AcceptHeaders.InvitationsApiPreview);
return GetAllForCurrent(ApiOptions.None);
}

/// <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)
{
return ApiConnection.GetAll<RepositoryInvitation>(ApiUrls.UserInvitations(), null, AcceptHeaders.InvitationsApiPreview, options);
}

/// <summary>
Expand All @@ -104,7 +117,21 @@ public Task<IReadOnlyList<RepositoryInvitation>> GetAllForCurrent()
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public Task<IReadOnlyList<RepositoryInvitation>> GetAllForRepository(long repositoryId)
{
return ApiConnection.GetAll<RepositoryInvitation>(ApiUrls.RepositoryInvitations(repositoryId), AcceptHeaders.InvitationsApiPreview);
return GetAllForRepository(repositoryId, ApiOptions.None);
}

/// <summary>
/// Gets all the invitations on a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <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>> GetAllForRepository(long repositoryId, ApiOptions options)
{
return ApiConnection.GetAll<RepositoryInvitation>(ApiUrls.RepositoryInvitations(repositoryId), null, AcceptHeaders.InvitationsApiPreview, options);
}

/// <summary>
Expand Down

0 comments on commit 7e4112c

Please sign in to comment.