1 | <?php |
||
7 | class Waredesk |
||
8 | { |
||
9 | const PRODUCTION_API_URL = 'https://api.waredesk.com'; |
||
10 | |||
11 | /** |
||
12 | * @var Products |
||
13 | */ |
||
14 | public $products; |
||
15 | |||
16 | private $apiUrl; |
||
17 | private $requestHandler; |
||
18 | private $clientId; |
||
19 | private $clientSecret; |
||
20 | private $accessToken; |
||
21 | |||
22 | 5 | public function __construct(string $clientId, string $clientSecret, string $accessToken = null) |
|
23 | { |
||
24 | 5 | $this->apiUrl = self::PRODUCTION_API_URL; |
|
25 | 5 | $this->requestHandler = new RequestHandler($accessToken, $this->apiUrl); |
|
26 | 5 | $this->clientId = $clientId; |
|
27 | 5 | $this->clientSecret = $clientSecret; |
|
28 | 5 | $this->accessToken = $accessToken; |
|
29 | 5 | $this->products = new Products($this->requestHandler); |
|
30 | 5 | } |
|
31 | |||
32 | public function getApiUrl() |
||
36 | |||
37 | 5 | public function setApiUrl($apiUrl) |
|
38 | { |
||
39 | 5 | $this->apiUrl = rtrim($apiUrl, '/'); |
|
40 | 5 | $this->requestHandler->setApiUrl($this->apiUrl); |
|
41 | 5 | } |
|
42 | |||
43 | public function getClientId(): string |
||
47 | |||
48 | 1 | public function setClientId(string $clientId = null) |
|
49 | { |
||
50 | 1 | $this->clientId = $clientId; |
|
51 | 1 | } |
|
52 | |||
53 | public function getClientSecret(): string |
||
57 | |||
58 | public function setClientSecret(string $clientSecret = null) |
||
62 | |||
63 | 2 | public function getAccessToken(): string |
|
64 | { |
||
65 | 2 | if (null !== $this->accessToken) { |
|
80 | |||
81 | 5 | public function setAccessToken(string $accessToken = null) |
|
86 | |||
87 | 5 | public function setMockHandler(HandlerStack $mockHandler = null) |
|
91 | } |
||
92 |