1 | <?php |
||
5 | class Drip |
||
6 | { |
||
7 | protected static $eventSubscriptions = []; |
||
8 | protected static $receivedWebhook = false; |
||
9 | protected $api_endpoint = 'https://api.getdrip.com/v2'; |
||
10 | protected $token = false; |
||
11 | protected $accountID = null; |
||
12 | protected $verify_ssl = true; |
||
13 | |||
14 | /** |
||
15 | * Drip constructor. |
||
16 | * |
||
17 | * @param string $token API Token |
||
18 | * @param string|null $accountID Drip account ID to operate on |
||
19 | */ |
||
20 | public function __construct($token, $accountID = null) |
||
28 | |||
29 | public static function subscribeToWebhook($event, callable $callback) |
||
38 | |||
39 | public static function receiveWebhook($input = null) |
||
55 | |||
56 | protected static function processWebhook($input) |
||
69 | |||
70 | protected static function dispatchWebhookEvent($event, $data) |
||
81 | |||
82 | /** |
||
83 | * Set account ID if it was not passed into the constructor |
||
84 | * |
||
85 | * @param string $accountID |
||
86 | * |
||
87 | * @return bool |
||
88 | */ |
||
89 | public function setAccountId($accountID) : bool |
||
94 | |||
95 | /** |
||
96 | * Make a GET request |
||
97 | * |
||
98 | * @param string $api_method API method to call |
||
99 | * @param array $args API arguments |
||
100 | * @param int $timeout Connection timeout (seconds) |
||
101 | * |
||
102 | * @return Response |
||
103 | * @throws DripException |
||
104 | */ |
||
105 | public function get($api_method, $args = [], $timeout = 10) |
||
109 | |||
110 | /** |
||
111 | * Make the HTTP request |
||
112 | * |
||
113 | * @param string $http_verb HTTP method used: get, post, delete |
||
114 | * @param string $api_method Drip API method to call |
||
115 | * @param array $args Array of arguments to the API method |
||
116 | * @param int $timeout Connection timeout (seconds) |
||
117 | * @param string $url Optional URL to override the constructed one |
||
118 | * |
||
119 | * @return Response |
||
120 | * @throws DripException |
||
121 | */ |
||
122 | protected function makeRequest($http_verb, $api_method, $args = [], $timeout = 10, $url = null) |
||
174 | |||
175 | /** |
||
176 | * Check for required PHP functionality |
||
177 | * |
||
178 | * @return bool |
||
179 | * @throws DripException |
||
180 | */ |
||
181 | private function checkDependencies() |
||
189 | |||
190 | |||
191 | /** |
||
192 | * @param string|null $url |
||
193 | * @param string $api_method |
||
194 | * |
||
195 | * @return string |
||
196 | * @throws DripException |
||
197 | */ |
||
198 | private function constructRequestUrl($url, $api_method) |
||
210 | |||
211 | /** |
||
212 | * Make a GET request to a top-level method outside of this account |
||
213 | * |
||
214 | * @param string $api_method |
||
215 | * @param array $args |
||
216 | * @param int $timeout |
||
217 | * |
||
218 | * @return Response |
||
219 | * @throws DripException |
||
220 | */ |
||
221 | public function getGlobal($api_method, $args = [], $timeout = 10) |
||
226 | |||
227 | /** |
||
228 | * Make a POST request |
||
229 | * |
||
230 | * @param string $api_method API method |
||
231 | * @param array $args Arguments to API method |
||
232 | * @param int $timeout Connection timeout (seconds) |
||
233 | * |
||
234 | * @return Response |
||
235 | * @throws DripException |
||
236 | */ |
||
237 | public function post($api_method, $args = [], $timeout = 10) |
||
241 | |||
242 | /** |
||
243 | * Make a DELETE request |
||
244 | * |
||
245 | * @param string $api_method API method |
||
246 | * @param array $args Arguments to the API method |
||
247 | * @param int $timeout Connection timeout (seconds) |
||
248 | * |
||
249 | * @return Response |
||
250 | * @throws DripException |
||
251 | */ |
||
252 | public function delete($api_method, $args = [], $timeout = 10) |
||
256 | |||
257 | public function disableSSLVerification() |
||
261 | } |
||
262 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.