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 = false; |
||
12 | protected $verify_ssl = true; |
||
13 | |||
14 | public function __construct($token, $accountID) |
||
19 | |||
20 | public static function subscribeToWebhook($event, callable $callback) |
||
29 | |||
30 | public static function receiveWebhook($input = null) |
||
46 | |||
47 | protected static function processWebhook($input) |
||
60 | |||
61 | protected static function dispatchWebhookEvent($event, $data) |
||
72 | |||
73 | /** |
||
74 | * Make a GET request |
||
75 | * |
||
76 | * @param string $api_method API method to call |
||
77 | * @param array $args API arguments |
||
78 | * @param int $timeout Connection timeout (seconds) |
||
79 | * |
||
80 | * @return Response |
||
81 | * @throws DripException |
||
82 | */ |
||
83 | public function get($api_method, $args = [], $timeout = 10) |
||
87 | |||
88 | /** |
||
89 | * Make the HTTP request |
||
90 | * |
||
91 | * @param string $http_verb HTTP method used: get, post, delete |
||
92 | * @param string $api_method Drip API method to call |
||
93 | * @param array $args Array of arguments to the API method |
||
94 | * @param int $timeout Connection timeout (seconds) |
||
95 | * @param string $url Optional URL to override the constructed one |
||
96 | * |
||
97 | * @return Response |
||
98 | * @throws DripException |
||
99 | */ |
||
100 | protected function makeRequest($http_verb, $api_method, $args = [], $timeout = 10, $url = null) : Response |
||
156 | |||
157 | /** |
||
158 | * Make a GET request to a top-level method outside of this account |
||
159 | * |
||
160 | * @param string $api_method |
||
161 | * @param array $args |
||
162 | * @param int $timeout |
||
163 | * |
||
164 | * @return Response |
||
165 | * @throws DripException |
||
166 | */ |
||
167 | public function getGlobal($api_method, $args = [], $timeout = 10) |
||
172 | |||
173 | /** |
||
174 | * Make a POST request |
||
175 | * |
||
176 | * @param string $api_method API method |
||
177 | * @param array $args Arguments to API method |
||
178 | * @param int $timeout Connection timeout (seconds) |
||
179 | * |
||
180 | * @return Response |
||
181 | * @throws DripException |
||
182 | */ |
||
183 | public function post($api_method, $args = [], $timeout = 10) |
||
187 | |||
188 | /** |
||
189 | * Make a DELETE request |
||
190 | * |
||
191 | * @param string $api_method API method |
||
192 | * @param array $args Arguments to the API method |
||
193 | * @param int $timeout Connection timeout (seconds) |
||
194 | * |
||
195 | * @return Response |
||
196 | * @throws DripException |
||
197 | */ |
||
198 | public function delete($api_method, $args = [], $timeout = 10) |
||
202 | |||
203 | public function disableSSLVerification() |
||
207 | } |
||
208 |