| 1 |
<?php |
| 2 |
|
| 3 |
namespace Cookiez\Modules\Reviews\Classes; |
| 4 |
|
| 5 |
use Cookiez\Classes\Services\Client; |
| 6 |
use Exception; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly |
| 10 |
} |
| 11 |
|
| 12 |
class Feedback_Client { |
| 13 |
|
| 14 |
private const SERVICE_ENDPOINT = 'feedback/reviews'; |
| 15 |
|
| 16 |
/** |
| 17 |
* Send request to the service to submit the feedback. |
| 18 |
* |
| 19 |
* @param array<string, mixed> $params Request payload. |
| 20 |
* |
| 21 |
* @return mixed |
| 22 |
* @throws Exception When the request fails. |
| 23 |
*/ |
| 24 |
public static function post_feedback( $params ) { |
| 25 |
$response = Client::get_instance()->make_request( |
| 26 |
'POST', |
| 27 |
self::SERVICE_ENDPOINT, |
| 28 |
$params |
| 29 |
); |
| 30 |
|
| 31 |
if ( empty( $response ) || is_wp_error( $response ) ) { |
| 32 |
throw new Exception( 'Failed to add the feedback.' ); |
| 33 |
} |
| 34 |
|
| 35 |
return $response; |
| 36 |
} |
| 37 |
} |
| 38 |
|