1 | <?php |
||
7 | class Waredesk |
||
8 | { |
||
9 | const PRODUCTION_API_URL = 'https://api.waredesk.com'; |
||
10 | |||
11 | /** |
||
12 | * @var Codes |
||
13 | */ |
||
14 | public $codes; |
||
15 | |||
16 | /** |
||
17 | * @var Products |
||
18 | */ |
||
19 | public $products; |
||
20 | |||
21 | private $apiUrl; |
||
22 | private $requestHandler; |
||
23 | |||
24 | 9 | public function __construct(string $clientId, string $clientSecret, string $accessToken = null) |
|
25 | { |
||
26 | 9 | $this->apiUrl = self::PRODUCTION_API_URL; |
|
27 | 9 | $this->requestHandler = new RequestHandler($clientId, $clientSecret, $accessToken, $this->apiUrl); |
|
28 | 9 | $this->products = new Products($this->requestHandler); |
|
29 | 9 | $this->codes = new Codes($this->requestHandler); |
|
30 | 9 | } |
|
31 | |||
32 | public function getApiUrl() |
||
36 | |||
37 | 9 | public function setApiUrl($apiUrl) |
|
38 | { |
||
39 | 9 | $this->apiUrl = rtrim($apiUrl, '/'); |
|
40 | 9 | $this->requestHandler->setApiUrl($this->apiUrl); |
|
41 | 9 | } |
|
42 | |||
43 | public function getClientId(): string |
||
47 | |||
48 | 1 | public function setClientId(string $clientId = null) |
|
49 | { |
||
50 | 1 | $this->requestHandler->setClientId($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 | return $this->requestHandler->getAccessToken(); |
|
67 | |||
68 | 9 | public function setAccessToken(string $accessToken = null) |
|
72 | |||
73 | 9 | public function setMockHandler(HandlerStack $mockHandler = null) |
|
77 | } |
||
78 |