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 public Task> GetPaths(long repositoryId) { return ApiConnection.GetAll(ApiUrls.RepositoryTrafficPaths(repositoryId), AcceptHeaders.RepositoryTrafficApiPreview); } /// /// 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 public Task> GetPaths(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); return ApiConnection.GetAll(ApiUrls.RepositoryTrafficPaths(owner, name), AcceptHeaders.RepositoryTrafficApiPreview); } /// /// List the top 10 referrers over the last 14 days /// /// https://developer.github.com/v3/repos/traffic/#list-referrers /// The owner of the repository public Task> GetReferrers(long repositoryId) { return ApiConnection.GetAll(ApiUrls.RepositoryTrafficReferrers(repositoryId), AcceptHeaders.RepositoryTrafficApiPreview); } /// /// 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 public Task> GetReferrers(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); return ApiConnection.GetAll(ApiUrls.RepositoryTrafficReferrers(owner, name), AcceptHeaders.RepositoryTrafficApiPreview); } /// /// 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 public Task GetClones(long repositoryId, RepositoryTrafficRequest per) { Ensure.ArgumentNotNull(per, "per"); return ApiConnection.Get(ApiUrls.RepositoryTrafficClones(repositoryId), per.ToParametersDictionary(), AcceptHeaders.RepositoryTrafficApiPreview); } /// /// 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 public Task GetClones(string owner, string name, RepositoryTrafficRequest per) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(per, "per"); return ApiConnection.Get(ApiUrls.RepositoryTrafficClones(owner, name), per.ToParametersDictionary(), AcceptHeaders.RepositoryTrafficApiPreview); } /// /// 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 public Task GetViews(long repositoryId, RepositoryTrafficRequest per) { Ensure.ArgumentNotNull(per, "per"); return ApiConnection.Get(ApiUrls.RepositoryTrafficViews(repositoryId), per.ToParametersDictionary(), AcceptHeaders.RepositoryTrafficApiPreview); } /// /// 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 public Task GetViews(string owner, string name, RepositoryTrafficRequest per) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(per, "per"); return ApiConnection.Get(ApiUrls.RepositoryTrafficViews(owner, name), per.ToParametersDictionary(), AcceptHeaders.RepositoryTrafficApiPreview); } } }