-
Notifications
You must be signed in to change notification settings - Fork 18
Home
sirprize edited this page Oct 10, 2011
·
17 revisions
This is a php library to access the Basecamp api. Collection classes provide methods to query the api and wrap each result item in an entity object. Entity objects come with methods such as update() and delete() to persist themselfes via the api. Functionality is provided to attach and detach observers to collections and entities – this is useful for logging or to print current activity to the terminal.
- Person: startMe(), startById(), startAllByProjectId(), startAll() etc
- Project: startById(), startAll(), copy(), replicate() etc
- Milestone: startAllByProjectId(), create(), update(), delete(), complete(), uncomplete() etc
- Todolist: startById(), startAllByProjectId(), startAllByResponsibiltyParty(), create(), update(), delete() etc
- Todoitems: startAllByTodoListId(), startById(), create(), update(), delete(), complete(), uncomplete() etc
- Comments: startAllByResourceId(), startById()
- Timetracking: startAllByProjectId(), startById()
- php 5.3+ (uses namespaces)
Please find plenty of working examples in the basecamp/example/basecamp directory. Here’s the basics:
- create a dummy project in your basecamp account
- adjust basecamp/example/basecamp/_config.php with your own settings
- make files executable in basecamp/example/basecamp/(milestone|person|project|todoitem|todolist)/*
- make writeable basecamp/example/_logs
- run examples
$config = array( 'baseUri' => 'https://xxx.basecamphq.com', 'username' => 'xxx', 'password' => 'xxx' );
$service = new \Sirprize\Basecamp\Service($config);
$projects = $service->getProjectsInstance()->startAll();
foreach($projects as $project) { print $project->getName()."\n"; }
/* * * populate the target-project with the milestones, * todo-lists and todo-items from the source-project * */
$sourceProjectId = new \Sirprize\Basecamp\Id('xxx'); $targetProjectId = new \Sirprize\Basecamp\Id('yyy');
$projects = $service->getProjectsInstance(); $sourceProject = $projects->startById($sourceProjectId); $sourceProject->copy($targetProjectId);
/* * * populate the target-project with the milestones, * todo-lists and todo-items from the source-project. * the last milestone deadline is pushed to 2010-12-30 and * all other deadlines will be calculated relative to it * */
$sourceProjectId = new \Sirprize\Basecamp\Id('xxx'); $targetProjectId = new \Sirprize\Basecamp\Id('yyy');
$projects = $service->getProjectsInstance(); $sourceProject = $projects->startById($sourceProjectId); $referenceDate = new \Sirprize\Basecamp\Date('2010-12-30'); $referenceMilestone = \Sirprize\Basecamp\Schema\Export::REFERENCE_EXTREMITY_LAST; $sourceProject->replicate($targetProjectId, $referenceDate, $referenceMilestone);
$milestones = $service->getMilestonesInstance(); $milestone = $milestones->getMilestoneInstance(); $deadline = new \Sirprize\Basecamp\Date('2010-03-01'); $projectId = new \Sirprize\Basecamp\Id('xxx'); $userId = new \Sirprize\Basecamp\Id('xxx');
$milestone ->setProjectId($projectId) ->setResponsiblePartyId($userId) ->setDeadline($deadline) ->setTitle('Milestoners Everywhere') ->setWantsNotification(true) ->create() ;
- Account
- Companies
- Categories
- Messages
- Comments: create(), update(), delete()
- Time tracking: startAllByTodoItemId(), create(), update(), delete()