|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Waredesk; |
|
4
|
|
|
|
|
5
|
|
|
use GuzzleHttp\HandlerStack; |
|
6
|
|
|
|
|
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
|
|
|
|
|
19
|
7 |
|
public function __construct(string $clientId, string $clientSecret, string $accessToken = null) |
|
20
|
|
|
{ |
|
21
|
7 |
|
$this->apiUrl = self::PRODUCTION_API_URL; |
|
22
|
7 |
|
$this->requestHandler = new RequestHandler($clientId, $clientSecret, $accessToken, $this->apiUrl); |
|
23
|
7 |
|
$this->products = new Products($this->requestHandler); |
|
24
|
7 |
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function getApiUrl() |
|
27
|
|
|
{ |
|
28
|
|
|
return $this->apiUrl; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
7 |
|
public function setApiUrl($apiUrl) |
|
32
|
|
|
{ |
|
33
|
7 |
|
$this->apiUrl = rtrim($apiUrl, '/'); |
|
34
|
7 |
|
$this->requestHandler->setApiUrl($this->apiUrl); |
|
35
|
7 |
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function getClientId(): string |
|
38
|
|
|
{ |
|
39
|
|
|
return $this->requestHandler->getClientId(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function setClientId(string $clientId = null) |
|
43
|
|
|
{ |
|
44
|
1 |
|
$this->requestHandler->setClientId($clientId); |
|
45
|
1 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function getClientSecret(): string |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->requestHandler->getClientSecret(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function setClientSecret(string $clientSecret = null) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->requestHandler->setClientSecret($clientSecret); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
2 |
|
public function getAccessToken(): string |
|
58
|
|
|
{ |
|
59
|
2 |
|
return $this->requestHandler->getAccessToken(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
7 |
|
public function setAccessToken(string $accessToken = null) |
|
63
|
|
|
{ |
|
64
|
7 |
|
$this->requestHandler->setAccessToken($accessToken); |
|
65
|
7 |
|
} |
|
66
|
|
|
|
|
67
|
7 |
|
public function setMockHandler(HandlerStack $mockHandler = null) |
|
68
|
|
|
{ |
|
69
|
7 |
|
$this->requestHandler->setMockHandler($mockHandler); |
|
70
|
7 |
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|