|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace WrapIt; |
|
4
|
|
|
|
|
5
|
|
|
use WrapIt\Exceptions\WrapItParameterException; |
|
6
|
|
|
use WrapIt\Http\WrapItApiRequester; |
|
7
|
|
|
use WrapIt\Helpers\WrapItLoginHelper; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class WrapIt |
|
11
|
|
|
* |
|
12
|
|
|
* @package WrapIt |
|
13
|
|
|
*/ |
|
14
|
|
|
class WrapIt { |
|
15
|
|
|
|
|
16
|
|
|
private $config; |
|
17
|
|
|
|
|
18
|
|
|
private $server_uri; |
|
19
|
|
|
|
|
20
|
|
|
private $sdk_version = "0.1"; |
|
|
|
|
|
|
21
|
|
|
private $public_key = null; |
|
22
|
|
|
private $private_key = null; |
|
23
|
|
|
private $domain = null; |
|
24
|
|
|
|
|
25
|
|
|
private $requester = null; |
|
26
|
|
|
|
|
27
|
78 |
|
public function __construct($config) { |
|
28
|
78 |
|
$this->config = array_merge(array( |
|
29
|
78 |
|
"domain" => null, |
|
30
|
39 |
|
"client_id" => null, |
|
31
|
|
|
"client_secret" => null |
|
32
|
78 |
|
), $config); |
|
33
|
|
|
|
|
34
|
78 |
|
if ($this->config["domain"] == null) { |
|
35
|
12 |
|
throw new WrapItParameterException("config[domain] is required but missing"); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
66 |
|
if ($this->config["client_id"] == null) { |
|
39
|
12 |
|
throw new WrapItParameterException("config[client_id] is required but missing"); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
54 |
|
if ($this->config["client_secret"] == null) { |
|
43
|
6 |
|
throw new WrapItParameterException("config[client_secret] is required but missing"); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
48 |
|
$this->config["domain"] = str_replace("https://", "", $this->config["domain"]); |
|
47
|
48 |
|
$this->config["domain"] = str_replace("http://", "", $this->config["domain"]); |
|
48
|
48 |
|
$this->config["domain"] = rtrim($this->config["domain"], "/"); |
|
49
|
48 |
|
$this->server_uri = "https://" . $this->config["domain"]; |
|
50
|
|
|
|
|
51
|
48 |
|
$this->domain = $this->config["domain"]; |
|
52
|
48 |
|
$this->public_key = $this->config["client_id"]; |
|
53
|
48 |
|
$this->private_key = $this->config["client_secret"]; |
|
54
|
|
|
|
|
55
|
48 |
|
$this->requester = new WrapItApiRequester($this->config["domain"]); |
|
56
|
48 |
|
} |
|
57
|
|
|
|
|
58
|
42 |
|
public function getClientId() { |
|
59
|
42 |
|
return $this->public_key; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
36 |
|
public function getClientSecret() { |
|
63
|
36 |
|
return $this->private_key; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
36 |
|
public function getDomain() { |
|
67
|
36 |
|
return $this->domain; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.