Skip to content

Instantly share code, notes, and snippets.

@AlexCuse
Created May 22, 2012 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexCuse/2765570 to your computer and use it in GitHub Desktop.
Save AlexCuse/2765570 to your computer and use it in GitHub Desktop.
Retrieve open tickets from assembla and create issues for them on github :)
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