The new Basecamp API

This project is a complete C# wrapper around the new Basecamp API (https://github.com/37signals/bcx-api. There are two main goals in the design of the project:

  1. Provide a very straight forward one-to-one API to method call
  2. Provide a "friendly" or "fluent" layer ontop of the API calls that allows to you manipulate API objects without having to (directly) reference an API call method

For example, the following two code samples are equivalent:

Create Project and Todo list using helper methods

var credentials = new BasicAuthenticationCredentials() { AccountId = 0, UserName = "", Password = "" };

var api = new Api(credentials);

var project = new Project() { Name = "Test Project", Description = "This is a description" };
api.Projects.Create(project);

var list = project.CreateToDoList("New todolist");
var item = list.CreateToDo("We need to do this");
item.Completed = true;
list.UpdateToDo(item);

Create Project and Todo list using direct API methods

var credentials = new BasicAuthenticationCredentials() { AccountId = 0, UserName = "", Password = "" };

var api = new Api(credentials);

var createProjectRequest = new ProjectCreateRequest() { Name = "Test Project", Description = "This is a description" };
var project = api.Projects.Create(createProjectRequest);

var list = api.ToDoLists.Create(new ToDoListCreateRequest() { ProjectId = project.Id, Name = "New todolist" });

var listItemCreateRequest = new ToDoListItemCreateRequest() { ProjectId = project.Id, ToDoListId = list.Id, Content = "We need to do this" };
var listItem = api.ToDoLists.Create(listItemCreateRequest);
            
listItem.Completed = true;
api.ToDoLists.Update(listItem);

Accessing API endpoints

After you initialize an Api object with your credentials, you can access all the API endpoints via helper properties.

Access projects

api.Projects.GetActive(); 
api.Projects.GetArchived();

Get recent activity (events)

var recentEvents = api.Events.Get(DateTime.Now.AddDays(-30)); //get the last month of events

Add a file to a project

var upload = api.Uploads.CreateForProject(project.Id, "This is the file", "c:\\my file.pdf");

Last edited Nov 13, 2012 at 4:24 AM by clonked, version 9