mtymek / codebasehq-sdk
PHP SDK for CodebaseHQ API
Installs: 1 866
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 5
Forks: 2
Open Issues: 2
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-12-05 04:46:23 UTC
README
CodebaseHQ is software project management tool with Git, Mercurial and Subversion hosting, bug and time tracking, and more.
Installation
This package can be installed using Composer:
{ "minimum-stability": "dev", "require": { "mtymek/codebasehq-sdk": "dev-master" } }
Usage
Please refer to this document for general information about CodebaseHQ API.
First, you need to create API client, and pass your account, username and API key:
$client = new CodebaseHq\Api('someaccount', 'mtymek', '85j9axug8r2mb42ao5rf59nrpstesdujbj05x2ih');
Example: listing tickets
Tickets are related organized in projects, so you need to begin with setting project name:
$client->setProject('project_name');
Now you're allowed to find tickets matching given query:
// list all closed tickets for current user $tickets = $client->tickets()->find('assignee:me status:closed');
Above code will return array of CodebaseHq\Entity\Ticket
objects.
You can also fetch single ticket:
$ticket = $client->tickets()->findOneById(124);
XML API
At this moment object interface supports only subset of Codebase HQ API. You can also access it directly, using low-level calls that work on XML data:
// Example: listing all assigned tickets $result = $api->api('/mats-playground/tickets?query=' . urlencode('assignee:me')); $xml = new SimpleXMLElement($result); foreach ($xml->ticket as $ticket) { echo $ticket->{'ticket-id'} . ': ' . $ticket->summary, "\n"; } // Example: tracking time session $xml = '<time-session> <summary>Worked on the awesome feature</summary> <minutes>60:00</minutes> </time-session>'; $api->api('/mats-playground/time_sessions', 'POST', $xml);
You can avoid passing XML directly by using buildXml()
helper method:
// Example: ticket update $ticketNote = array( 'content' => 'Lorem Ipsum dolor sit amet.', 'time-added' => '1:00' ); $result = $api->api( '/mats-playground/tickets/263/notes', 'POST', $api->buildXml('ticket-note', $ticketNote) );
TODO
- basic, low-level API access [IMPLEMENTED]
- nice, object-oriented interface for accessing all types of records defined by CodebaseHQ API [IN PROGRESS]