1 | <?php |
||
5 | class Vindi |
||
|
|||
6 | { |
||
7 | /** |
||
8 | * The Environment variable name or argument for API URI. |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | const VINDI_API_URI = 'VINDI_API_URI'; |
||
13 | |||
14 | /** |
||
15 | * The Environment variable name or argument for API Key. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | const VINDI_API_KEY = 'VINDI_API_KEY'; |
||
20 | |||
21 | /** |
||
22 | * API KEY to be set on instances |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | private static $vindi_api_key; |
||
27 | |||
28 | /** |
||
29 | * URI to be set on instances |
||
30 | * Ex.: https://sandbox-app.vindi.com.br/api/v1/ |
||
31 | * |
||
32 | * @var string; |
||
33 | */ |
||
34 | private static $vindi_api_uri; |
||
35 | |||
36 | /** |
||
37 | * This Package SDK Version. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | public static $sdkVersion = '1.1.0'; |
||
42 | |||
43 | /** |
||
44 | * The Environment variable name for API Time Out. |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | public static $apiTimeOutEnvVar = 'VINDI_API_TIME_OUT'; |
||
49 | |||
50 | /** |
||
51 | * Vindi constructor. |
||
52 | */ |
||
53 | private function __construct() |
||
56 | |||
57 | /** |
||
58 | * Set API KEY |
||
59 | * |
||
60 | * @param $vindi_api_key |
||
61 | */ |
||
62 | 2 | public static function setApiKey($vindi_api_key) |
|
68 | |||
69 | /** |
||
70 | * Set API URI |
||
71 | * |
||
72 | * @param $vindi_api_uri |
||
73 | */ |
||
74 | 2 | public static function setApiUri($vindi_api_uri) |
|
80 | |||
81 | /** |
||
82 | * Get Vindi API URI from environment. |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 432 | public static function getApiUri() |
|
87 | { |
||
88 | 432 | if (null !== self::$vindi_api_uri) { |
|
89 | 2 | return self::$vindi_api_uri; |
|
90 | } |
||
91 | |||
92 | 432 | if (!empty(getenv(static::VINDI_API_URI))) { |
|
93 | 2 | return getenv(static::VINDI_API_URI); |
|
94 | } |
||
95 | |||
96 | 432 | return 'https://app.vindi.com.br/api/v1/'; |
|
97 | } |
||
98 | |||
99 | /** |
||
100 | * Get Vindi API Key from environment. |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | 432 | public static function getApiKey() |
|
112 | |||
113 | /** |
||
114 | * Get Vindi API Time Out from environment. |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | 432 | public static function getApiTimeOut() |
|
119 | { |
||
120 | 432 | if (empty(getenv(static::$apiTimeOutEnvVar))) { |
|
121 | 432 | return 60; |
|
122 | } |
||
123 | 2 | return getenv(static::$apiTimeOutEnvVar); |
|
124 | } |
||
125 | |||
126 | /** |
||
127 | * Get CA Bundle Path. |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | 432 | public static function getCertPath() |
|
135 | } |
||
136 |