Skip to content

Commit

Permalink
Adding observable client methods
Browse files Browse the repository at this point in the history
  • Loading branch information
StanleyGoldman committed Aug 7, 2018
1 parent e94b955 commit 1e5d95f
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Octokit.Reactive/Clients/IObservableGitHubAppsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,41 @@ public interface IObservableGitHubAppsClient
/// </remarks>
/// <param name="installationId">The Id of the GitHub App Installation</param>
IObservable<AccessToken> CreateInstallationToken(long installationId);

/// <summary>
/// List installations for user
/// </summary>
/// <remarks>https://developer.github.com/v3/apps/#list-installations-for-user</remarks>
IObservable<Installation> GetAllInstallationsForUser();

/// <summary>
/// List installations for user
/// </summary>
/// <remarks>https://developer.github.com/v3/apps/#list-installations-for-user</remarks>
IObservable<Installation> GetAllInstallationsForUser(ApiOptions options);

/// <summary>
/// Enables an authenticated GitHub App to find the organizations's installation information.
/// </summary>
/// <remarks>https://developer.github.com/v3/apps/#find-repository-installation</remarks>
/// <param name="owner">The owner of the repo</param>
/// <param name="repo">The name of the repo</param>
IObservable<Installation> GetRepositoryInstallation(string owner, string repo);

/// <summary>
/// Enables an authenticated GitHub App to find the repository's installation information.
/// </summary>
/// <remarks>https://developer.github.com/v3/apps/#find-organization-installation</remarks>
/// <param name="owner">The owner of the repo</param>
/// <param name="repo">The name of the repo</param>
IObservable<Installation> GetOrganizationInstallation(string organization);

/// <summary>
/// Enables an authenticated GitHub App to find the users's installation information.
/// </summary>
/// <remarks>https://developer.github.com/v3/apps/#find-user-installation</remarks>
/// <param name="owner">The owner of the repo</param>
/// <param name="repo">The name of the repo</param>
IObservable<Installation> GetUserInstallation(string user);
}
}
51 changes: 51 additions & 0 deletions Octokit.Reactive/Clients/ObservableGitHubAppsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,56 @@ public IObservable<AccessToken> CreateInstallationToken(long installationId)
{
return _client.CreateInstallationToken(installationId).ToObservable();
}

/// <summary>
/// List installations for user
/// </summary>
/// <remarks>https://developer.github.com/v3/apps/#list-installations-for-user</remarks>
public IObservable<Installation> GetAllInstallationsForUser()
{
return _connection.GetAndFlattenAllPages<Installation>(ApiUrls.UserInstallations(), null, AcceptHeaders.GitHubAppsPreview);
}

/// <summary>
/// List installations for user
/// </summary>
/// <remarks>https://developer.github.com/v3/apps/#list-installations-for-user</remarks>
public IObservable<Installation> GetAllInstallationsForUser(ApiOptions options)
{
return _connection.GetAndFlattenAllPages<Installation>(ApiUrls.UserInstallations(), null, AcceptHeaders.GitHubAppsPreview, options);
}

/// <summary>
/// Enables an authenticated GitHub App to find the organizations's installation information.
/// </summary>
/// <remarks>https://developer.github.com/v3/apps/#find-repository-installation</remarks>
/// <param name="owner">The owner of the repo</param>
/// <param name="repo">The name of the repo</param>
public IObservable<Installation> GetRepositoryInstallation(string owner, string repo)
{
return _client.GetRepositoryInstallation(owner, repo).ToObservable();
}

/// <summary>
/// Enables an authenticated GitHub App to find the repository's installation information.
/// </summary>
/// <remarks>https://developer.github.com/v3/apps/#find-organization-installation</remarks>
/// <param name="owner">The owner of the repo</param>
/// <param name="repo">The name of the repo</param>
public IObservable<Installation> GetOrganizationInstallation(string organization)
{
return _client.GetOrganizationInstallation(organization).ToObservable();
}

/// <summary>
/// Enables an authenticated GitHub App to find the users's installation information.
/// </summary>
/// <remarks>https://developer.github.com/v3/apps/#find-user-installation</remarks>
/// <param name="owner">The owner of the repo</param>
/// <param name="repo">The name of the repo</param>
public IObservable<Installation> GetUserInstallation(string user)
{
return _client.GetUserInstallation(user).ToObservable();
}
}
}

0 comments on commit 1e5d95f

Please sign in to comment.