commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
OverlappingPriceValidityErrorModel.php
1<?php
2
3declare(strict_types=1);
10
19use DateTimeImmutable;
20use stdClass;
21
26{
27 public const DISCRIMINATOR_VALUE = 'OverlappingPriceValidity';
32 protected $code;
33
38 protected $message;
39
45
50 protected $currency;
51
56 protected $country;
57
62 protected $customerGroup;
63
68 protected $channel;
69
74 protected $validFrom;
75
80 protected $validUntil;
81
87
93
94
98 public function __construct(
99 ?string $message = null,
100 ?string $conflictingPrice = null,
101 ?string $currency = null,
102 ?string $country = null,
105 ?DateTimeImmutable $validFrom = null,
106 ?DateTimeImmutable $validUntil = null,
107 ?DateTimeImmutable $conflictingValidFrom = null,
108 ?DateTimeImmutable $conflictingValidUntil = null,
109 ?string $code = null
110 ) {
111 $this->message = $message;
112 $this->conflictingPrice = $conflictingPrice;
113 $this->currency = $currency;
114 $this->country = $country;
115 $this->customerGroup = $customerGroup;
116 $this->channel = $channel;
117 $this->validFrom = $validFrom;
118 $this->validUntil = $validUntil;
119 $this->conflictingValidFrom = $conflictingValidFrom;
120 $this->conflictingValidUntil = $conflictingValidUntil;
121 $this->code = $code ?? self::DISCRIMINATOR_VALUE;
122 }
123
128 public function getCode()
129 {
130 if (is_null($this->code)) {
132 $data = $this->raw(self::FIELD_CODE);
133 if (is_null($data)) {
134 return null;
135 }
136 $this->code = (string) $data;
137 }
138
139 return $this->code;
140 }
141
148 public function getMessage()
149 {
150 if (is_null($this->message)) {
152 $data = $this->raw(self::FIELD_MESSAGE);
153 if (is_null($data)) {
154 return null;
155 }
156 $this->message = (string) $data;
157 }
158
159 return $this->message;
160 }
161
168 public function getConflictingPrice()
169 {
170 if (is_null($this->conflictingPrice)) {
172 $data = $this->raw(self::FIELD_CONFLICTING_PRICE);
173 if (is_null($data)) {
174 return null;
175 }
176 $this->conflictingPrice = (string) $data;
177 }
178
180 }
181
188 public function getCurrency()
189 {
190 if (is_null($this->currency)) {
192 $data = $this->raw(self::FIELD_CURRENCY);
193 if (is_null($data)) {
194 return null;
195 }
196 $this->currency = (string) $data;
197 }
198
199 return $this->currency;
200 }
201
208 public function getCountry()
209 {
210 if (is_null($this->country)) {
212 $data = $this->raw(self::FIELD_COUNTRY);
213 if (is_null($data)) {
214 return null;
215 }
216 $this->country = (string) $data;
217 }
218
219 return $this->country;
220 }
221
228 public function getCustomerGroup()
229 {
230 if (is_null($this->customerGroup)) {
232 $data = $this->raw(self::FIELD_CUSTOMER_GROUP);
233 if (is_null($data)) {
234 return null;
235 }
236
237 $this->customerGroup = CustomerGroupResourceIdentifierModel::of($data);
238 }
239
241 }
242
249 public function getChannel()
250 {
251 if (is_null($this->channel)) {
253 $data = $this->raw(self::FIELD_CHANNEL);
254 if (is_null($data)) {
255 return null;
256 }
257
258 $this->channel = ChannelResourceIdentifierModel::of($data);
259 }
260
261 return $this->channel;
262 }
263
270 public function getValidFrom()
271 {
272 if (is_null($this->validFrom)) {
274 $data = $this->raw(self::FIELD_VALID_FROM);
275 if (is_null($data)) {
276 return null;
277 }
278 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
279 if (false === $data) {
280 return null;
281 }
282 $this->validFrom = $data;
283 }
284
285 return $this->validFrom;
286 }
287
294 public function getValidUntil()
295 {
296 if (is_null($this->validUntil)) {
298 $data = $this->raw(self::FIELD_VALID_UNTIL);
299 if (is_null($data)) {
300 return null;
301 }
302 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
303 if (false === $data) {
304 return null;
305 }
306 $this->validUntil = $data;
307 }
308
309 return $this->validUntil;
310 }
311
318 public function getConflictingValidFrom()
319 {
320 if (is_null($this->conflictingValidFrom)) {
322 $data = $this->raw(self::FIELD_CONFLICTING_VALID_FROM);
323 if (is_null($data)) {
324 return null;
325 }
326 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
327 if (false === $data) {
328 return null;
329 }
330 $this->conflictingValidFrom = $data;
331 }
332
334 }
335
342 public function getConflictingValidUntil()
343 {
344 if (is_null($this->conflictingValidUntil)) {
346 $data = $this->raw(self::FIELD_CONFLICTING_VALID_UNTIL);
347 if (is_null($data)) {
348 return null;
349 }
350 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
351 if (false === $data) {
352 return null;
353 }
354 $this->conflictingValidUntil = $data;
355 }
356
358 }
359
360
364 public function setMessage(?string $message): void
365 {
366 $this->message = $message;
367 }
368
372 public function setConflictingPrice(?string $conflictingPrice): void
373 {
374 $this->conflictingPrice = $conflictingPrice;
375 }
376
380 public function setCurrency(?string $currency): void
381 {
382 $this->currency = $currency;
383 }
384
388 public function setCountry(?string $country): void
389 {
390 $this->country = $country;
391 }
392
397 {
398 $this->customerGroup = $customerGroup;
399 }
400
405 {
406 $this->channel = $channel;
407 }
408
412 public function setValidFrom(?DateTimeImmutable $validFrom): void
413 {
414 $this->validFrom = $validFrom;
415 }
416
420 public function setValidUntil(?DateTimeImmutable $validUntil): void
421 {
422 $this->validUntil = $validUntil;
423 }
424
428 public function setConflictingValidFrom(?DateTimeImmutable $conflictingValidFrom): void
429 {
430 $this->conflictingValidFrom = $conflictingValidFrom;
431 }
432
436 public function setConflictingValidUntil(?DateTimeImmutable $conflictingValidUntil): void
437 {
438 $this->conflictingValidUntil = $conflictingValidUntil;
439 }
440
444 public function by(string $key)
445 {
446 $data = $this->raw($key);
447 if (is_null($data)) {
448 return null;
449 }
450
451 return $data;
452 }
453
454 #[\ReturnTypeWillChange]
455 public function jsonSerialize()
456 {
457 $data = $this->toArray();
458 if (isset($data[OverlappingPriceValidityError::FIELD_VALID_FROM]) && $data[OverlappingPriceValidityError::FIELD_VALID_FROM] instanceof \DateTimeImmutable) {
459 $data[OverlappingPriceValidityError::FIELD_VALID_FROM] = $data[OverlappingPriceValidityError::FIELD_VALID_FROM]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
460 }
461
462 if (isset($data[OverlappingPriceValidityError::FIELD_VALID_UNTIL]) && $data[OverlappingPriceValidityError::FIELD_VALID_UNTIL] instanceof \DateTimeImmutable) {
463 $data[OverlappingPriceValidityError::FIELD_VALID_UNTIL] = $data[OverlappingPriceValidityError::FIELD_VALID_UNTIL]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
464 }
465
468 }
469
472 }
473 return (object) $data;
474 }
475}
__construct(?string $message=null, ?string $conflictingPrice=null, ?string $currency=null, ?string $country=null, ?CustomerGroupResourceIdentifier $customerGroup=null, ?ChannelResourceIdentifier $channel=null, ?DateTimeImmutable $validFrom=null, ?DateTimeImmutable $validUntil=null, ?DateTimeImmutable $conflictingValidFrom=null, ?DateTimeImmutable $conflictingValidUntil=null, ?string $code=null)