public Issue Create(string user, string password, string repo, IssueCreate createIssue)
        {
            var client = new HttpClient();
            var uri = String.Format("https://api.github.com/repos/{0}/{1}/issues", user, repo);
            var request = new HttpRequestMessage<IssueCreate>(createIssue,
                                                                           new HttpMethod("POST"),
                                                                           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<Issue>().Result;

            return result;
        }
Example #2
0
        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 Issue Create(string user, string password, string repo, IssueCreate createIssue)
 {
     return this.issuesRepository.Create(user, password, repo, createIssue);
 }
 public Issue CreateIssue(string user, string password, string repo, IssueCreate createIssue)
 {
     IIssuesService issuesService = ObjectFactory.GetInstance<IIssuesService>();
     return issuesService.Create(user, password, repo, createIssue);
 }