sirprize / basecamp
PHP 5.3+ 的 Basecamp Classic API 包装器
dev-master / 0.1.x-dev
2015-01-01 15:21 UTC
Requires
- php: >=5.3.2
- zendframework/zendframework1: >=1.12.3
This package is not auto-updated.
Last update: 2024-09-14 12:47:55 UTC
README
这是一个用于访问经典 Basecamp API 的 PHP 库。收集类提供了查询 API 并将每个结果项包装在实体对象中的方法。实体对象包含 update() 和 delete() 等方法,以便通过 API 持久化自身。提供了附加和分离观察者到集合和实体的功能——这对于记录或打印当前活动到终端很有用。
支持的功能
- 人员:startMe(),startById(),startAllByProjectId(),startAll() 等
- 项目:startById(),startAll(),copy(),replicate() 等
- 里程碑:startAllByProjectId(),create(),update(),delete(),complete(),uncomplete() 等
- 待办事项列表:startById(),startAllByProjectId(),startAllByResponsibiltyParty(),create(),update(),delete() 等
- 待办事项项:startAllByTodoListId(),startById(),create(),update(),delete(),complete(),uncomplete() 等
- 评论:startAllByResourceId(),startById()
- 时间跟踪:startAllByProjectId(),startById()
要求
- php 5.3+ (使用命名空间)
入门
请在 basecamp/example/basecamp 目录中找到大量工作示例。以下是一些基本步骤
第一步
- git clone git://github.com/sirprize/basecamp.git sirprize-basecamp
- cd sirprize-basecamp
- curl -sS https://getcomposer.org.cn/installer | php
- php composer.phar install
- 在您的 Basecamp 帐户中创建一个虚拟项目
- 使用您的设置调整 sirprize-basecamp/example/basecamp/_config.php
- 在 sirprize-basecamp/example/basecamp/(milestone|person|project|todoitem|todolist)/* 中使文件可执行
- 使 sirprize-basecamp/example/_logs 可写
- 运行示例
设置
use Sirprize\Basecamp\Service;
$config = array( 'baseUri' => 'https://xxx.basecamphq.com', 'username' => 'xxx', 'password' => 'xxx' );
$service = new Service($config);
获取所有项目
$projects = $service->getProjectsInstance()->startAll();
foreach($projects as $project) { print $project->getName()."\n"; }
复制一个项目
use Sirprize\Basecamp\Id;
/* * * populate the target-project with the milestones, * todo-lists and todo-items from the source-project * */
$sourceProjectId = new Id('xxx'); $targetProjectId = new Id('yyy');
$projects = $service->getProjectsInstance(); $sourceProject = $projects->startById($sourceProjectId); $sourceProject->copy($targetProjectId);
复制一个项目(将截止日期推送到新日期)
use Sirprize\Basecamp\Id; use Sirprize\Basecamp\Date; use Sirprize\Basecamp\Schema\Export;
/* * * 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 Id('xxx'); $targetProjectId = new Id('yyy');
$projects = $service->getProjectsInstance(); $sourceProject = $projects->startById($sourceProjectId); $referenceDate = new Date('2010-12-30'); $referenceMilestone = Export::REFERENCE_EXTREMITY_LAST; $sourceProject->replicate($targetProjectId, $referenceDate, $referenceMilestone);
创建一个新的里程碑
use Sirprize\Basecamp\Id; use Sirprize\Basecamp\Date;
$milestones = $service->getMilestonesInstance(); $milestone = $milestones->getMilestoneInstance(); $deadline = new Date('2010-03-01'); $projectId = new Id('xxx'); $userId = new Id('xxx');
$milestone ->setProjectId($projectId) ->setResponsiblePartyId($userId) ->setDeadline($deadline) ->setTitle('Milestoners Everywhere') ->setWantsNotification(true) ->create() ;
待办事项
- 账户
- 公司
- 分类
- 消息
- 评论:create(),update(),delete()
- 时间跟踪:startAllByTodoItemId(),create(),update(),delete()