Created
May 22, 2012 00:05
-
-
Save AlexCuse/2765570 to your computer and use it in GitHub Desktop.
Retrieve open tickets from assembla and create issues for them on github :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using RestSharp; | |
namespace GithubTicketImporter { | |
class Program { | |
static IAuthenticator authenticator = new HttpBasicAuthenticator("uname", "pwd"); | |
static string assemblaBaseUrl = "https://www.assembla.com/spaces/BrewTelligence/"; | |
static string githubBaseUrl = "https://api.github.com/"; | |
static RestClient assemblaClient = new RestClient(assemblaBaseUrl) { Authenticator = authenticator }; | |
static RestClient githubClient = new RestClient(githubBaseUrl) { Authenticator = authenticator }; | |
static void Main(string[] args) { | |
foreach (var ticket in GetAssemblaTickets()) { | |
OpenOnGithub(ticket); | |
} | |
} | |
static void OpenOnGithub(Ticket ticket) { | |
var request = new RestRequest("repos/AlexCuse/BrewTelligence/issues", Method.POST); | |
request.RequestFormat = DataFormat.Json; | |
request.AddBody(new { title = ticket.Summary, body = ticket.Description }); | |
var newTicket = githubClient.Execute(request).Content; | |
Console.WriteLine(newTicket); | |
} | |
static IEnumerable<Ticket> GetAssemblaTickets() { | |
var request = new RestRequest("tickets", Method.GET); | |
request.AddHeader("Accept", "application/xml"); | |
var result = assemblaClient.Execute<List<Ticket>>(request); | |
return result.Data; | |
} | |
} | |
class Ticket { | |
public int Number { get; set; } | |
public string Description { get; set; } | |
public string StatusName { get; set; } | |
public string Summary { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment