| 1 |
<?php |
| 2 |
/** |
| 3 |
* WooCommerce Routeapp API Client Class |
| 4 |
* |
| 5 |
* @link https://route.com/ |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @package Routeapp |
| 9 |
* @subpackage Routeapp/includes |
| 10 |
*/ |
| 11 |
|
| 12 |
class Routeapp_API_Compatibility extends Routeapp_API_Client |
| 13 |
{ |
| 14 |
|
| 15 |
const API_ENDPOINT = 'partner-integration/plugin-status'; |
| 16 |
const HTTP_SUCCESS_CODE = 200; |
| 17 |
|
| 18 |
/** |
| 19 |
* Send compatibility report |
| 20 |
* |
| 21 |
* @param $data |
| 22 |
* @return mixed |
| 23 |
*/ |
| 24 |
public function send($data) |
| 25 |
{ |
| 26 |
try { |
| 27 |
|
| 28 |
$response = $this->_make_private_api_call(self::API_ENDPOINT, $data, 'POST'); |
| 29 |
|
| 30 |
if (is_wp_error($response)) { |
| 31 |
throw new Exception("Compatibility endpoint has failed: " . $response->get_error_message()); |
| 32 |
} |
| 33 |
|
| 34 |
if (wp_remote_retrieve_response_code($response) != self::HTTP_SUCCESS_CODE) { |
| 35 |
throw new Exception("Compatibility endpoint returned an expected error code: " . wp_remote_retrieve_response_code($response)); |
| 36 |
} |
| 37 |
|
| 38 |
Route_Setup::set_setup_check_widget(Route_Setup::SETUP_CHECK_WIDGET_API_CALL); |
| 39 |
|
| 40 |
} catch (Exception $exception) { |
| 41 |
$routeapp_public = self::get_route_public_instance(); |
| 42 |
$routeapp_public->routeapp_log($exception, $this->_extraData); |
| 43 |
} |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
protected function isStorable() |
| 48 |
{ |
| 49 |
return false; |
| 50 |
} |
| 51 |
|
| 52 |
protected function enqueueOperation() |
| 53 |
{ |
| 54 |
return false; |
| 55 |
} |
| 56 |
} |
| 57 |
|