using Octokit.Reactive.Internal;
using System;
using System.Reactive.Threading.Tasks;
using System.Collections.Generic;
namespace Octokit.Reactive
{
public class ObservableProjectColumnsClient : IObservableProjectColumnsClient
{
readonly IProjectColumnsClient _client;
readonly IConnection _connection;
public ObservableProjectColumnsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));
_client = client.Repository.Project.Column;
_connection = client.Connection;
}
///
/// Gets all columns for this project.
///
///
/// See the API documentation for more information.
///
/// The Id of the project
public IObservable GetAll(int projectId)
{
return GetAll(projectId, ApiOptions.None);
}
///
/// Gets all columns for this project.
///
///
/// See the API documentation for more information.
///
/// The Id of the project
/// Options for changing the API response
public IObservable GetAll(int projectId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
var url = ApiUrls.ProjectColumns(projectId);
return _connection.GetAndFlattenAllPages(url, new Dictionary(), options);
}
///
/// Gets a single column for this project.
///
///
/// See the API documentation for more information.
///
/// The id of the column
public IObservable Get(int columnId)
{
return _client.Get(columnId).ToObservable();
}
///
/// Creates a column for this project.
///
///
/// See the API documentation for more information.
///
/// The id of the project
/// The column to create
public IObservable Create(int projectId, NewProjectColumn newProjectColumn)
{
Ensure.ArgumentNotNull(newProjectColumn, nameof(newProjectColumn));
return _client.Create(projectId, newProjectColumn).ToObservable();
}
///
/// Updates a column for this project.
///
///
/// See the API documentation for more information.
///
/// The id of the column
/// New values to update the column with
public IObservable Update(int columnId, ProjectColumnUpdate projectColumnUpdate)
{
Ensure.ArgumentNotNull(projectColumnUpdate, nameof(projectColumnUpdate));
return _client.Update(columnId, projectColumnUpdate).ToObservable();
}
///
/// Deletes a column.
///
///
/// See the API documentation for more information.
///
/// The id of the column
public IObservable Delete(int columnId)
{
return _client.Delete(columnId).ToObservable();
}
///
/// Moves a column.
///
///
/// See the API documentation for more information.
///
/// The id of the column
/// The position to move the column
public IObservable Move(int columnId, ProjectColumnMove position)
{
Ensure.ArgumentNotNull(position, nameof(position));
return _client.Move(columnId, position).ToObservable();
}
}
}