|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace seregazhuk\Favro\Api; |
|
4
|
|
|
|
|
5
|
|
|
use seregazhuk\Favro\Api\Endpoints\Cards; |
|
6
|
|
|
use seregazhuk\Favro\Api\Endpoints\Tasks; |
|
7
|
|
|
use seregazhuk\Favro\Api\Endpoints\Users; |
|
8
|
|
|
use seregazhuk\Favro\Api\Endpoints\Columns; |
|
9
|
|
|
use seregazhuk\Favro\Api\Endpoints\Widgets; |
|
10
|
|
|
use seregazhuk\Favro\Api\Endpoints\Endpoint; |
|
11
|
|
|
use seregazhuk\Favro\Api\Endpoints\Collections; |
|
12
|
|
|
use seregazhuk\Favro\Api\Endpoints\Organizations; |
|
13
|
|
|
use seregazhuk\Favro\Api\Endpoints\EndpointsContainer; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class Api |
|
17
|
|
|
* |
|
18
|
|
|
* @property Organizations $organizations |
|
19
|
|
|
* @property Users $users |
|
20
|
|
|
* @property Collections $collections |
|
21
|
|
|
* @property Widgets $widgets |
|
22
|
|
|
* @property Columns $columns |
|
23
|
|
|
* @property Cards $cards |
|
24
|
|
|
* @property Tasks $tasks |
|
25
|
|
|
*/ |
|
26
|
|
|
class Api |
|
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->resolveEndpoint($endpoint); |
|
53
|
|
|
|
|
54
|
|
|
if (method_exists($endpoint, 'setOrganizationId')) { |
|
55
|
|
|
$endpoint->setOrganizationId($this->organizationId); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
return $endpoint; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param int $organizationId |
|
63
|
|
|
* @return $this |
|
64
|
|
|
*/ |
|
65
|
|
|
public function setOrganization($organizationId) |
|
66
|
|
|
{ |
|
67
|
|
|
$this->organizationId = $organizationId; |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return string |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getOrganizationId() |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->organizationId; |
|
78
|
|
|
} |
|
79
|
|
|
} |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.