| 1 |
<?php |
| 2 |
|
| 3 |
namespace ReviewX\Rest\Controllers; |
| 4 |
|
| 5 |
\defined("ABSPATH") || exit; |
| 6 |
use ReviewX\Services\DashboardServices; |
| 7 |
use ReviewX\Utilities\Helper; |
| 8 |
use Throwable; |
| 9 |
use ReviewX\WPDrill\Contracts\InvokableContract; |
| 10 |
use ReviewX\WPDrill\Response; |
| 11 |
class DashboardController implements InvokableContract |
| 12 |
{ |
| 13 |
protected $dashboardServices; |
| 14 |
/** |
| 15 |
* |
| 16 |
*/ |
| 17 |
public function __construct(DashboardServices $dashboardServices) |
| 18 |
{ |
| 19 |
$this->dashboardServices = $dashboardServices; |
| 20 |
} |
| 21 |
/** |
| 22 |
* @return void |
| 23 |
*/ |
| 24 |
public function __invoke() |
| 25 |
{ |
| 26 |
} |
| 27 |
/** |
| 28 |
* @return Response |
| 29 |
*/ |
| 30 |
public function insight() |
| 31 |
{ |
| 32 |
$resp = $this->dashboardServices->insight(); |
| 33 |
return Helper::getApiResponse($resp); |
| 34 |
} |
| 35 |
/** |
| 36 |
* @return Response |
| 37 |
*/ |
| 38 |
public function requestEmail() |
| 39 |
{ |
| 40 |
$resp = $this->dashboardServices->requestEmail(); |
| 41 |
return Helper::getApiResponse($resp); |
| 42 |
} |
| 43 |
/** |
| 44 |
* Orders list (with review-request status) for the Review Reminder "Orders" tab. |
| 45 |
* |
| 46 |
* @param $request |
| 47 |
* @return Response |
| 48 |
*/ |
| 49 |
public function orders($request) |
| 50 |
{ |
| 51 |
$resp = $this->dashboardServices->orders($request->get_params()); |
| 52 |
return Helper::getApiResponse($resp); |
| 53 |
} |
| 54 |
/** |
| 55 |
* @return \WPDrill\Response |
| 56 |
*/ |
| 57 |
public function requestUserData() |
| 58 |
{ |
| 59 |
try { |
| 60 |
$response = $this->dashboardServices->requestUserData(); |
| 61 |
return Helper::rvxApi($response)->success('Site data Retrieved Successfully'); |
| 62 |
} catch (Throwable $e) { |
| 63 |
return Helper::rvxApi(['error' => $e->getMessage()])->fails('Site data Retrieval Failed', $e->getCode()); |
| 64 |
} |
| 65 |
} |
| 66 |
/** |
| 67 |
* @param $request |
| 68 |
* @return Response |
| 69 |
*/ |
| 70 |
public function chart($request) |
| 71 |
{ |
| 72 |
$resp = $this->dashboardServices->chart($request->get_params()); |
| 73 |
return Helper::getApiResponse($resp); |
| 74 |
} |
| 75 |
} |
| 76 |
|