1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Vindi; |
4
|
|
|
|
5
|
|
|
class Vindi |
|
|
|
|
6
|
|
|
{ |
7
|
|
|
|
8
|
|
|
private static $vindi_api_key; |
9
|
|
|
|
10
|
|
|
private static $vindi_api_uri; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* This Package SDK Version. |
15
|
|
|
* |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
public static $sdkVersion = '1.0.11'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* The Environment variable name for API URI. |
22
|
|
|
* |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
public static $apiUriEnvVar = 'VINDI_API_URI'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The Environment variable name for API Key. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
public static $apiKeyEnvVar = 'VINDI_API_KEY'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The Environment variable name for API Time Out. |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
public static $apiTimeOutEnvVar = 'VINDI_API_TIME_OUT'; |
40
|
|
|
|
41
|
430 |
|
|
42
|
|
|
/** |
43
|
430 |
|
* Vindi constructor. |
44
|
430 |
|
*/ |
45
|
|
|
private function __construct() |
46
|
|
|
{ |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Set API KEY |
52
|
|
|
* |
53
|
|
|
* @param $vindi_api_key |
54
|
432 |
|
*/ |
55
|
|
|
public static function setApiKey($vindi_api_key) |
56
|
432 |
|
{ |
57
|
|
|
if (null === self::$vindi_api_key) { |
58
|
|
|
self::$vindi_api_key = $vindi_api_key; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Set API URI |
64
|
430 |
|
* |
65
|
|
|
* @param $vindi_api_uri |
66
|
430 |
|
*/ |
67
|
430 |
|
public static function setApiUri($vindi_api_uri) |
68
|
|
|
{ |
69
|
|
|
if (null === self::$vindi_api_uri) { |
70
|
|
|
self::$vindi_api_uri = $vindi_api_uri; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get Vindi API URI from environment. |
76
|
|
|
* |
77
|
432 |
|
* @return string |
78
|
|
|
*/ |
79
|
432 |
|
public static function getApiUri() |
80
|
|
|
{ |
81
|
|
|
if (!empty(getenv(static::$apiUriEnvVar))) { |
82
|
|
|
return getenv(static::$apiUriEnvVar); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
if (null !== self::$vindi_api_uri) { |
86
|
|
|
return self::$vindi_api_uri; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
return 'https://app.vindi.com.br/api/v1/'; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get Vindi API Key from environment. |
94
|
|
|
* |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
public static function getApiKey() |
98
|
|
|
{ |
99
|
|
|
if (null !== self::$vindi_api_key) { |
100
|
|
|
return self::$vindi_api_key; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
return getenv(static::$apiKeyEnvVar); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Get Vindi API Time Out from environment. |
108
|
|
|
* |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
public static function getApiTimeOut() |
112
|
|
|
{ |
113
|
|
|
if (!empty(getenv(static::$apiTimeOutEnvVar))) { |
114
|
|
|
return getenv(static::$apiTimeOutEnvVar); |
115
|
|
|
} |
116
|
|
|
return 60; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Get CA Bundle Path. |
121
|
|
|
* |
122
|
|
|
* @return string |
123
|
|
|
*/ |
124
|
|
|
public static function getCertPath() |
125
|
|
|
{ |
126
|
|
|
return realpath(sprintf('%s/%s', dirname(__FILE__), '/../data/ssl/ca-bundle.crt')); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|