commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
BusinessUnitAssociatesSetMessageModel.php
1<?php
2
3declare(strict_types=1);
10
22use DateTimeImmutable;
23use stdClass;
24
29{
30 public const DISCRIMINATOR_VALUE = 'BusinessUnitAssociatesSet';
35 protected $id;
36
41 protected $version;
42
47 protected $createdAt;
48
53 protected $lastModifiedAt;
54
59 protected $lastModifiedBy;
60
65 protected $createdBy;
66
71 protected $sequenceNumber;
72
77 protected $resource;
78
84
89 protected $type;
90
96
101 protected $associates;
102
103
107 public function __construct(
108 ?string $id = null,
109 ?int $version = null,
110 ?DateTimeImmutable $createdAt = null,
111 ?DateTimeImmutable $lastModifiedAt = null,
113 ?CreatedBy $createdBy = null,
114 ?int $sequenceNumber = null,
115 ?Reference $resource = null,
116 ?int $resourceVersion = null,
119 ?string $type = null
120 ) {
121 $this->id = $id;
122 $this->version = $version;
123 $this->createdAt = $createdAt;
124 $this->lastModifiedAt = $lastModifiedAt;
125 $this->lastModifiedBy = $lastModifiedBy;
126 $this->createdBy = $createdBy;
127 $this->sequenceNumber = $sequenceNumber;
128 $this->resource = $resource;
129 $this->resourceVersion = $resourceVersion;
130 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
131 $this->associates = $associates;
132 $this->type = $type ?? self::DISCRIMINATOR_VALUE;
133 }
134
141 public function getId()
142 {
143 if (is_null($this->id)) {
145 $data = $this->raw(self::FIELD_ID);
146 if (is_null($data)) {
147 return null;
148 }
149 $this->id = (string) $data;
150 }
151
152 return $this->id;
153 }
154
161 public function getVersion()
162 {
163 if (is_null($this->version)) {
165 $data = $this->raw(self::FIELD_VERSION);
166 if (is_null($data)) {
167 return null;
168 }
169 $this->version = (int) $data;
170 }
171
172 return $this->version;
173 }
174
181 public function getCreatedAt()
182 {
183 if (is_null($this->createdAt)) {
185 $data = $this->raw(self::FIELD_CREATED_AT);
186 if (is_null($data)) {
187 return null;
188 }
189 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
190 if (false === $data) {
191 return null;
192 }
193 $this->createdAt = $data;
194 }
195
196 return $this->createdAt;
197 }
198
205 public function getLastModifiedAt()
206 {
207 if (is_null($this->lastModifiedAt)) {
209 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
210 if (is_null($data)) {
211 return null;
212 }
213 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
214 if (false === $data) {
215 return null;
216 }
217 $this->lastModifiedAt = $data;
218 }
219
221 }
222
229 public function getLastModifiedBy()
230 {
231 if (is_null($this->lastModifiedBy)) {
233 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
234 if (is_null($data)) {
235 return null;
236 }
237
238 $this->lastModifiedBy = LastModifiedByModel::of($data);
239 }
240
242 }
243
250 public function getCreatedBy()
251 {
252 if (is_null($this->createdBy)) {
254 $data = $this->raw(self::FIELD_CREATED_BY);
255 if (is_null($data)) {
256 return null;
257 }
258
259 $this->createdBy = CreatedByModel::of($data);
260 }
261
262 return $this->createdBy;
263 }
264
272 public function getSequenceNumber()
273 {
274 if (is_null($this->sequenceNumber)) {
276 $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
277 if (is_null($data)) {
278 return null;
279 }
280 $this->sequenceNumber = (int) $data;
281 }
282
284 }
285
292 public function getResource()
293 {
294 if (is_null($this->resource)) {
296 $data = $this->raw(self::FIELD_RESOURCE);
297 if (is_null($data)) {
298 return null;
299 }
300 $className = ReferenceModel::resolveDiscriminatorClass($data);
301 $this->resource = $className::of($data);
302 }
303
304 return $this->resource;
305 }
306
313 public function getResourceVersion()
314 {
315 if (is_null($this->resourceVersion)) {
317 $data = $this->raw(self::FIELD_RESOURCE_VERSION);
318 if (is_null($data)) {
319 return null;
320 }
321 $this->resourceVersion = (int) $data;
322 }
323
325 }
326
333 public function getType()
334 {
335 if (is_null($this->type)) {
337 $data = $this->raw(self::FIELD_TYPE);
338 if (is_null($data)) {
339 return null;
340 }
341 $this->type = (string) $data;
342 }
343
344 return $this->type;
345 }
346
354 {
355 if (is_null($this->resourceUserProvidedIdentifiers)) {
357 $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
358 if (is_null($data)) {
359 return null;
360 }
361
362 $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
363 }
364
366 }
367
374 public function getAssociates()
375 {
376 if (is_null($this->associates)) {
378 $data = $this->raw(self::FIELD_ASSOCIATES);
379 if (is_null($data)) {
380 return null;
381 }
382 $this->associates = AssociateCollection::fromArray($data);
383 }
384
385 return $this->associates;
386 }
387
388
392 public function setId(?string $id): void
393 {
394 $this->id = $id;
395 }
396
400 public function setVersion(?int $version): void
401 {
402 $this->version = $version;
403 }
404
408 public function setCreatedAt(?DateTimeImmutable $createdAt): void
409 {
410 $this->createdAt = $createdAt;
411 }
412
416 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
417 {
418 $this->lastModifiedAt = $lastModifiedAt;
419 }
420
425 {
426 $this->lastModifiedBy = $lastModifiedBy;
427 }
428
432 public function setCreatedBy(?CreatedBy $createdBy): void
433 {
434 $this->createdBy = $createdBy;
435 }
436
440 public function setSequenceNumber(?int $sequenceNumber): void
441 {
442 $this->sequenceNumber = $sequenceNumber;
443 }
444
448 public function setResource(?Reference $resource): void
449 {
450 $this->resource = $resource;
451 }
452
456 public function setResourceVersion(?int $resourceVersion): void
457 {
458 $this->resourceVersion = $resourceVersion;
459 }
460
465 {
466 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
467 }
468
473 {
474 $this->associates = $associates;
475 }
476
477
478 #[\ReturnTypeWillChange]
479 public function jsonSerialize()
480 {
481 $data = $this->toArray();
482 if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
483 $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
484 }
485
486 if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
487 $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
488 }
489 return (object) $data;
490 }
491}
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?int $sequenceNumber=null, ?Reference $resource=null, ?int $resourceVersion=null, ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers=null, ?AssociateCollection $associates=null, ?string $type=null)