| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
abstract class CJTServicesClientModule { |
| 10 |
|
| 11 |
/** |
| 12 |
* put your comment there... |
| 13 |
* |
| 14 |
* @var WP_Error |
| 15 |
*/ |
| 16 |
private $response; |
| 17 |
|
| 18 |
/** |
| 19 |
* put your comment there... |
| 20 |
* |
| 21 |
* @var mixed |
| 22 |
*/ |
| 23 |
private $responseData; |
| 24 |
|
| 25 |
/** |
| 26 |
* put your comment there... |
| 27 |
* |
| 28 |
* @var mixed |
| 29 |
*/ |
| 30 |
private $servicesAPI; |
| 31 |
|
| 32 |
/** |
| 33 |
* put your comment there... |
| 34 |
* |
| 35 |
* @param mixed $extensionData |
| 36 |
* @return CJTProUpdateCheck |
| 37 |
*/ |
| 38 |
public function __construct() { |
| 39 |
# Get Services API instance |
| 40 |
$this->servicesAPI =& CJTServicesClient::getInstance(); |
| 41 |
# Obtain module name from $this class name with CJT prefix removed |
| 42 |
$this->moduleName = strtolower( substr( get_class( $this ), 3 ) ); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* put your comment there... |
| 47 |
* |
| 48 |
* @param mixed $name |
| 49 |
*/ |
| 50 |
protected function get($name) { |
| 51 |
return isset( $this->responseData[ $name ] ) ? $this->responseData[ $name ] : null; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* put your comment there... |
| 56 |
* |
| 57 |
*/ |
| 58 |
public function getModuleName() { |
| 59 |
return $this->moduleName; |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* put your comment there... |
| 64 |
* |
| 65 |
*/ |
| 66 |
public function getResponseData() { |
| 67 |
return $this->responseData; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* put your comment there... |
| 72 |
* |
| 73 |
*/ |
| 74 |
public function & getServicesAPI() { |
| 75 |
return $this->servicesAPI; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* put your comment there... |
| 80 |
* |
| 81 |
* @param mixed $json |
| 82 |
*/ |
| 83 |
protected function jsonDecode( $json ) { |
| 84 |
return json_decode( $json, true ); |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* put your comment there... |
| 89 |
* |
| 90 |
* @param mixed $method |
| 91 |
* @param mixed $params |
| 92 |
* @param mixed $postData |
| 93 |
*/ |
| 94 |
public function makeCall($method, $params = null, $postData = null) { |
| 95 |
# Reset response object |
| 96 |
$this->response = null; |
| 97 |
$this->responseData = null; |
| 98 |
# Dispatch and store response |
| 99 |
$this->response = $this->getServicesAPI()->makeCall( $this->getModuleName(), $method, $params, $postData ); |
| 100 |
# Read response data |
| 101 |
$this->responseData = wp_remote_retrieve_body( $this->response ); |
| 102 |
# Chain |
| 103 |
return $this; |
| 104 |
} |
| 105 |
|
| 106 |
} |
| 107 |
|