public Repo Edit(string user, string password, string repo, RepoEdit editRepo) { var client = new HttpClient(); var uri = String.Format("https://api.github.com/repos/{0}/{1}", user, repo); var request = new HttpRequestMessage<RepoEdit>(editRepo, new HttpMethod("PATCH"), new Uri(uri), new List<MediaTypeFormatter> { new JsonMediaTypeFormatter() }); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); client.DefaultRequestHeaders.Authorization = CreateBasicAuthentication(user, password); var response = client.SendAsync(request).Result; var result = response.Content.ReadAsAsync<Repo>().Result; return result; }
public static void Main() { // Settings needed to connect and use the Batching Service. string user = ConfigurationManager.AppSettings["User"]; string password = ConfigurationManager.AppSettings["Password"]; string batchingServiceEndpointAddress = ConfigurationManager.AppSettings["BatchingServiceEndpointAddress"]; // Creation of a channel connected to the Batching Service. var endpoint = new EndpointAddress(batchingServiceEndpointAddress); var binding = new BasicHttpBinding(); ChannelFactory<IGitHubSoapBatchingService> channelFactory = new ChannelFactory<IGitHubSoapBatchingService>(binding, endpoint); var serviceChannel = channelFactory.CreateChannel(); // Build a Request to create a new repository. var newRepo = new RepoCreate { name = "Another-Test-Repository", description = "Just another test repository", has_downloads = true, has_issues = true, has_wiki = false, @private = false }; var createRepoRequest = new CreateRepoRequest {User = user, Password = password, CreateRepo = newRepo}; // Build a Request to get the created repository. var getRepoRequest = new GetRepoRequest {User = user, Repo = newRepo.name}; // Build a request to edit the created repository. var editRepo = new RepoEdit {has_wiki = true, name = newRepo.name}; var editRepoRequest = new EditRepoRequest {User = user, Password = password, Repo = newRepo.name, EditRepo = editRepo}; // Call the Batching Service. var results = serviceChannel.Process(createRepoRequest, getRepoRequest, editRepoRequest); // Get the indexed responses. var createRepoResponse = (RepoResponse) results[0]; var getRepoResponse = (RepoResponse) results[1]; var editRepoResponse = (RepoResponse) results[2]; }
public static void Main() { // Settings needed to connect and use the Regular Service. string user = ConfigurationManager.AppSettings["User"]; string password = ConfigurationManager.AppSettings["Password"]; string serviceEndpointAddress = ConfigurationManager.AppSettings["ServiceEndpointAddress"]; // Creation of a channel connected to the Regular Service. var endpoint = new EndpointAddress(serviceEndpointAddress); var binding = new BasicHttpBinding(); ChannelFactory<IGitHubSoapService> channelFactory = new ChannelFactory<IGitHubSoapService>(binding, endpoint); channelFactory.Endpoint.Behaviors.Add(new AuthenticationHeaderBehavior()); var serviceChannel = channelFactory.CreateChannel(); // Create a new repository. var newRepo = new RepoCreate { name = "Test-Repository", description = "Just a test repository", has_downloads = true, has_issues = true, has_wiki = false, @private = false }; var createdRepo = serviceChannel.CreateRepo(user, password, newRepo); // Get the created repository. var repo = serviceChannel.GetRepo(user, "Test-Repository"); // Edit the repository. var editRepo = new RepoEdit { has_downloads = false, name = "Test-Repository" }; serviceChannel.EditRepo(user, password, "Test-Repository", editRepo); // Create an issue in the created repository. var newIssue = new IssueCreate {title = "Found a bug", body = "I'm having a problem with this.", assignee = "luismdcp"}; var createdIssue = serviceChannel.CreateIssue(user, password, "Test-Repository", newIssue); // Edit the created issue. var editIssue = new IssueEdit {milestone = 1}; serviceChannel.EditIssue(user, password, "Test-Repository", createdIssue.id, editIssue); }
public Repo EditRepo(string user, string password, string repo, RepoEdit editRepo) { IReposService reposService = ObjectFactory.GetInstance<IReposService>(); return reposService.Edit(user, password, repo, editRepo); }
public Repo Edit(string user, string password, string repo, RepoEdit editRepo) { return this.reposRepository.Edit(user, password, repo, editRepo); }