Skip to content

Commit

Permalink
add license info + make client setters chainable
Browse files Browse the repository at this point in the history
  • Loading branch information
kbsali committed Dec 13, 2013
1 parent d09be12 commit cb29a29
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 54 deletions.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2013 Kevin Saliou

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 changes: 3 additions & 24 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,12 @@ A possible solution to this would be to create an extra APIs implementing the mi
* "Enable REST web service" for your Redmine project (/settings/edit?tab=authentication)
* then obtain your *API access key* in your profile page : /my/account

## Autoload
## Install

The first step to use `php-redmine-api` is to download composer:
Through [composer](http://getcomposer.org/download/), simply run :

```bash
$ curl -s http://getcomposer.org/installer | php
```

Then create a composer.json file in the root of your project:

```yaml
{
"require": {
"kbsali/redmine-api": "~1.0"
}
}
```

... and install your dependencies using:
```bash
$ php composer.phar install
$ php composer.phar require kbsali/redmine-api:1.*
```

## Basic usage of `php-redmine-api` client
Expand Down Expand Up @@ -106,9 +91,3 @@ see `example.php`

- Thanks to [Thomas Spycher](http://tspycher.com/2011/03/using-the-redmine-api-with-php/) for the 1st version of the class.
- Thanks to [Thibault Duplessis aka. ornicar](https://github.com/ornicar) for the php-github-api library, great source of inspiration!

## Contributors

- Kevin Saliou (@kbsali)
- William Suffill (@wsuff)
- Marlos Carmo (@marloscarmo)
3 changes: 1 addition & 2 deletions lib/Redmine/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
/**
* Abstract class for Api classes
*
* @author Thibault Duplessis <thibault.duplessis at gmail dot com>
* @author Joseph Bielawski <[email protected]>
* @author Kevin Saliou <kevin at saliou dot name>
*/
abstract class AbstractApi
{
Expand Down
4 changes: 3 additions & 1 deletion lib/Redmine/Api/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Redmine\Api;

/**
* Custom queries retrieval
*
* @link http://www.redmine.org/projects/redmine/wiki/Rest_Queries
* @author Kevin Saliou <kevin at saliou dot name>
*/
Expand All @@ -11,7 +13,7 @@ class Query extends AbstractApi
private $query = array();

/**
* List available queries
* Returns the list of all custom queries visible by the user (public and private queries) for all projects.
* @link http://www.redmine.org/projects/redmine/wiki/Rest_Queries#GET
*
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
Expand Down
1 change: 0 additions & 1 deletion lib/Redmine/Api/TimeEntryActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class TimeEntryActivity extends AbstractApi

/**
* List time entry activities
* @link http://www.redmine.org/projects/redmine/wiki/Rest_Enumerations#enumerationstime_entry_activitiesformat
*
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
* @return array list of time entry activities found
Expand Down
43 changes: 17 additions & 26 deletions lib/Redmine/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,86 +86,66 @@ public function api($name)
{
if (!isset($this->apis[$name])) {
switch ($name) {

case 'attachment':
$api = new Api\Attachment($this);
break;

// @todo finish implementation!
case 'group':
$api = new Api\Group($this);
break;

case 'issue':
$api = new Api\Issue($this);
break;

case 'issue_category':
$api = new Api\IssueCategory($this);
break;

case 'issue_priority':
$api = new Api\IssuePriority($this);
break;

// @todo finish implementation!
case 'issue_relation':
$api = new Api\IssueRelation($this);
break;

case 'issue_status':
$api = new Api\IssueStatus($this);
break;

// @todo finish implementation!
case 'membership':
$api = new Api\Membership($this);
break;

case 'news':
$api = new Api\News($this);
break;

case 'project':
$api = new Api\Project($this);
break;

case 'query':
$api = new Api\Query($this);
break;

case 'role':
$api = new Api\Role($this);
break;

case 'time_entry':
$api = new Api\TimeEntry($this);
break;

case 'time_entry_activity':
$api = new Api\TimeEntryActivity($this);
break;

case 'tracker':
$api = new Api\Tracker($this);
break;

case 'user':
$api = new Api\User($this);
break;

case 'version':
$api = new Api\Version($this);
break;

case 'wiki':
$api = new Api\Wiki($this);
break;

default:
throw new \InvalidArgumentException();
}

$this->apis[$name] = $api;
}

Expand Down Expand Up @@ -247,41 +227,52 @@ public function delete($path)

/**
* Turns on/off ssl certificate check
* @param boolean $check
* @param boolean $check
* @return Client
*/
public function setCheckSslCertificate($check = false)
{
$this->checkSslCertificate = $check;

return $this;
}

/**
* Turns on/off ssl host certificate check
* @param boolean $check
* @param boolean $check
* @return Client
*/
public function setCheckSslHost($check = false)
{
$this->checkSslHost = $check;
$this->checkSslHost = $check;

return $this;
}

/**
* Turns on/off http auth
* @param bool $use
* @internal param bool $check
* @param bool $use
* @return Client
*/
public function setUseHttpAuth($use = true)
{
$this->useHttpAuth = $use;

return $this;
}

/**
* Set the port of the connection
* @param int $port
* @param int $port
* @return Client
*/
public function setPort($port = null)
{
if (null !== $port) {
$this->port = (int) $port;
}

return $this;
}

/**
Expand Down

0 comments on commit cb29a29

Please sign in to comment.