| 1 |
<?php |
| 2 |
namespace Enteraddons\Admin; |
| 3 |
|
| 4 |
/** |
| 5 |
* Enteraddons api config |
| 6 |
* |
| 7 |
* @package Enteraddons |
| 8 |
* @author ThemeLooks |
| 9 |
* @copyright 2022 ThemeLooks |
| 10 |
* @license GPL-2.0-or-later |
| 11 |
* |
| 12 |
* |
| 13 |
*/ |
| 14 |
|
| 15 |
class Admin_API { |
| 16 |
|
| 17 |
/** |
| 18 |
* $changelog_endpoint |
| 19 |
* @var string |
| 20 |
*/ |
| 21 |
private $changelog_endpoint; |
| 22 |
|
| 23 |
/** |
| 24 |
* call_api |
| 25 |
* @return array/object |
| 26 |
*/ |
| 27 |
public function call_api() { |
| 28 |
$url = $this->get_remote_url(); |
| 29 |
$data = wp_remote_request( $url, array( 'method' => 'GET' ) ); |
| 30 |
$body = wp_remote_retrieve_body( $data ); |
| 31 |
$getData = json_decode( $body, true ); |
| 32 |
return $getData; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* get_data |
| 37 |
* @param string $endpoint |
| 38 |
* @return void |
| 39 |
*/ |
| 40 |
public function get_data( $endpoint ) { |
| 41 |
$this->changelog_endpoint = $endpoint; |
| 42 |
return $this->call_api(); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* get_remote_url |
| 47 |
* @param $endpoint |
| 48 |
* @return void |
| 49 |
*/ |
| 50 |
public function get_remote_url() { |
| 51 |
$api = new \Enteraddons\Classes\API(); |
| 52 |
return $api->get_api_url( esc_html( $this->changelog_endpoint ) ); |
| 53 |
} |
| 54 |
|
| 55 |
} |
| 56 |
|