using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Octokit
{
public class RepositoryTrafficClient : ApiClient, IRepositoryTrafficClient
{
public RepositoryTrafficClient(IApiConnection apiConnection) : base(apiConnection)
{
}
///
/// List the top 10 popular contents over the last 14 days
///
/// https://developer.github.com/v3/repos/traffic/#list-paths
/// The owner of the repository
[ManualRoute("GET", "/repositories/{id}/traffic/popular/paths")]
public Task> GetAllPaths(long repositoryId)
{
return ApiConnection.GetAll(ApiUrls.RepositoryTrafficPaths(repositoryId));
}
///
/// List the top 10 popular contents over the last 14 days
///
/// https://developer.github.com/v3/repos/traffic/#list-paths
/// The owner of the repository
/// The name of the repository
[ManualRoute("GET", "/repos/{owner}/{repo}/traffic/popular/paths")]
public Task> GetAllPaths(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return ApiConnection.GetAll(ApiUrls.RepositoryTrafficPaths(owner, name));
}
///
/// List the top 10 referrers over the last 14 days
///
/// https://developer.github.com/v3/repos/traffic/#list-referrers
/// The owner of the repository
[ManualRoute("GET", "/repositories/{id}/traffic/popular/referrers")]
public Task> GetAllReferrers(long repositoryId)
{
return ApiConnection.GetAll(ApiUrls.RepositoryTrafficReferrers(repositoryId));
}
///
/// List the top 10 referrers over the last 14 days
///
/// https://developer.github.com/v3/repos/traffic/#list-referrers
/// The owner of the repository
/// The name of the repository
[ManualRoute("GET", "/repos/{owner}/{repo}/traffic/popular/referrers")]
public Task> GetAllReferrers(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return ApiConnection.GetAll(ApiUrls.RepositoryTrafficReferrers(owner, name));
}
///
/// Get the total number of clones and breakdown per day or week for the last 14 days
///
/// https://developer.github.com/v3/repos/traffic/#clones
/// The owner of the repository
/// Breakdown per day or week
[ManualRoute("GET", "/repositories/{id}/traffic/clones")]
public Task GetClones(long repositoryId, RepositoryTrafficRequest per)
{
Ensure.ArgumentNotNull(per, nameof(per));
return ApiConnection.Get(ApiUrls.RepositoryTrafficClones(repositoryId), per.ToParametersDictionary());
}
///
/// Get the total number of clones and breakdown per day or week for the last 14 days
///
/// https://developer.github.com/v3/repos/traffic/#clones
/// The owner of the repository
/// The name of the repository
/// Breakdown per day or week
[ManualRoute("GET", "/repos/{owner}/{repo}/traffic/clones")]
public Task GetClones(string owner, string name, RepositoryTrafficRequest per)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(per, nameof(per));
return ApiConnection.Get(ApiUrls.RepositoryTrafficClones(owner, name), per.ToParametersDictionary());
}
///
/// Get the total number of views and breakdown per day or week for the last 14 days
///
/// https://developer.github.com/v3/repos/traffic/#views
/// The owner of the repository
/// Breakdown per day or week
[ManualRoute("GET", "/repositories/{id}/traffic/views")]
public Task GetViews(long repositoryId, RepositoryTrafficRequest per)
{
Ensure.ArgumentNotNull(per, nameof(per));
return ApiConnection.Get(ApiUrls.RepositoryTrafficViews(repositoryId), per.ToParametersDictionary());
}
///
/// Get the total number of views and breakdown per day or week for the last 14 days
///
/// https://developer.github.com/v3/repos/traffic/#views
/// The owner of the repository
/// The name of the repository
/// Breakdown per day or week
[ManualRoute("GET", "/repos/{owner}/{repo}/traffic/views")]
public Task GetViews(string owner, string name, RepositoryTrafficRequest per)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(per, nameof(per));
return ApiConnection.Get(ApiUrls.RepositoryTrafficViews(owner, name), per.ToParametersDictionary());
}
}
}