stevenmaguire /
trello-php
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Stevenmaguire\Services\Trello; |
||
| 4 | |||
| 5 | use GuzzleHttp\ClientInterface as HttpClient; |
||
| 6 | |||
| 7 | class Client |
||
| 8 | { |
||
| 9 | use Traits\ApiMethodsTrait; |
||
| 10 | use Traits\AuthorizationTrait; |
||
| 11 | use Traits\BatchTrait; |
||
| 12 | use Traits\ConfigurationTrait; |
||
| 13 | use Traits\SearchTrait; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Default client options |
||
| 17 | * |
||
| 18 | * @var array |
||
| 19 | */ |
||
| 20 | protected static $defaultOptions = [ |
||
| 21 | 'domain' => 'https://trello.com', |
||
| 22 | 'key' => null, |
||
| 23 | 'proxy' => null, |
||
| 24 | 'version' => '1', |
||
| 25 | 'secret' => null, |
||
| 26 | ]; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Http broker |
||
| 30 | * |
||
| 31 | * @var Http |
||
| 32 | */ |
||
| 33 | protected $http; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Creates new trello client. |
||
| 37 | * |
||
| 38 | 702 | * @param array $options |
|
| 39 | */ |
||
| 40 | 702 | public function __construct($options = []) |
|
| 41 | { |
||
| 42 | 702 | Configuration::setMany($options, static::$defaultOptions); |
|
| 43 | 702 | ||
| 44 | $this->http = new Http(); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Retrieves a new authorization broker. |
||
| 49 | * |
||
| 50 | 2 | * @return Stevenmaguire\Services\Trello\Authorization |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 51 | */ |
||
| 52 | 2 | public function getAuthorization() |
|
| 53 | { |
||
| 54 | return new Authorization(); |
||
|
0 ignored issues
–
show
|
|||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Retrieves currently configured http broker. |
||
| 59 | * |
||
| 60 | 684 | * @return Stevenmaguire\Services\Trello\Http |
|
|
0 ignored issues
–
show
|
|||
| 61 | */ |
||
| 62 | 684 | public function getHttp() |
|
| 63 | { |
||
| 64 | return $this->http; |
||
|
0 ignored issues
–
show
|
|||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Updates the http client used by http broker. |
||
| 69 | * |
||
| 70 | * @param HttpClient $httpClient |
||
| 71 | * |
||
| 72 | 680 | * @return Client |
|
| 73 | */ |
||
| 74 | 680 | public function setHttpClient(HttpClient $httpClient) |
|
| 75 | { |
||
| 76 | 680 | $this->http->setClient($httpClient); |
|
| 77 | |||
| 78 | return $this; |
||
| 79 | 2 | } |
|
| 80 | } |
||
| 81 |