| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Actions\Controller\ReviewActions; |
| 4 |
|
| 5 |
use SyncBasalam\Actions\Controller\ActionController; |
| 6 |
use SyncBasalam\Services\BasalamAppStoreReview; |
| 7 |
|
| 8 |
defined('ABSPATH') || exit; |
| 9 |
|
| 10 |
class SubmitReview extends ActionController |
| 11 |
{ |
| 12 |
public function __invoke() |
| 13 |
{ |
| 14 |
$comment = isset($this->request['sync_basalam_comment']) ? sanitize_textarea_field(wp_unslash($this->request['sync_basalam_comment'])) : null; |
| 15 |
$rating = isset($this->request['sync_basalam_rating']) ? intval($this->request['sync_basalam_rating']) : 5; |
| 16 |
|
| 17 |
$basalamReviewService = new BasalamAppStoreReview(); |
| 18 |
$review = $basalamReviewService->createReview($comment, $rating); |
| 19 |
|
| 20 |
if (isset($review['status_code']) && $review['status_code'] == 200) { |
| 21 |
update_option('sync_basalam_review_never_remind', true); |
| 22 |
} |
| 23 |
|
| 24 |
wp_send_json_success([ |
| 25 |
'review' => $review |
| 26 |
]); |
| 27 |
} |
| 28 |
} |
| 29 |
|