Skip to content

Commit

Permalink
Implement checks API GetAll methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberboss committed May 15, 2018
1 parent 594cfba commit a1d3c7a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 34 deletions.
21 changes: 13 additions & 8 deletions Octokit/Clients/CheckRunsClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Octokit
Expand Down Expand Up @@ -102,42 +103,46 @@ public Task<IReadOnlyList<CheckRun>> GetAllForCheckSuite(long repositoryId, long
return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None);
}

public Task<IReadOnlyList<CheckRun>> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options)
public async Task<IReadOnlyList<CheckRun>> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
Ensure.ArgumentNotNull(options, nameof(options));

throw new NotImplementedException();
var results = await ApiConnection.GetAll<CheckRunList>(ApiUrls.ReferenceCheckRuns(owner, name, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false);
return results.SelectMany(x => x.CheckRuns).ToList();
}

public Task<IReadOnlyList<CheckRun>> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options)
public async Task<IReadOnlyList<CheckRun>> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
Ensure.ArgumentNotNull(options, nameof(options));

throw new NotImplementedException();
var results = await ApiConnection.GetAll<CheckRunList>(ApiUrls.ReferenceCheckRuns(repositoryId, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false);
return results.SelectMany(x => x.CheckRuns).ToList();
}

public Task<IReadOnlyList<CheckRun>> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options)
public async Task<IReadOnlyList<CheckRun>> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
Ensure.ArgumentNotNull(options, nameof(options));

throw new NotImplementedException();
var results = await ApiConnection.GetAll<CheckRunList>(ApiUrls.CheckSuiteRuns(owner, name, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false);
return results.SelectMany(x => x.CheckRuns).ToList();
}

public Task<IReadOnlyList<CheckRun>> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options)
public async Task<IReadOnlyList<CheckRun>> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options)
{
Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest));
Ensure.ArgumentNotNull(options, nameof(options));

throw new NotImplementedException();
var results = await ApiConnection.GetAll<CheckRunList>(ApiUrls.CheckSuiteRuns(repositoryId, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false);
return results.SelectMany(x => x.CheckRuns).ToList();
}

public Task<CheckRun> Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate)
Expand Down
33 changes: 9 additions & 24 deletions Octokit/Clients/CheckSuitesClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Octokit
Expand Down Expand Up @@ -44,14 +45,14 @@ public Task<IReadOnlyList<CheckSuite>> GetAllForReference(string owner, string n
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));

return GetAllForReference(owner, name, reference, ApiOptions.None);
return GetAllForReference(owner, name, reference, new CheckSuiteRequest(), ApiOptions.None);
}

public Task<IReadOnlyList<CheckSuite>> GetAllForReference(long repositoryId, string reference)
{
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));

return GetAllForReference(repositoryId, reference, ApiOptions.None);
return GetAllForReference(repositoryId, reference, new CheckSuiteRequest(), ApiOptions.None);
}

public Task<IReadOnlyList<CheckSuite>> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request)
Expand All @@ -71,42 +72,26 @@ public Task<IReadOnlyList<CheckSuite>> GetAllForReference(long repositoryId, str
return GetAllForReference(repositoryId, reference, request, ApiOptions.None);
}

public Task<IReadOnlyList<CheckSuite>> GetAllForReference(string owner, string name, string reference, ApiOptions request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
Ensure.ArgumentNotNull(request, nameof(request));

throw new System.NotImplementedException();
}

public Task<IReadOnlyList<CheckSuite>> GetAllForReference(long repositoryId, string reference, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
Ensure.ArgumentNotNull(options, nameof(options));

throw new System.NotImplementedException();
}

public Task<IReadOnlyList<CheckSuite>> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options)
public async Task<IReadOnlyList<CheckSuite>> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));

throw new System.NotImplementedException();
var results = await ApiConnection.GetAll<CheckSuiteList>(ApiUrls.ReferenceCheckSuites(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false);
return results.SelectMany(x => x.CheckSuites).ToList();
}

public Task<IReadOnlyList<CheckSuite>> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options)
public async Task<IReadOnlyList<CheckSuite>> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options)
{
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));

throw new System.NotImplementedException();
var results = await ApiConnection.GetAll<CheckSuiteList>(ApiUrls.ReferenceCheckSuites(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false);
return results.SelectMany(x => x.CheckSuites).ToList();
}

public Task<CheckSuite> Request(string owner, string name, CheckSuiteTriggerRequest request)
Expand Down
2 changes: 0 additions & 2 deletions Octokit/Clients/ICheckSuitesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public interface ICheckSuitesClient
Task<IReadOnlyList<CheckSuite>> GetAllForReference(long repositoryId, string reference);
Task<IReadOnlyList<CheckSuite>> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request);
Task<IReadOnlyList<CheckSuite>> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request);
Task<IReadOnlyList<CheckSuite>> GetAllForReference(string owner, string name, string reference, ApiOptions options);
Task<IReadOnlyList<CheckSuite>> GetAllForReference(long repositoryId, string reference, ApiOptions options);
Task<IReadOnlyList<CheckSuite>> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options);
Task<IReadOnlyList<CheckSuite>> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options);
Task<CheckSuitePreferences> UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences);
Expand Down
21 changes: 21 additions & 0 deletions Octokit/Models/Response/CheckRunList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;

namespace Octokit
{
public class CheckRunList
{
public CheckRunList()
{
}

public CheckRunList(int totalCount, IReadOnlyList<CheckRun> checkRuns)
{
TotalCount = totalCount;
CheckRuns = checkRuns;
}

public int TotalCount { get; protected set; }

public IReadOnlyList<CheckRun> CheckRuns { get; protected set; }
}
}
21 changes: 21 additions & 0 deletions Octokit/Models/Response/CheckSuiteList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;

namespace Octokit
{
public class CheckSuiteList
{
public CheckSuiteList()
{
}

public CheckSuiteList(int totalCount, IReadOnlyList<CheckSuite> checkSuites)
{
TotalCount = totalCount;
CheckSuites = checkSuites;
}

public int TotalCount { get; protected set; }

public IReadOnlyList<CheckSuite> CheckSuites { get; protected set; }
}
}

0 comments on commit a1d3c7a

Please sign in to comment.