|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author SignpostMarv |
|
4
|
|
|
*/ |
|
5
|
|
|
declare(strict_types=1); |
|
6
|
|
|
|
|
7
|
|
|
namespace SignpostMarv\DaftObject\SchemaOrg; |
|
8
|
|
|
|
|
9
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\CreativeWork\Review; |
|
10
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\DataTypes\Date; |
|
11
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\DataTypes\DateTime; |
|
12
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\BusinessEntityType; |
|
13
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\BusinessFunction; |
|
14
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\DeliveryMethod; |
|
15
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\ItemAvailability; |
|
16
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\OfferItemCondition; |
|
17
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\PaymentMethod; |
|
18
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\PhysicalActivityCategory; |
|
19
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Rating\AggregateRating; |
|
20
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Service; |
|
21
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Service\FinancialProduct\LoanOrCredit; |
|
22
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue\PriceSpecification; |
|
23
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue\QuantitativeValue; |
|
24
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue\TypeAndQuantityNode; |
|
25
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue\WarrantyPromise; |
|
26
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Place\AdministrativeArea; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @property array<int, LoanOrCredit|PaymentMethod> $acceptedPaymentMethod |
|
30
|
|
|
* @property array<int, Offer> $addOn |
|
31
|
|
|
* @property array<int, QuantitativeValue> $advanceBookingRequirement |
|
32
|
|
|
* @property array<int, AggregateRating> $aggregateRating |
|
33
|
|
|
* @property array<int, string|AdministrativeArea|GeoShape|Place> $areaServed |
|
34
|
|
|
* @property array<int, ItemAvailability> $availability |
|
35
|
|
|
* @property array<int, DateTime> $availabilityEnds |
|
36
|
|
|
* @property array<int, DateTime> $availabilityStarts |
|
37
|
|
|
* @property array<int, Place> $availableAtOrFrom |
|
38
|
|
|
* @property array<int, DeliveryMethod> $availableDeliveryMethod |
|
39
|
|
|
* @property array<int, Type> $businessFunction |
|
40
|
|
|
* @property array<int, string|Thing|PhysicalActivityCategory> $category |
|
41
|
|
|
* @property array<int, QuantitativeValue> $deliveryLeadTime |
|
42
|
|
|
* @property array<int, BusinessEntityType> $eligibleCustomerType |
|
43
|
|
|
* @property array<int, QuantitativeValue> $eligibleDuration |
|
44
|
|
|
* @property array<int, QuantitativeValue> $eligibleQuantity |
|
45
|
|
|
* @property array<int, string|GeoShape|Place> $eligibleRegion |
|
46
|
|
|
* @property array<int, PriceSpecification> $eligibleTransactionVolume |
|
47
|
|
|
* @property array<int, string> $gtin12 |
|
48
|
|
|
* @property array<int, string> $gtin13 |
|
49
|
|
|
* @property array<int, string> $gtin14 |
|
50
|
|
|
* @property array<int, string> $gtin8 |
|
51
|
|
|
* @property array<int, TypeAndQuantityNode> $includesObject |
|
52
|
|
|
* @property array<int, string|GeoShape|Place> $ineligibleRegion |
|
53
|
|
|
* @property array<int, QuantitativeValue> $inventoryLevel |
|
54
|
|
|
* @property array<int, OfferItemCondition> $itemCondition |
|
55
|
|
|
* @property array<int, Product|Service> $itemOffered |
|
56
|
|
|
* @property array<int, string> $mpn |
|
57
|
|
|
* @property array<int, Organization|Person> $offeredBy |
|
58
|
|
|
* @property array<int, string|float|int> $price |
|
59
|
|
|
* @property array<int, string> $priceCurrency |
|
60
|
|
|
* @property array<int, PriceSpecification> $priceSpecification |
|
61
|
|
|
* @property array<int, Date> $priceValidUntil |
|
62
|
|
|
* @property array<int, Review> $review |
|
63
|
|
|
* @property array<int, Organization|Person> $seller |
|
64
|
|
|
* @property array<int, string> $serialNumber |
|
65
|
|
|
* @property array<int, string> $sku |
|
66
|
|
|
* @property array<int, DateTime> $validFrom |
|
67
|
|
|
* @property array<int, DateTime> $validThrough |
|
68
|
|
|
* @property array<int, WarrantyPromise> $warranty |
|
69
|
|
|
*/ |
|
70
|
|
|
class Offer extends Thing |
|
71
|
|
|
{ |
|
72
|
|
|
use DaftObjectTraits\IsOfferOrDemand; |
|
73
|
|
|
use DaftObjectTraits\HasAggregateRating; |
|
74
|
|
|
use DaftObjectTraits\HasCategory; |
|
75
|
|
|
use DaftObjectTraits\HasItemCondition; |
|
76
|
|
|
use DaftObjectTraits\HasMpn; |
|
77
|
|
|
use DaftObjectTraits\PricePriceCurrency; |
|
78
|
|
|
use DaftObjectTraits\HasReview; |
|
79
|
|
|
|
|
80
|
|
|
const SCHEMA_ORG_TYPE = 'Offer'; |
|
81
|
|
|
|
|
82
|
|
|
const PROPERTIES = [ |
|
83
|
|
|
'acceptedPaymentMethod', |
|
84
|
|
|
'addOn', |
|
85
|
|
|
'advanceBookingRequirement', |
|
86
|
|
|
'aggregateRating', |
|
87
|
|
|
'areaServed', |
|
88
|
|
|
'availability', |
|
89
|
|
|
'availabilityEnds', |
|
90
|
|
|
'availabilityStarts', |
|
91
|
|
|
'availableAtOrFrom', |
|
92
|
|
|
'availableDeliveryMethod', |
|
93
|
|
|
'businessFunction', |
|
94
|
|
|
'category', |
|
95
|
|
|
'deliveryLeadTime', |
|
96
|
|
|
'eligibleCustomerType', |
|
97
|
|
|
'eligibleDuration', |
|
98
|
|
|
'eligibleQuantity', |
|
99
|
|
|
'eligibleRegion', |
|
100
|
|
|
'eligibleTransactionVolume', |
|
101
|
|
|
'gtin12', |
|
102
|
|
|
'gtin13', |
|
103
|
|
|
'gtin14', |
|
104
|
|
|
'gtin8', |
|
105
|
|
|
'includesObject', |
|
106
|
|
|
'ineligibleRegion', |
|
107
|
|
|
'inventoryLevel', |
|
108
|
|
|
'itemCondition', |
|
109
|
|
|
'itemOffered', |
|
110
|
|
|
'mpn', |
|
111
|
|
|
'offeredBy', |
|
112
|
|
|
'price', |
|
113
|
|
|
'priceCurrency', |
|
114
|
|
|
'priceSpecification', |
|
115
|
|
|
'priceValidUntil', |
|
116
|
|
|
'review', |
|
117
|
|
|
'seller', |
|
118
|
|
|
'serialNumber', |
|
119
|
|
|
'sku', |
|
120
|
|
|
'validFrom', |
|
121
|
|
|
'validThrough', |
|
122
|
|
|
'warranty', |
|
123
|
|
|
]; |
|
124
|
|
|
|
|
125
|
|
|
const PROPERTIES_WITH_MULTI_TYPED_ARRAYS = [ |
|
126
|
|
|
'acceptedPaymentMethod' => [ |
|
127
|
|
|
LoanOrCredit::class, |
|
128
|
|
|
PaymentMethod::class, |
|
129
|
|
|
], |
|
130
|
|
|
'addOn' => [ |
|
131
|
|
|
Offer::class, |
|
132
|
|
|
], |
|
133
|
|
|
'advanceBookingRequirement' => [ |
|
134
|
|
|
QuantitativeValue::class, |
|
135
|
|
|
], |
|
136
|
|
|
'aggregateRating' => [ |
|
137
|
|
|
AggregateRating::class, |
|
138
|
|
|
], |
|
139
|
|
|
'areaServed' => [ |
|
140
|
|
|
'string', |
|
141
|
|
|
AdministrativeArea::class, |
|
142
|
|
|
GeoShape::class, |
|
143
|
|
|
Place::class, |
|
144
|
|
|
], |
|
145
|
|
|
'availability' => [ |
|
146
|
|
|
ItemAvailability::class, |
|
147
|
|
|
], |
|
148
|
|
|
'availabilityEnds' => [ |
|
149
|
|
|
DateTime::class, |
|
150
|
|
|
], |
|
151
|
|
|
'availabilityStarts' => [ |
|
152
|
|
|
DateTime::class, |
|
153
|
|
|
], |
|
154
|
|
|
'availableAtOrFrom' => [ |
|
155
|
|
|
Place::class, |
|
156
|
|
|
], |
|
157
|
|
|
'availableDeliveryMethod' => [ |
|
158
|
|
|
DeliveryMethod::class, |
|
159
|
|
|
], |
|
160
|
|
|
'businessFunction' => [ |
|
161
|
|
|
BusinessFunction::class, |
|
162
|
|
|
], |
|
163
|
|
|
'category' => [ |
|
164
|
|
|
'string', |
|
165
|
|
|
Thing::class, |
|
166
|
|
|
PhysicalActivityCategory::class, |
|
167
|
|
|
], |
|
168
|
|
|
'deliveryLeadTime' => TypeUtilities::MULTI_TYPE_DICT__deliveryLeadTime, |
|
169
|
|
|
'eligibleCustomerType' => TypeUtilities::MULTI_TYPE_DICT__eligibleCustomerType, |
|
170
|
|
|
'eligibleDuration' => TypeUtilities::MULTI_TYPE_DICT__eligibleDuration, |
|
171
|
|
|
'eligibleQuantity' => TypeUtilities::MULTI_TYPE_DICT__eligibleQuantity, |
|
172
|
|
|
'eligibleRegion' => TypeUtilities::MULTI_TYPE_DICT__eligibleRegion, |
|
173
|
|
|
'eligibleTransactionVolume' => TypeUtilities::MULTI_TYPE_DICT__eligibleTransactionVolume, |
|
174
|
|
|
'gtin12' => TypeUtilities::MULTI_TYPE_DICT__gtin12, |
|
175
|
|
|
'gtin13' => TypeUtilities::MULTI_TYPE_DICT__gtin13, |
|
176
|
|
|
'gtin14' => TypeUtilities::MULTI_TYPE_DICT__gtin14, |
|
177
|
|
|
'gtin8' => TypeUtilities::MULTI_TYPE_DICT__gtin8, |
|
178
|
|
|
'includesObject' => TypeUtilities::MULTI_TYPE_DICT__includesObject, |
|
179
|
|
|
'ineligibleRegion' => TypeUtilities::MULTI_TYPE_DICT__ineligibleRegion, |
|
180
|
|
|
'inventoryLevel' => TypeUtilities::MULTI_TYPE_DICT__inventoryLevel, |
|
181
|
|
|
'itemCondition' => TypeUtilities::MULTI_TYPE_DICT__itemCondition, |
|
182
|
|
|
'itemOffered' => TypeUtilities::MULTI_TYPE_DICT__itemOffered, |
|
183
|
|
|
'mpn' => TypeUtilities::MULTI_TYPE_DICT__mpn, |
|
184
|
|
|
'offeredBy' => [ |
|
185
|
|
|
Organization::class, |
|
186
|
|
|
Person::class, |
|
187
|
|
|
], |
|
188
|
|
|
'price' => [ |
|
189
|
|
|
'string', |
|
190
|
|
|
'double', |
|
191
|
|
|
'integer', |
|
192
|
|
|
], |
|
193
|
|
|
'priceCurrency' => [ |
|
194
|
|
|
'string', |
|
195
|
|
|
], |
|
196
|
|
|
'priceSpecification' => [ |
|
197
|
|
|
PriceSpecification::class, |
|
198
|
|
|
], |
|
199
|
|
|
'priceValidUntil' => [ |
|
200
|
|
|
Date::class, |
|
201
|
|
|
], |
|
202
|
|
|
'review' => [ |
|
203
|
|
|
Review::class, |
|
204
|
|
|
], |
|
205
|
|
|
'seller' => [ |
|
206
|
|
|
Organization::class, |
|
207
|
|
|
Person::class, |
|
208
|
|
|
], |
|
209
|
|
|
'serialNumber' => [ |
|
210
|
|
|
'string', |
|
211
|
|
|
], |
|
212
|
|
|
'sku' => [ |
|
213
|
|
|
'string', |
|
214
|
|
|
], |
|
215
|
|
|
'validFrom' => [ |
|
216
|
|
|
DateTime::class, |
|
217
|
|
|
], |
|
218
|
|
|
'validThrough' => [ |
|
219
|
|
|
DateTime::class, |
|
220
|
|
|
], |
|
221
|
|
|
'warranty' => [ |
|
222
|
|
|
WarrantyPromise::class, |
|
223
|
|
|
], |
|
224
|
|
|
]; |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* @return array<int, Offer> |
|
228
|
85 |
|
*/ |
|
229
|
|
|
public function GetAddOn() : array |
|
230
|
|
|
{ |
|
231
|
|
|
/** |
|
232
|
|
|
* @var array<int, Offer> |
|
233
|
85 |
|
*/ |
|
234
|
|
|
$out = $this->ExpectRetrievedValueIsArray('addOn'); |
|
235
|
85 |
|
|
|
236
|
|
|
return $out; |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
/** |
|
240
|
|
|
* @param array<int, Offer> $value |
|
241
|
1 |
|
*/ |
|
242
|
|
|
public function SetAddOn(array $value) : void |
|
243
|
1 |
|
{ |
|
244
|
1 |
|
$this->NudgePropertyValue('addOn', $value); |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* @return array<int, Organization|Person> |
|
249
|
85 |
|
*/ |
|
250
|
|
|
public function GetOfferedBy() : array |
|
251
|
|
|
{ |
|
252
|
|
|
/** |
|
253
|
|
|
* @var array<int, Organization|Person> |
|
254
|
85 |
|
*/ |
|
255
|
|
|
$out = $this->ExpectRetrievedValueIsArray('offeredBy'); |
|
256
|
85 |
|
|
|
257
|
|
|
return $out; |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
/** |
|
261
|
|
|
* @param array<int, Organization|Person> $value |
|
262
|
1 |
|
*/ |
|
263
|
|
|
public function SetOfferedBy(array $value) : void |
|
264
|
1 |
|
{ |
|
265
|
1 |
|
$this->NudgePropertyValue('offeredBy', $value); |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* @return array<int, Date> |
|
270
|
85 |
|
*/ |
|
271
|
|
|
public function GetPriceValidUntil() : array |
|
272
|
|
|
{ |
|
273
|
|
|
/** |
|
274
|
|
|
* @var array<int, Date> |
|
275
|
85 |
|
*/ |
|
276
|
|
|
$out = $this->ExpectRetrievedValueIsArray('priceValidUntil'); |
|
277
|
85 |
|
|
|
278
|
|
|
return $out; |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
/** |
|
282
|
|
|
* @param array<int, Date> $value |
|
283
|
1 |
|
*/ |
|
284
|
|
|
public function SetPriceValidUntil(array $value) : void |
|
285
|
1 |
|
{ |
|
286
|
1 |
|
$this->NudgePropertyValue('priceValidUntil', $value); |
|
287
|
|
|
} |
|
288
|
|
|
} |
|
289
|
|
|
|