Skip to content

Commit

Permalink
add example for time entry code
Browse files Browse the repository at this point in the history
  • Loading branch information
sirprize committed May 30, 2011
1 parent 980f227 commit 113218c
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/basecamp/_config.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ define('BASECAMP_EXAMPLE_TODOLIST_ID', 'xxxxxx');
define('BASECAMP_EXAMPLE_TODOLIST_TEMPLATE_ID', 'xxxxxx');
define('BASECAMP_EXAMPLE_TODOLISTITEM_ID', 'xxxxxx');
define('BASECAMP_EXAMPLE_COMMENT_ID', 'xxxxxx');
define('BASECAMP_EXAMPLE_TIMEENTRY_ID', 'xxxxxx');

set_include_path(implode(PATH_SEPARATOR, array(
realpath('/path/to/zend/framework'), # path to zend framework
Expand Down
43 changes: 43 additions & 0 deletions example/basecamp/timeentry/get-all-in-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env php
<?php

/**
* Basecamp API Wrapper for PHP 5.3+
*
* LICENSE
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt
*
* @category Sirprize
* @package Basecamp
* @subpackage Try
* @copyright Copyright (c) 2010, Christian Hoegl, Switzerland (http://sirprize.me)
* @license MIT License
*/

require_once '../_config.php';

require_once 'Sirprize/Basecamp/Cli.php';
$basecamp = new \Sirprize\Basecamp\Cli($config);
$basecamp->setLog($log);

require_once 'Sirprize/Basecamp/Id.php';
$projectId = new \Sirprize\Basecamp\Id(BASECAMP_EXAMPLE_PROJECT_ID);

$timeEntries = $basecamp->getTimeEntriesInstance();
$timeEntries->startAllByProjectId($projectId);

if($timeEntries->getResponse()->isError())
{
die("Error\n");
}

foreach($timeEntries as $timeEntry)
{
print "id: ".$timeEntry->getId()."\n";
print "date: ".$timeEntry->getDate()."\n";
print "hours: ".$timeEntry->getHours()."\n";
print "description: ".$timeEntry->getDescription()."\n";
print "--------------------------\n";
}
44 changes: 44 additions & 0 deletions example/basecamp/timeentry/get-by-id
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env php
<?php

/**
* Basecamp API Wrapper for PHP 5.3+
*
* LICENSE
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt
*
* @category Sirprize
* @package Basecamp
* @subpackage Try
* @copyright Copyright (c) 2010, Christian Hoegl, Switzerland (http://sirprize.me)
* @license MIT License
*/

require_once '../_config.php';

require_once 'Sirprize/Basecamp/Cli.php';
$basecamp = new \Sirprize\Basecamp\Cli($config);
$basecamp->setLog($log);

require_once 'Sirprize/Basecamp/Id.php';
$timeEntryId = new \Sirprize\Basecamp\Id(BASECAMP_EXAMPLE_TIMEENTRY_ID);

$timeEntries = $basecamp->getTimeEntriesInstance();
$timeEntry = $timeEntries->startById($timeEntryId);

if($timeEntry === null)
{
die("Not found\n");
}

if($timeEntries->getResponse()->isError())
{
die("Error\n");
}

print "id: ".$timeEntry->getId()."\n";
print "date: ".$timeEntry->getDate()."\n";
print "hours: ".$timeEntry->getHours()."\n";
print "description: ".$timeEntry->getDescription()."\n";

0 comments on commit 113218c

Please sign in to comment.