Retry until call is successful

This is crude I know, but will be revisited once all apis implemented
This commit is contained in:
Amy Palamountain
2014-01-27 21:32:38 +13:00
parent 60fc710b73
commit 021ef3d534
+11 -3
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
namespace Octokit
@@ -19,13 +20,20 @@ namespace Octokit
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>A list of <see cref="Contributor"/></returns>
public Task<IEnumerable<Contributor>> GetContributors(string owner, string repositoryName)
public async Task<IEnumerable<Contributor>> GetContributors(string owner, string repositoryName)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
var endpoint = "/repos/{0}/{1}/stats/contributors".FormatUri(owner,repositoryName);
return ApiConnection.Get<IEnumerable<Contributor>>(endpoint);
var endpoint = "/repos/{0}/{1}/stats/contributors".FormatUri(owner, repositoryName);
var response = await Connection.GetAsync<IList<Contributor>>(endpoint, null, null);
if (response.StatusCode == HttpStatusCode.Accepted)
{
return await GetContributors(owner, repositoryName);
}
return response.BodyAsObject;
}
}
}