@@ -6,105 +6,105 @@ |
||
| 6 | 6 | |
| 7 | 7 | abstract class Endpoint |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * @var array |
|
| 11 | - */ |
|
| 12 | - protected $rateLimitInfo; |
|
| 9 | + /** |
|
| 10 | + * @var array |
|
| 11 | + */ |
|
| 12 | + protected $rateLimitInfo; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @var array |
|
| 16 | - */ |
|
| 17 | - protected $headers = []; |
|
| 14 | + /** |
|
| 15 | + * @var array |
|
| 16 | + */ |
|
| 17 | + protected $headers = []; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var HttpClient |
|
| 21 | - */ |
|
| 22 | - protected $http; |
|
| 19 | + /** |
|
| 20 | + * @var HttpClient |
|
| 21 | + */ |
|
| 22 | + protected $http; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - protected $organizationId; |
|
| 24 | + /** |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + protected $organizationId; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @param HttpClient $http |
|
| 31 | - */ |
|
| 32 | - public function __construct(HttpClient $http) |
|
| 33 | - { |
|
| 34 | - $this->http = $http; |
|
| 35 | - } |
|
| 29 | + /** |
|
| 30 | + * @param HttpClient $http |
|
| 31 | + */ |
|
| 32 | + public function __construct(HttpClient $http) |
|
| 33 | + { |
|
| 34 | + $this->http = $http; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param string $verb |
|
| 39 | - * @return string |
|
| 40 | - */ |
|
| 41 | - public function makeRequestUrl($verb = '') |
|
| 42 | - { |
|
| 43 | - return "https://favro.com/api/v1/{$this->endpoint()}/$verb"; |
|
| 44 | - } |
|
| 37 | + /** |
|
| 38 | + * @param string $verb |
|
| 39 | + * @return string |
|
| 40 | + */ |
|
| 41 | + public function makeRequestUrl($verb = '') |
|
| 42 | + { |
|
| 43 | + return "https://favro.com/api/v1/{$this->endpoint()}/$verb"; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @return HttpClient |
|
| 48 | - */ |
|
| 49 | - public function getHttp() |
|
| 50 | - { |
|
| 51 | - return $this->http; |
|
| 52 | - } |
|
| 46 | + /** |
|
| 47 | + * @return HttpClient |
|
| 48 | + */ |
|
| 49 | + public function getHttp() |
|
| 50 | + { |
|
| 51 | + return $this->http; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @param array $params |
|
| 56 | - * @return array |
|
| 57 | - */ |
|
| 58 | - public function getAll(array $params = []) |
|
| 59 | - { |
|
| 60 | - return $this |
|
| 61 | - ->getHttp() |
|
| 62 | - ->get( |
|
| 63 | - $this->makeRequestUrl(), |
|
| 64 | - $params, |
|
| 65 | - $this->getHeaders() |
|
| 66 | - ); |
|
| 67 | - } |
|
| 54 | + /** |
|
| 55 | + * @param array $params |
|
| 56 | + * @return array |
|
| 57 | + */ |
|
| 58 | + public function getAll(array $params = []) |
|
| 59 | + { |
|
| 60 | + return $this |
|
| 61 | + ->getHttp() |
|
| 62 | + ->get( |
|
| 63 | + $this->makeRequestUrl(), |
|
| 64 | + $params, |
|
| 65 | + $this->getHeaders() |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @param string $id |
|
| 71 | - * @return array |
|
| 72 | - */ |
|
| 73 | - public function getById($id) |
|
| 74 | - { |
|
| 75 | - return $this |
|
| 76 | - ->getHttp() |
|
| 77 | - ->get( |
|
| 78 | - $this->makeRequestUrl($id), |
|
| 79 | - [], |
|
| 80 | - $this->getHeaders() |
|
| 81 | - ); |
|
| 82 | - } |
|
| 69 | + /** |
|
| 70 | + * @param string $id |
|
| 71 | + * @return array |
|
| 72 | + */ |
|
| 73 | + public function getById($id) |
|
| 74 | + { |
|
| 75 | + return $this |
|
| 76 | + ->getHttp() |
|
| 77 | + ->get( |
|
| 78 | + $this->makeRequestUrl($id), |
|
| 79 | + [], |
|
| 80 | + $this->getHeaders() |
|
| 81 | + ); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @return array |
|
| 86 | - */ |
|
| 87 | - public function getHeaders() |
|
| 88 | - { |
|
| 89 | - return array_merge( |
|
| 90 | - ['organizationId' => $this->organizationId], |
|
| 91 | - $this->headers |
|
| 92 | - ); |
|
| 93 | - } |
|
| 84 | + /** |
|
| 85 | + * @return array |
|
| 86 | + */ |
|
| 87 | + public function getHeaders() |
|
| 88 | + { |
|
| 89 | + return array_merge( |
|
| 90 | + ['organizationId' => $this->organizationId], |
|
| 91 | + $this->headers |
|
| 92 | + ); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * @param string $organizationId |
|
| 97 | - * @return $this |
|
| 98 | - */ |
|
| 99 | - public function setOrganizationId($organizationId) |
|
| 100 | - { |
|
| 101 | - $this->organizationId = $organizationId; |
|
| 95 | + /** |
|
| 96 | + * @param string $organizationId |
|
| 97 | + * @return $this |
|
| 98 | + */ |
|
| 99 | + public function setOrganizationId($organizationId) |
|
| 100 | + { |
|
| 101 | + $this->organizationId = $organizationId; |
|
| 102 | 102 | |
| 103 | - return $this; |
|
| 104 | - } |
|
| 103 | + return $this; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 109 | - abstract public function endpoint(); |
|
| 106 | + /** |
|
| 107 | + * @return string |
|
| 108 | + */ |
|
| 109 | + abstract public function endpoint(); |
|
| 110 | 110 | } |
@@ -4,52 +4,52 @@ |
||
| 4 | 4 | |
| 5 | 5 | abstract class CrudEndpoint extends Endpoint |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * @param array $attributes |
|
| 9 | - * @return array |
|
| 10 | - */ |
|
| 11 | - public function create(array $attributes) |
|
| 12 | - { |
|
| 13 | - return $this |
|
| 14 | - ->getHttp() |
|
| 15 | - ->post( |
|
| 16 | - $this->makeRequestUrl(), |
|
| 17 | - $attributes, |
|
| 18 | - $this->getHeaders() |
|
| 19 | - ); |
|
| 20 | - } |
|
| 7 | + /** |
|
| 8 | + * @param array $attributes |
|
| 9 | + * @return array |
|
| 10 | + */ |
|
| 11 | + public function create(array $attributes) |
|
| 12 | + { |
|
| 13 | + return $this |
|
| 14 | + ->getHttp() |
|
| 15 | + ->post( |
|
| 16 | + $this->makeRequestUrl(), |
|
| 17 | + $attributes, |
|
| 18 | + $this->getHeaders() |
|
| 19 | + ); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @param string $itemId |
|
| 24 | - * @param array $attributes |
|
| 25 | - * @return mixed |
|
| 26 | - */ |
|
| 27 | - public function update($itemId, array $attributes) |
|
| 28 | - { |
|
| 29 | - return $this |
|
| 30 | - ->getHttp() |
|
| 31 | - ->put( |
|
| 32 | - $this->makeRequestUrl($itemId), |
|
| 33 | - $attributes, |
|
| 34 | - $this->getHeaders() |
|
| 35 | - ); |
|
| 36 | - } |
|
| 22 | + /** |
|
| 23 | + * @param string $itemId |
|
| 24 | + * @param array $attributes |
|
| 25 | + * @return mixed |
|
| 26 | + */ |
|
| 27 | + public function update($itemId, array $attributes) |
|
| 28 | + { |
|
| 29 | + return $this |
|
| 30 | + ->getHttp() |
|
| 31 | + ->put( |
|
| 32 | + $this->makeRequestUrl($itemId), |
|
| 33 | + $attributes, |
|
| 34 | + $this->getHeaders() |
|
| 35 | + ); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param string $itemId |
|
| 40 | - * @param bool $everywhere |
|
| 41 | - * @return mixed |
|
| 42 | - */ |
|
| 43 | - public function delete($itemId, $everywhere = false) |
|
| 44 | - { |
|
| 45 | - $params = $everywhere ? ['everywhere' => $everywhere] : []; |
|
| 38 | + /** |
|
| 39 | + * @param string $itemId |
|
| 40 | + * @param bool $everywhere |
|
| 41 | + * @return mixed |
|
| 42 | + */ |
|
| 43 | + public function delete($itemId, $everywhere = false) |
|
| 44 | + { |
|
| 45 | + $params = $everywhere ? ['everywhere' => $everywhere] : []; |
|
| 46 | 46 | |
| 47 | - return $this |
|
| 48 | - ->getHttp() |
|
| 49 | - ->delete( |
|
| 50 | - $this->makeRequestUrl($itemId), |
|
| 51 | - $params, |
|
| 52 | - $this->getHeaders() |
|
| 53 | - ); |
|
| 54 | - } |
|
| 47 | + return $this |
|
| 48 | + ->getHttp() |
|
| 49 | + ->delete( |
|
| 50 | + $this->makeRequestUrl($itemId), |
|
| 51 | + $params, |
|
| 52 | + $this->getHeaders() |
|
| 53 | + ); |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -17,43 +17,43 @@ |
||
| 17 | 17 | |
| 18 | 18 | class Favro |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @param string $login |
|
| 22 | - * @param string $password |
|
| 23 | - * @return Api |
|
| 24 | - */ |
|
| 25 | - public static function create($login, $password) |
|
| 26 | - { |
|
| 27 | - $httpClient = new GuzzleHttpClient( |
|
| 28 | - new Client(['auth' => [$login, $password]]) |
|
| 29 | - ); |
|
| 20 | + /** |
|
| 21 | + * @param string $login |
|
| 22 | + * @param string $password |
|
| 23 | + * @return Api |
|
| 24 | + */ |
|
| 25 | + public static function create($login, $password) |
|
| 26 | + { |
|
| 27 | + $httpClient = new GuzzleHttpClient( |
|
| 28 | + new Client(['auth' => [$login, $password]]) |
|
| 29 | + ); |
|
| 30 | 30 | |
| 31 | - return new Api( |
|
| 32 | - $httpClient, |
|
| 33 | - new Cards($httpClient), |
|
| 34 | - new Collections($httpClient), |
|
| 35 | - new Columns($httpClient), |
|
| 36 | - new Comments($httpClient), |
|
| 37 | - new Organizations($httpClient), |
|
| 38 | - new Tags($httpClient), |
|
| 39 | - new TaskLists($httpClient), |
|
| 40 | - new Tasks($httpClient), |
|
| 41 | - new Users($httpClient), |
|
| 42 | - new Widgets($httpClient) |
|
| 43 | - ); |
|
| 44 | - } |
|
| 31 | + return new Api( |
|
| 32 | + $httpClient, |
|
| 33 | + new Cards($httpClient), |
|
| 34 | + new Collections($httpClient), |
|
| 35 | + new Columns($httpClient), |
|
| 36 | + new Comments($httpClient), |
|
| 37 | + new Organizations($httpClient), |
|
| 38 | + new Tags($httpClient), |
|
| 39 | + new TaskLists($httpClient), |
|
| 40 | + new Tasks($httpClient), |
|
| 41 | + new Users($httpClient), |
|
| 42 | + new Widgets($httpClient) |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @codeCoverageIgnore |
|
| 48 | - */ |
|
| 49 | - private function __construct() |
|
| 50 | - { |
|
| 51 | - } |
|
| 46 | + /** |
|
| 47 | + * @codeCoverageIgnore |
|
| 48 | + */ |
|
| 49 | + private function __construct() |
|
| 50 | + { |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @codeCoverageIgnore |
|
| 55 | - */ |
|
| 56 | - private function __clone() |
|
| 57 | - { |
|
| 58 | - } |
|
| 53 | + /** |
|
| 54 | + * @codeCoverageIgnore |
|
| 55 | + */ |
|
| 56 | + private function __clone() |
|
| 57 | + { |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Comments extends CrudEndpoint |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * {@inheritdoc} |
|
| 9 | - */ |
|
| 10 | - public function endpoint() |
|
| 11 | - { |
|
| 12 | - return 'comments'; |
|
| 13 | - } |
|
| 7 | + /** |
|
| 8 | + * {@inheritdoc} |
|
| 9 | + */ |
|
| 10 | + public function endpoint() |
|
| 11 | + { |
|
| 12 | + return 'comments'; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class TaskLists extends CrudEndpoint |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * {@inheritdoc} |
|
| 9 | - */ |
|
| 10 | - public function endpoint() |
|
| 11 | - { |
|
| 12 | - return 'tasklists'; |
|
| 13 | - } |
|
| 7 | + /** |
|
| 8 | + * {@inheritdoc} |
|
| 9 | + */ |
|
| 10 | + public function endpoint() |
|
| 11 | + { |
|
| 12 | + return 'tasklists'; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -4,29 +4,29 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Widgets extends CrudEndpoint |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * @param string $itemId |
|
| 9 | - * @param string|null $collectionId |
|
| 10 | - * @return mixed |
|
| 11 | - */ |
|
| 12 | - public function delete($itemId, $collectionId = null) |
|
| 13 | - { |
|
| 14 | - $attributes = $collectionId ? ['collectionId' => $collectionId] : []; |
|
| 7 | + /** |
|
| 8 | + * @param string $itemId |
|
| 9 | + * @param string|null $collectionId |
|
| 10 | + * @return mixed |
|
| 11 | + */ |
|
| 12 | + public function delete($itemId, $collectionId = null) |
|
| 13 | + { |
|
| 14 | + $attributes = $collectionId ? ['collectionId' => $collectionId] : []; |
|
| 15 | 15 | |
| 16 | - return $this |
|
| 17 | - ->getHttp() |
|
| 18 | - ->delete( |
|
| 19 | - $this->makeRequestUrl($itemId), |
|
| 20 | - $attributes, |
|
| 21 | - $this->getHeaders() |
|
| 22 | - ); |
|
| 23 | - } |
|
| 16 | + return $this |
|
| 17 | + ->getHttp() |
|
| 18 | + ->delete( |
|
| 19 | + $this->makeRequestUrl($itemId), |
|
| 20 | + $attributes, |
|
| 21 | + $this->getHeaders() |
|
| 22 | + ); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * {@inheritdoc} |
|
| 27 | - */ |
|
| 28 | - public function endpoint() |
|
| 29 | - { |
|
| 30 | - return 'widgets'; |
|
| 31 | - } |
|
| 25 | + /** |
|
| 26 | + * {@inheritdoc} |
|
| 27 | + */ |
|
| 28 | + public function endpoint() |
|
| 29 | + { |
|
| 30 | + return 'widgets'; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Tasks extends CrudEndpoint |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * {@inheritdoc} |
|
| 9 | - */ |
|
| 10 | - public function endpoint() |
|
| 11 | - { |
|
| 12 | - return 'tasks'; |
|
| 13 | - } |
|
| 7 | + /** |
|
| 8 | + * {@inheritdoc} |
|
| 9 | + */ |
|
| 10 | + public function endpoint() |
|
| 11 | + { |
|
| 12 | + return 'tasks'; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Collections extends CrudEndpoint |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * {@inheritdoc} |
|
| 9 | - */ |
|
| 10 | - public function endpoint() |
|
| 11 | - { |
|
| 12 | - return 'collections'; |
|
| 13 | - } |
|
| 7 | + /** |
|
| 8 | + * {@inheritdoc} |
|
| 9 | + */ |
|
| 10 | + public function endpoint() |
|
| 11 | + { |
|
| 12 | + return 'collections'; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Tags extends CrudEndpoint |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * {@inheritdoc} |
|
| 9 | - */ |
|
| 10 | - public function endpoint() |
|
| 11 | - { |
|
| 12 | - return 'tags'; |
|
| 13 | - } |
|
| 7 | + /** |
|
| 8 | + * {@inheritdoc} |
|
| 9 | + */ |
|
| 10 | + public function endpoint() |
|
| 11 | + { |
|
| 12 | + return 'tags'; |
|
| 13 | + } |
|
| 14 | 14 | } |