commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ExactLockConflictErrorModel.php
1<?php
2
3declare(strict_types=1);
10
21use DateTimeImmutable;
22use stdClass;
23
28{
29 public const DISCRIMINATOR_VALUE = 'ExactLockConflict';
34 protected $code;
35
40 protected $message;
41
46 protected $sku;
47
52 protected $currency;
53
58 protected $country;
59
64 protected $customerGroup;
65
70 protected $channel;
71
76 protected $validFrom;
77
82 protected $validUntil;
83
89
90
94 public function __construct(
95 ?string $message = null,
96 ?string $sku = null,
97 ?string $currency = null,
98 ?string $country = null,
101 ?DateTimeImmutable $validFrom = null,
102 ?DateTimeImmutable $validUntil = null,
104 ?string $code = null
105 ) {
106 $this->message = $message;
107 $this->sku = $sku;
108 $this->currency = $currency;
109 $this->country = $country;
110 $this->customerGroup = $customerGroup;
111 $this->channel = $channel;
112 $this->validFrom = $validFrom;
113 $this->validUntil = $validUntil;
114 $this->recurrencePolicy = $recurrencePolicy;
115 $this->code = $code ?? self::DISCRIMINATOR_VALUE;
116 }
117
122 public function getCode()
123 {
124 if (is_null($this->code)) {
126 $data = $this->raw(self::FIELD_CODE);
127 if (is_null($data)) {
128 return null;
129 }
130 $this->code = (string) $data;
131 }
132
133 return $this->code;
134 }
135
142 public function getMessage()
143 {
144 if (is_null($this->message)) {
146 $data = $this->raw(self::FIELD_MESSAGE);
147 if (is_null($data)) {
148 return null;
149 }
150 $this->message = (string) $data;
151 }
152
153 return $this->message;
154 }
155
162 public function getSku()
163 {
164 if (is_null($this->sku)) {
166 $data = $this->raw(self::FIELD_SKU);
167 if (is_null($data)) {
168 return null;
169 }
170 $this->sku = (string) $data;
171 }
172
173 return $this->sku;
174 }
175
182 public function getCurrency()
183 {
184 if (is_null($this->currency)) {
186 $data = $this->raw(self::FIELD_CURRENCY);
187 if (is_null($data)) {
188 return null;
189 }
190 $this->currency = (string) $data;
191 }
192
193 return $this->currency;
194 }
195
202 public function getCountry()
203 {
204 if (is_null($this->country)) {
206 $data = $this->raw(self::FIELD_COUNTRY);
207 if (is_null($data)) {
208 return null;
209 }
210 $this->country = (string) $data;
211 }
212
213 return $this->country;
214 }
215
222 public function getCustomerGroup()
223 {
224 if (is_null($this->customerGroup)) {
226 $data = $this->raw(self::FIELD_CUSTOMER_GROUP);
227 if (is_null($data)) {
228 return null;
229 }
230
231 $this->customerGroup = CustomerGroupResourceIdentifierModel::of($data);
232 }
233
235 }
236
243 public function getChannel()
244 {
245 if (is_null($this->channel)) {
247 $data = $this->raw(self::FIELD_CHANNEL);
248 if (is_null($data)) {
249 return null;
250 }
251
252 $this->channel = ChannelResourceIdentifierModel::of($data);
253 }
254
255 return $this->channel;
256 }
257
264 public function getValidFrom()
265 {
266 if (is_null($this->validFrom)) {
268 $data = $this->raw(self::FIELD_VALID_FROM);
269 if (is_null($data)) {
270 return null;
271 }
272 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
273 if (false === $data) {
274 return null;
275 }
276 $this->validFrom = $data;
277 }
278
279 return $this->validFrom;
280 }
281
288 public function getValidUntil()
289 {
290 if (is_null($this->validUntil)) {
292 $data = $this->raw(self::FIELD_VALID_UNTIL);
293 if (is_null($data)) {
294 return null;
295 }
296 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
297 if (false === $data) {
298 return null;
299 }
300 $this->validUntil = $data;
301 }
302
303 return $this->validUntil;
304 }
305
312 public function getRecurrencePolicy()
313 {
314 if (is_null($this->recurrencePolicy)) {
316 $data = $this->raw(self::FIELD_RECURRENCE_POLICY);
317 if (is_null($data)) {
318 return null;
319 }
320
321 $this->recurrencePolicy = RecurrencePolicyReferenceModel::of($data);
322 }
323
325 }
326
327
331 public function setMessage(?string $message): void
332 {
333 $this->message = $message;
334 }
335
339 public function setSku(?string $sku): void
340 {
341 $this->sku = $sku;
342 }
343
347 public function setCurrency(?string $currency): void
348 {
349 $this->currency = $currency;
350 }
351
355 public function setCountry(?string $country): void
356 {
357 $this->country = $country;
358 }
359
364 {
365 $this->customerGroup = $customerGroup;
366 }
367
372 {
373 $this->channel = $channel;
374 }
375
379 public function setValidFrom(?DateTimeImmutable $validFrom): void
380 {
381 $this->validFrom = $validFrom;
382 }
383
387 public function setValidUntil(?DateTimeImmutable $validUntil): void
388 {
389 $this->validUntil = $validUntil;
390 }
391
396 {
397 $this->recurrencePolicy = $recurrencePolicy;
398 }
399
403 public function by(string $key)
404 {
405 $data = $this->raw($key);
406 if (is_null($data)) {
407 return null;
408 }
409
410 return $data;
411 }
412
413 #[\ReturnTypeWillChange]
414 public function jsonSerialize()
415 {
416 $data = $this->toArray();
417 if (isset($data[ExactLockConflictError::FIELD_VALID_FROM]) && $data[ExactLockConflictError::FIELD_VALID_FROM] instanceof \DateTimeImmutable) {
418 $data[ExactLockConflictError::FIELD_VALID_FROM] = $data[ExactLockConflictError::FIELD_VALID_FROM]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
419 }
420
421 if (isset($data[ExactLockConflictError::FIELD_VALID_UNTIL]) && $data[ExactLockConflictError::FIELD_VALID_UNTIL] instanceof \DateTimeImmutable) {
422 $data[ExactLockConflictError::FIELD_VALID_UNTIL] = $data[ExactLockConflictError::FIELD_VALID_UNTIL]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
423 }
424 return (object) $data;
425 }
426}
setCustomerGroup(?CustomerGroupResourceIdentifier $customerGroup)
__construct(?string $message=null, ?string $sku=null, ?string $currency=null, ?string $country=null, ?CustomerGroupResourceIdentifier $customerGroup=null, ?ChannelResourceIdentifier $channel=null, ?DateTimeImmutable $validFrom=null, ?DateTimeImmutable $validUntil=null, ?RecurrencePolicyReference $recurrencePolicy=null, ?string $code=null)
setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy)