//http://developer.github.com/v3/issues/#edit-an-issue public static IRestResponse <TIssue> EditIssue <TIssue>(this GithubRestApiClient client, string RepoOwner, string Repo, long IssueNumber, string Title = null, string Body = null, string Asignee = null, string State = null, string[] Labels = null) where TIssue : new() { dynamic data = GetUpdateData(Title, Body, Asignee, State, Labels); var request = client.RequestFactory.CreateRequest( () => { var req = new RestRequest("/repos/{owner}/{repo}/issues/{number}") { Method = Method.PATCH, RequestFormat = DataFormat.Json }; req.AddBody(data); req.AddUrlSegment("owner", RepoOwner); req.AddUrlSegment("repo", Repo); req.AddUrlSegment("number", IssueNumber.ToString()); return(req); }); var response = client.Execute <TIssue>(request); return(response); }
//http://developer.github.com/v3/issues/comments/#create-a-comment //TODO: do we like this way of specifying URL parameters? Should we require a Repo Object instead? public static IRestResponse <TComment> CreateComment <TComment>(this GithubRestApiClient client, string RepoOwner, string Repo, long Number, string CommentText) where TComment : new() { dynamic data = GetUpdateData(CommentText); var request = client.RequestFactory.CreateRequest( () => { var req = new RestRequest("/repos/{owner}/{repo}/issues/{number}/comments") { Method = Method.POST, RequestFormat = DataFormat.Json }; req.AddBody(data); req.AddUrlSegment("owner", RepoOwner); req.AddUrlSegment("repo", Repo); req.AddUrlSegment("number", Number.ToString()); return(req); }); var response = client.Execute <TComment>(request); return(response); }
static void Main(string[] args) { var client = new GithubRestApiClient( @"https://api.github.com"); client.WithAuthentication(new HttpBasicAuthenticator("[user name here]", "[password here]")); CreateAuthorization(client); //GetAuthorizations(client); }
private static void CreateAuthorization(GithubRestApiClient client) { var response = client.CreateAuthorization<Authorization>(new List<string> { "repo" }, "[client id here]", "[client secret here]"); Console.WriteLine("Authorization Token: " + response.Data.Token); Console.ReadKey(); }
/// <summary> /// Get the authenticated user /// </summary> /// <param name="client">The <see cref="GithubRestApiClient"/> instance to attach to.</param> /// <typeparam name="TIssue">The user model to serialise the JSON data into.</typeparam> /// <returns>A <see cref="IRestResponse{TIssue}"/> for the authenticated user.</returns> public static IRestResponse <T> GetUser <T>(this GithubRestApiClient client) where T : new() { Log.Info(() => "Making request for the authenticated user."); var request = client.RequestFactory.CreateRequest(() => new RestRequest("/user")); var response = client.Execute <T>(request); return(response); }
/// <summary> /// Get a single user /// </summary> /// <param name="client">The <see cref="GithubRestApiClient"/> instance to attach to.</param> /// <param name="username">The user to get from GitHub.</param> public static IRestResponse <TUser> GetUser <TUser>(this GithubRestApiClient client, string username) where TUser : new() { var request = client.RequestFactory.CreateRequest("/users/{username}", Method.GET, new[] { new KeyValuePair <string, string>("username", username) }); var response = client.Execute <TUser>(request); return(response); }
private static void GetAuthorizations(GithubRestApiClient client) { var response = client.GetAuthorizations<List<Authorization>>(); foreach (var auth in response.Data) { Console.WriteLine("App: " + auth.App.Name); Console.WriteLine("Authorization Token: " + auth.Token); Console.WriteLine(Environment.NewLine); } Console.ReadKey(); }
/// <summary> /// Get all users /// </summary> /// <remarks> /// This provides a dump of every user, in the order that they signed up for GitHub. /// </remarks> /// <param name="client">The <see cref="GithubRestApiClient"/> instance to attach to.</param> /// <param name="id">The integer ID of the last User that you’ve seen.</param> /// <returns>A <see cref="IRestResponse"/> containing a chunk of users.</returns> public static IRestResponse GetUsers(this GithubRestApiClient client, string id = "") { var request = client.RequestFactory.CreateRequest(() => { var req = new RestRequest("/users?since={id}") { Method = Method.GET }; req.AddUrlSegment("id", Convert.ToString(id, CultureInfo.InvariantCulture)); return(req); }); var response = client.Execute(request); return(response); }
/// <summary> /// List all issues across all the authenticated user’s visible repositories including owned repositories, member repositories, and organization repositories: http://developer.github.com/v3/issues/#list-issues /// </summary> /// <param name="client">The <see cref="GithubRestApiClient"/> instance to attach to.</param> /// <typeparam name="TIssue">The issue model to serialise the JSON data into.</typeparam> /// <returns>A <see cref="IRestResponse{TIssue}"/> for the issues.</returns> public static IRestResponse <TIssue> GetIssues <TIssue>(this GithubRestApiClient client) where TIssue : new() { Log.Info(() => "Making request for the issues."); var request = client.RequestFactory.CreateRequest( () => { var req = new RestRequest("/issues?filter={filter}") { Method = Method.GET }; req.AddUrlSegment("filter", "all"); return(req); } ); var response = client.Execute <TIssue>(request); return(response); }
//http://developer.github.com/v3/repos/collaborators/#add-collaborator //Strange one, has no response object public static IRestResponse AddCollaborator(this GithubRestApiClient client, string RepoOwner, string Repo, string UserID) { var request = client.RequestFactory.CreateRequest( () => { var req = new RestRequest("/repos/{owner}/{repo}/collaborators/{user}") { Method = Method.PUT, RequestFormat = DataFormat.Json }; req.AddUrlSegment("owner", RepoOwner); req.AddUrlSegment("repo", Repo); req.AddUrlSegment("user", UserID); return(req); }); var response = client.Execute(request); return(response); }
public static IRestResponse <TUser> UpdateUser <TUser>(this GithubRestApiClient client, string name = "", string email = "", string blog = null, string company = "", string location = "", string hireable = "", string bio = "") where TUser : new() { dynamic data = GetUpdateData(name, email, blog, company, location, hireable, bio); var request = client.RequestFactory.CreateRequest( () => { var req = new RestRequest("/user") { Method = Method.PATCH, RequestFormat = DataFormat.Json }; req.AddBody(data); return(req); }); var response = client.Execute <TUser>(request); return(response); }
public override void Context() { base.Context(); Github = new GithubRestApiClient(GitHubUrl); }
public override void Context() { base.Context(); Github = new GithubRestApiClient(GitHubUrl); }
public static IRestResponse Events(GithubRestApiClient client) { return(null); }
public static IRestResponse Events(GithubRestApiClient client) { return null; }