PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.18
ووسلام – همگام سازی ووکامرس و باسلام v1.10.18
1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 1.8.7 1.8.4 All 51 releases
sync-basalam / includes / Services / BasalamAppStoreReview.php

BasalamAppStoreReview.php in ووسلام – همگام سازی ووکامرس و باسلام 1.10.18, at includes/Services/BasalamAppStoreReview.php

44 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SyncBasalam\Services;
4
5 use SyncBasalam\Config\Endpoints;
6 use SyncBasalam\Logger\Logger;
7
8 defined('ABSPATH') || exit;
9
10 class BasalamAppStoreReview
11 {
12 private string $BasalamAppReviewUrl;
13 private $apiService;
14
15 public function __construct()
16 {
17 $this->BasalamAppReviewUrl = Endpoints::APP_REVIEW;
18 $this->apiService = syncBasalamContainer()->get(ApiServiceManager::class);
19 }
20
21 public function createReview($comment, $rating = 5)
22 {
23 $rating = intval($rating);
24 if ($rating < 1) $rating = 1;
25 if ($rating > 5) $rating = 5;
26
27 $body = [
28 "comment" => $comment,
29 "rating" => $rating,
30 ];
31
32 try {
33 return $this->apiService->post($this->BasalamAppReviewUrl, $body);
34 } catch (\Exception $e) {
35 Logger::error('خطا در ثبت نظر افزونه: ' . $e->getMessage());
36 return [
37 'status_code' => 500,
38 'body' => null,
39 'error' => 'خطا در ثبت نظر: ' . $e->getMessage(),
40 ];
41 }
42 }
43 }
44