|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jenschude <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Review; |
|
7
|
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\CreatedBy; |
|
9
|
|
|
use Commercetools\Core\Model\Common\LastModifiedBy; |
|
10
|
|
|
use Commercetools\Core\Model\Common\Resource; |
|
11
|
|
|
use Commercetools\Core\Model\Common\DateTimeDecorator; |
|
12
|
|
|
use Commercetools\Core\Model\State\StateReference; |
|
13
|
|
|
use Commercetools\Core\Model\Common\ResourceIdentifier; |
|
14
|
|
|
use Commercetools\Core\Model\Customer\CustomerReference; |
|
15
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObject; |
|
16
|
|
|
use DateTime; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @package Commercetools\Core\Model\Review |
|
20
|
|
|
* @link https://docs.commercetools.com/http-api-projects-reviews.html#review |
|
21
|
|
|
* @method string getId() |
|
22
|
|
|
* @method Review setId(string $id = null) |
|
23
|
|
|
* @method int getVersion() |
|
24
|
|
|
* @method Review setVersion(int $version = null) |
|
25
|
|
|
* @method DateTimeDecorator getCreatedAt() |
|
26
|
|
|
* @method Review setCreatedAt(DateTime $createdAt = null) |
|
27
|
|
|
* @method DateTimeDecorator getLastModifiedAt() |
|
28
|
|
|
* @method Review setLastModifiedAt(DateTime $lastModifiedAt = null) |
|
29
|
|
|
* @method string getProductId() |
|
30
|
|
|
* @method Review setProductId(string $productId = null) |
|
31
|
|
|
* @method string getCustomerId() |
|
32
|
|
|
* @method Review setCustomerId(string $customerId = null) |
|
33
|
|
|
* @method string getAuthorName() |
|
34
|
|
|
* @method Review setAuthorName(string $authorName = null) |
|
35
|
|
|
* @method string getTitle() |
|
36
|
|
|
* @method Review setTitle(string $title = null) |
|
37
|
|
|
* @method string getText() |
|
38
|
|
|
* @method Review setText(string $text = null) |
|
39
|
|
|
* @method float getScore() |
|
40
|
|
|
* @method Review setScore(float $score = null) |
|
41
|
|
|
* @method StateReference getState() |
|
42
|
|
|
* @method Review setState(StateReference $state = null) |
|
43
|
|
|
* @method string getKey() |
|
44
|
|
|
* @method Review setKey(string $key = null) |
|
45
|
|
|
* @method string getUniquenessValue() |
|
46
|
|
|
* @method Review setUniquenessValue(string $uniquenessValue = null) |
|
47
|
|
|
* @method string getLocale() |
|
48
|
|
|
* @method Review setLocale(string $locale = null) |
|
49
|
|
|
* @method ResourceIdentifier getTarget() |
|
50
|
|
|
* @method Review setTarget(ResourceIdentifier $target = null) |
|
51
|
|
|
* @method int getRating() |
|
52
|
|
|
* @method Review setRating(int $rating = null) |
|
53
|
|
|
* @method bool getIncludedInStatistics() |
|
54
|
|
|
* @method Review setIncludedInStatistics(bool $includedInStatistics = null) |
|
55
|
|
|
* @method CustomerReference getCustomer() |
|
56
|
|
|
* @method Review setCustomer(CustomerReference $customer = null) |
|
57
|
|
|
* @method CustomFieldObject getCustom() |
|
58
|
|
|
* @method Review setCustom(CustomFieldObject $custom = null) |
|
59
|
|
|
* @method CreatedBy getCreatedBy() |
|
60
|
|
|
* @method Review setCreatedBy(CreatedBy $createdBy = null) |
|
61
|
|
|
* @method LastModifiedBy getLastModifiedBy() |
|
62
|
|
|
* @method Review setLastModifiedBy(LastModifiedBy $lastModifiedBy = null) |
|
63
|
|
|
*/ |
|
64
|
|
|
class Review extends Resource |
|
65
|
|
|
{ |
|
66
|
18 |
|
public function fieldDefinitions() |
|
67
|
|
|
{ |
|
68
|
|
|
return [ |
|
69
|
18 |
|
'id' => [static::TYPE => 'string'], |
|
70
|
18 |
|
'version' => [static::TYPE => 'int'], |
|
71
|
|
|
'createdAt' => [ |
|
72
|
18 |
|
static::TYPE => DateTime::class, |
|
73
|
18 |
|
static::DECORATOR => DateTimeDecorator::class |
|
74
|
|
|
], |
|
75
|
|
|
'lastModifiedAt' => [ |
|
76
|
18 |
|
static::TYPE => DateTime::class, |
|
77
|
18 |
|
static::DECORATOR => DateTimeDecorator::class |
|
78
|
|
|
], |
|
79
|
18 |
|
'key' => [static::TYPE => 'string'], |
|
80
|
18 |
|
'uniquenessValue' => [static::TYPE => 'string'], |
|
81
|
18 |
|
'locale' => [static::TYPE => 'string'], |
|
82
|
18 |
|
'authorName' => [static::TYPE => 'string'], |
|
83
|
18 |
|
'title' => [static::TYPE => 'string'], |
|
84
|
18 |
|
'text' => [static::TYPE => 'string'], |
|
85
|
18 |
|
'target' => [static::TYPE => ResourceIdentifier::class], |
|
86
|
18 |
|
'rating' => [static::TYPE => 'int'], |
|
87
|
18 |
|
'state' => [static::TYPE => StateReference::class], |
|
88
|
18 |
|
'includedInStatistics' => [static::TYPE => 'bool'], |
|
89
|
18 |
|
'customer' => [static::TYPE => CustomerReference::class], |
|
90
|
18 |
|
'custom' => [static::TYPE => CustomFieldObject::class], |
|
91
|
18 |
|
'createdBy' => [static::TYPE => CreatedBy::class], |
|
92
|
18 |
|
'lastModifiedBy' => [static::TYPE => LastModifiedBy::class], |
|
93
|
|
|
]; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function jsonSerialize() |
|
97
|
|
|
{ |
|
98
|
|
|
$data = parent::jsonSerialize(); |
|
99
|
|
|
if (isset($data['locale'])) { |
|
100
|
|
|
$data['locale'] = str_replace('_', '-', $data['locale']); |
|
101
|
|
|
} |
|
102
|
|
|
return $data; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|