@@ -8,115 +8,115 @@ |
||
8 | 8 | |
9 | 9 | class GuzzleHttpAdapter implements HttpInterface |
10 | 10 | { |
11 | - /** |
|
12 | - * @var ClientInterface |
|
13 | - */ |
|
14 | - protected $client; |
|
15 | - |
|
16 | - /** |
|
17 | - * @param ClientInterface $client |
|
18 | - */ |
|
19 | - public function __construct(ClientInterface $client) |
|
20 | - { |
|
21 | - $this->client = $client; |
|
22 | - } |
|
23 | - |
|
24 | - /** |
|
25 | - * @param string $uri |
|
26 | - * @param array $params |
|
27 | - * @param array $headers |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function get($uri, $params = [], $headers = []) |
|
31 | - { |
|
32 | - if (!empty($params)) { |
|
33 | - $uri .= '?' . http_build_query($params); |
|
34 | - } |
|
35 | - |
|
36 | - $response = $this |
|
37 | - ->client |
|
38 | - ->get($uri, ['headers' => $headers]); |
|
39 | - |
|
40 | - return $this->parseResponse($response); |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * @param string $uri |
|
45 | - * @param array $body |
|
46 | - * @param array $headers |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function post($uri, $body = [], $headers = []) |
|
50 | - { |
|
51 | - $response = $this |
|
52 | - ->client |
|
53 | - ->post( |
|
54 | - $uri, [ |
|
55 | - 'headers' => $headers, |
|
56 | - 'form_params' => $body, |
|
57 | - ] |
|
58 | - ); |
|
59 | - |
|
60 | - return $this->parseResponse($response); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * @param string $uri |
|
65 | - * @param array $body |
|
66 | - * @param array $headers |
|
67 | - * @return mixed |
|
68 | - */ |
|
69 | - public function put($uri, $body = [], $headers = []) |
|
70 | - { |
|
71 | - $response = $this |
|
72 | - ->client |
|
73 | - ->put( |
|
74 | - $uri, [ |
|
75 | - 'headers' => $headers, |
|
76 | - 'form_params' => $body, |
|
77 | - ] |
|
78 | - ); |
|
79 | - |
|
80 | - return $this->parseResponse($response); |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @param string $uri |
|
85 | - * @param array $body |
|
86 | - * @param array $headers |
|
87 | - * @return mixed |
|
88 | - */ |
|
89 | - public function delete($uri, $body = [], $headers = []) |
|
90 | - { |
|
91 | - $response = $this |
|
92 | - ->client |
|
93 | - ->delete($uri, [ |
|
94 | - 'headers' => $headers, |
|
95 | - 'form_params' => $body, |
|
96 | - ]); |
|
97 | - |
|
98 | - return $this->parseResponse($response); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @param string $url |
|
103 | - * @return $this |
|
104 | - */ |
|
105 | - public function setBaseUrl($url) |
|
106 | - { |
|
107 | - $this->client->setBaseUrl($url); |
|
108 | - return $this; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @param ResponseInterface $response |
|
113 | - * @return array|null |
|
114 | - */ |
|
115 | - protected function parseResponse(ResponseInterface $response) |
|
116 | - { |
|
117 | - $responseContents = $response->getBody()->getContents(); |
|
118 | - |
|
119 | - return json_decode($responseContents, true); |
|
120 | - } |
|
11 | + /** |
|
12 | + * @var ClientInterface |
|
13 | + */ |
|
14 | + protected $client; |
|
15 | + |
|
16 | + /** |
|
17 | + * @param ClientInterface $client |
|
18 | + */ |
|
19 | + public function __construct(ClientInterface $client) |
|
20 | + { |
|
21 | + $this->client = $client; |
|
22 | + } |
|
23 | + |
|
24 | + /** |
|
25 | + * @param string $uri |
|
26 | + * @param array $params |
|
27 | + * @param array $headers |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function get($uri, $params = [], $headers = []) |
|
31 | + { |
|
32 | + if (!empty($params)) { |
|
33 | + $uri .= '?' . http_build_query($params); |
|
34 | + } |
|
35 | + |
|
36 | + $response = $this |
|
37 | + ->client |
|
38 | + ->get($uri, ['headers' => $headers]); |
|
39 | + |
|
40 | + return $this->parseResponse($response); |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * @param string $uri |
|
45 | + * @param array $body |
|
46 | + * @param array $headers |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function post($uri, $body = [], $headers = []) |
|
50 | + { |
|
51 | + $response = $this |
|
52 | + ->client |
|
53 | + ->post( |
|
54 | + $uri, [ |
|
55 | + 'headers' => $headers, |
|
56 | + 'form_params' => $body, |
|
57 | + ] |
|
58 | + ); |
|
59 | + |
|
60 | + return $this->parseResponse($response); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * @param string $uri |
|
65 | + * @param array $body |
|
66 | + * @param array $headers |
|
67 | + * @return mixed |
|
68 | + */ |
|
69 | + public function put($uri, $body = [], $headers = []) |
|
70 | + { |
|
71 | + $response = $this |
|
72 | + ->client |
|
73 | + ->put( |
|
74 | + $uri, [ |
|
75 | + 'headers' => $headers, |
|
76 | + 'form_params' => $body, |
|
77 | + ] |
|
78 | + ); |
|
79 | + |
|
80 | + return $this->parseResponse($response); |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @param string $uri |
|
85 | + * @param array $body |
|
86 | + * @param array $headers |
|
87 | + * @return mixed |
|
88 | + */ |
|
89 | + public function delete($uri, $body = [], $headers = []) |
|
90 | + { |
|
91 | + $response = $this |
|
92 | + ->client |
|
93 | + ->delete($uri, [ |
|
94 | + 'headers' => $headers, |
|
95 | + 'form_params' => $body, |
|
96 | + ]); |
|
97 | + |
|
98 | + return $this->parseResponse($response); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @param string $url |
|
103 | + * @return $this |
|
104 | + */ |
|
105 | + public function setBaseUrl($url) |
|
106 | + { |
|
107 | + $this->client->setBaseUrl($url); |
|
108 | + return $this; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @param ResponseInterface $response |
|
113 | + * @return array|null |
|
114 | + */ |
|
115 | + protected function parseResponse(ResponseInterface $response) |
|
116 | + { |
|
117 | + $responseContents = $response->getBody()->getContents(); |
|
118 | + |
|
119 | + return json_decode($responseContents, true); |
|
120 | + } |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | \ No newline at end of file |
@@ -25,86 +25,86 @@ |
||
25 | 25 | */ |
26 | 26 | class Api |
27 | 27 | { |
28 | - /** |
|
29 | - * @var EndpointsContainer |
|
30 | - */ |
|
31 | - protected $endpointsContainer; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - protected $organizationId; |
|
37 | - |
|
38 | - public function __construct(EndpointsContainer $endpointsContainer) |
|
39 | - { |
|
40 | - $this->endpointsContainer = $endpointsContainer; |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Magic method to access different endpoints. |
|
45 | - * |
|
46 | - * @param string $endpoint |
|
47 | - * |
|
48 | - * @return Endpoint |
|
49 | - */ |
|
50 | - public function __get($endpoint) |
|
51 | - { |
|
52 | - $endpoint = $this->endpointsContainer->resolve($endpoint); |
|
53 | - |
|
54 | - if (method_exists($endpoint, 'setOrganizationId')) { |
|
55 | - $endpoint->setOrganizationId($this->organizationId); |
|
56 | - } |
|
57 | - |
|
58 | - return $endpoint; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @param $organizationName |
|
63 | - * @return $this |
|
64 | - */ |
|
65 | - public function setOrganization($organizationName) |
|
66 | - { |
|
67 | - if($organization = $this->getOrganizationByName($organizationName)) { |
|
68 | - $this->setOrganizationId($organization['organizationId']); |
|
69 | - } |
|
70 | - |
|
71 | - return $this; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @param int $organizationId |
|
76 | - * @return $this |
|
77 | - */ |
|
78 | - public function setOrganizationId($organizationId) |
|
79 | - { |
|
80 | - $this->organizationId = $organizationId; |
|
81 | - |
|
82 | - return $this; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function getOrganizationId() |
|
90 | - { |
|
91 | - return $this->organizationId; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * @param $organization |
|
96 | - * @return bool|array |
|
97 | - */ |
|
98 | - protected function getOrganizationByName($organization) |
|
99 | - { |
|
100 | - $organizations = $this->organizations->getAll(); |
|
101 | - |
|
102 | - foreach ($organizations['entities'] as $entity) { |
|
103 | - if ($entity['name'] == $organization) { |
|
104 | - return $organization; |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - return false; |
|
109 | - } |
|
28 | + /** |
|
29 | + * @var EndpointsContainer |
|
30 | + */ |
|
31 | + protected $endpointsContainer; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + protected $organizationId; |
|
37 | + |
|
38 | + public function __construct(EndpointsContainer $endpointsContainer) |
|
39 | + { |
|
40 | + $this->endpointsContainer = $endpointsContainer; |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Magic method to access different endpoints. |
|
45 | + * |
|
46 | + * @param string $endpoint |
|
47 | + * |
|
48 | + * @return Endpoint |
|
49 | + */ |
|
50 | + public function __get($endpoint) |
|
51 | + { |
|
52 | + $endpoint = $this->endpointsContainer->resolve($endpoint); |
|
53 | + |
|
54 | + if (method_exists($endpoint, 'setOrganizationId')) { |
|
55 | + $endpoint->setOrganizationId($this->organizationId); |
|
56 | + } |
|
57 | + |
|
58 | + return $endpoint; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @param $organizationName |
|
63 | + * @return $this |
|
64 | + */ |
|
65 | + public function setOrganization($organizationName) |
|
66 | + { |
|
67 | + if($organization = $this->getOrganizationByName($organizationName)) { |
|
68 | + $this->setOrganizationId($organization['organizationId']); |
|
69 | + } |
|
70 | + |
|
71 | + return $this; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @param int $organizationId |
|
76 | + * @return $this |
|
77 | + */ |
|
78 | + public function setOrganizationId($organizationId) |
|
79 | + { |
|
80 | + $this->organizationId = $organizationId; |
|
81 | + |
|
82 | + return $this; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function getOrganizationId() |
|
90 | + { |
|
91 | + return $this->organizationId; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * @param $organization |
|
96 | + * @return bool|array |
|
97 | + */ |
|
98 | + protected function getOrganizationByName($organization) |
|
99 | + { |
|
100 | + $organizations = $this->organizations->getAll(); |
|
101 | + |
|
102 | + foreach ($organizations['entities'] as $entity) { |
|
103 | + if ($entity['name'] == $organization) { |
|
104 | + return $organization; |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + return false; |
|
109 | + } |
|
110 | 110 | } |
111 | 111 | \ No newline at end of file |
@@ -64,7 +64,7 @@ |
||
64 | 64 | */ |
65 | 65 | public function setOrganization($organizationName) |
66 | 66 | { |
67 | - if($organization = $this->getOrganizationByName($organizationName)) { |
|
67 | + if ($organization = $this->getOrganizationByName($organizationName)) { |
|
68 | 68 | $this->setOrganizationId($organization['organizationId']); |
69 | 69 | } |
70 | 70 |
@@ -8,10 +8,10 @@ |
||
8 | 8 | class Comments extends Endpoint |
9 | 9 | { |
10 | 10 | |
11 | - use CrudEndpoint, BelongsToOrganization; |
|
11 | + use CrudEndpoint, BelongsToOrganization; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $endpoint = 'comments'; |
|
13 | + /** |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $endpoint = 'comments'; |
|
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -8,10 +8,10 @@ |
||
8 | 8 | class Tasks extends Endpoint |
9 | 9 | { |
10 | 10 | |
11 | - use BelongsToOrganization, CrudEndpoint; |
|
11 | + use BelongsToOrganization, CrudEndpoint; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $endpoint = 'tasks'; |
|
13 | + /** |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $endpoint = 'tasks'; |
|
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -8,35 +8,35 @@ |
||
8 | 8 | class Cards extends Endpoint |
9 | 9 | { |
10 | 10 | |
11 | - use BelongsToOrganization, CrudEndpoint; |
|
11 | + use BelongsToOrganization, CrudEndpoint; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $endpoint = 'cards'; |
|
13 | + /** |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $endpoint = 'cards'; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @param string $widgetCommonId |
|
20 | - * @return mixed |
|
21 | - */ |
|
22 | - public function getAll($widgetCommonId) |
|
23 | - { |
|
24 | - return parent::getAll(['widgetCommonId'=>$widgetCommonId]); |
|
25 | - } |
|
18 | + /** |
|
19 | + * @param string $widgetCommonId |
|
20 | + * @return mixed |
|
21 | + */ |
|
22 | + public function getAll($widgetCommonId) |
|
23 | + { |
|
24 | + return parent::getAll(['widgetCommonId'=>$widgetCommonId]); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @param string $cardId |
|
29 | - * @param bool $everywhere |
|
30 | - * @return mixed |
|
31 | - */ |
|
32 | - public function delete($cardId, $everywhere) |
|
33 | - { |
|
34 | - return $this |
|
35 | - ->getHttp() |
|
36 | - ->delete( |
|
37 | - $this->makeRequestUrl($cardId), |
|
38 | - ['everywhere' => $everywhere], |
|
39 | - $this->getHeaders() |
|
40 | - ); |
|
41 | - } |
|
27 | + /** |
|
28 | + * @param string $cardId |
|
29 | + * @param bool $everywhere |
|
30 | + * @return mixed |
|
31 | + */ |
|
32 | + public function delete($cardId, $everywhere) |
|
33 | + { |
|
34 | + return $this |
|
35 | + ->getHttp() |
|
36 | + ->delete( |
|
37 | + $this->makeRequestUrl($cardId), |
|
38 | + ['everywhere' => $everywhere], |
|
39 | + $this->getHeaders() |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -8,10 +8,10 @@ |
||
8 | 8 | class TaskLists extends Endpoint |
9 | 9 | { |
10 | 10 | |
11 | - use CrudEndpoint, BelongsToOrganization; |
|
11 | + use CrudEndpoint, BelongsToOrganization; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $endpoint = 'tasklists'; |
|
13 | + /** |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $endpoint = 'tasklists'; |
|
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -9,10 +9,10 @@ |
||
9 | 9 | class Columns extends Endpoint |
10 | 10 | { |
11 | 11 | |
12 | - use BelongsToOrganization, CrudEndpoint; |
|
12 | + use BelongsToOrganization, CrudEndpoint; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $endpoint = 'columns'; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $endpoint = 'columns'; |
|
18 | 18 | } |
19 | 19 | \ No newline at end of file |