| 1 |
<?php |
| 2 |
namespace Manage\Classes; |
| 3 |
|
| 4 |
use ElementorOne\Connect\Classes\GrantTypes; |
| 5 |
use Manage\Modules\Connect\Module as Connect; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
|
| 11 |
class Lighthouse_Client extends Platform_Client { |
| 12 |
private static ?Lighthouse_Client $instance = null; |
| 13 |
|
| 14 |
protected static function get_api_path(): string { |
| 15 |
return apply_filters( 'manage/lighthouse_api_base_url', 'performance-metrics/api/v1/' ); |
| 16 |
} |
| 17 |
|
| 18 |
protected static function get_grant_type(): string { |
| 19 |
return GrantTypes::REFRESH_TOKEN; |
| 20 |
} |
| 21 |
|
| 22 |
public static function get_instance(): Lighthouse_Client { |
| 23 |
if ( ! self::$instance ) { |
| 24 |
self::$instance = new self(); |
| 25 |
} |
| 26 |
|
| 27 |
return self::$instance; |
| 28 |
} |
| 29 |
|
| 30 |
public function get_site_performance( array $categories = [ 'performance', 'seo', 'accessibility' ], bool $force = false ) { |
| 31 |
$connect_data = Connect::get_connect()->data(); |
| 32 |
$site_id = $connect_data->get_client_id(); |
| 33 |
|
| 34 |
return $this->make_request( |
| 35 |
'POST', |
| 36 |
'site-performance', |
| 37 |
[ |
| 38 |
'siteId' => $site_id, |
| 39 |
'categories' => $categories, |
| 40 |
'force' => $force, |
| 41 |
], |
| 42 |
[], |
| 43 |
true |
| 44 |
); |
| 45 |
} |
| 46 |
} |
| 47 |
|