From d924684cc1b3672c825f06edcff2deab8cf75c57 Mon Sep 17 00:00:00 2001 From: pltaylor Date: Mon, 4 Nov 2013 21:13:37 -0500 Subject: [PATCH] Working away adding methods --- Octokit/Clients/ActivitiesClient.cs | 53 ++++++++++++++++++++++++++++- Octokit/Helpers/ApiUrls.cs | 16 +++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/Octokit/Clients/ActivitiesClient.cs b/Octokit/Clients/ActivitiesClient.cs index 77329024..ceeb4409 100644 --- a/Octokit/Clients/ActivitiesClient.cs +++ b/Octokit/Clients/ActivitiesClient.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; namespace Octokit { - public class ActivitiesClient: ApiClient, IActivitiesClient + public class ActivitiesClient : ApiClient { public ActivitiesClient(IApiConnection apiConnection) : base(apiConnection) @@ -22,5 +22,56 @@ namespace Octokit { return ApiConnection.GetAll(ApiUrls.Events()); } + + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// All the s for the particular repository. + public Task> GetAllForRepository(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.GetAll(ApiUrls.IssuesEvents(owner, name)); + } + + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// All the s for the particular repository network. + public Task> GetAllForRepositoryNetwork(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.GetAll(ApiUrls.NetworkEvents(owner, name)); + } + + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// All the s for the particular organization. + public Task> GetAllForOrganization(string organization) + { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + + return ApiConnection.GetAll(ApiUrls.OrganizationEvents(organization)); + } + + } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 53846127..86cce9d0 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -348,5 +348,21 @@ namespace Octokit { return "events".FormatUri(); } + + /// + /// Returns the for the network of repositories. + /// + /// The owner of the repository + /// The name of the repository + /// + public static Uri NetworkEvents(string owner, string name) + { + return "network/{0}/{1}/event".FormatUri(owner, name); + } + + public static Uri OrganizationEvents(string organization) + { + return "orgs/{0}/events".FormatUri(organization); + } } }