commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
AssociateRoleModel.php
1<?php
2
3declare(strict_types=1);
10
23use DateTimeImmutable;
24use stdClass;
25
29final class AssociateRoleModel extends JsonObjectModel implements AssociateRole
30{
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 $key;
72
78
83 protected $name;
84
89 protected $permissions;
90
95 protected $custom;
96
97
101 public function __construct(
102 ?string $id = null,
103 ?int $version = null,
104 ?DateTimeImmutable $createdAt = null,
105 ?DateTimeImmutable $lastModifiedAt = null,
107 ?CreatedBy $createdBy = null,
108 ?string $key = null,
109 ?bool $buyerAssignable = null,
110 ?string $name = null,
111 ?array $permissions = null,
112 ?CustomFields $custom = null
113 ) {
114 $this->id = $id;
115 $this->version = $version;
116 $this->createdAt = $createdAt;
117 $this->lastModifiedAt = $lastModifiedAt;
118 $this->lastModifiedBy = $lastModifiedBy;
119 $this->createdBy = $createdBy;
120 $this->key = $key;
121 $this->buyerAssignable = $buyerAssignable;
122 $this->name = $name;
123 $this->permissions = $permissions;
124 $this->custom = $custom;
125 }
126
133 public function getId()
134 {
135 if (is_null($this->id)) {
137 $data = $this->raw(self::FIELD_ID);
138 if (is_null($data)) {
139 return null;
140 }
141 $this->id = (string) $data;
142 }
143
144 return $this->id;
145 }
146
153 public function getVersion()
154 {
155 if (is_null($this->version)) {
157 $data = $this->raw(self::FIELD_VERSION);
158 if (is_null($data)) {
159 return null;
160 }
161 $this->version = (int) $data;
162 }
163
164 return $this->version;
165 }
166
173 public function getCreatedAt()
174 {
175 if (is_null($this->createdAt)) {
177 $data = $this->raw(self::FIELD_CREATED_AT);
178 if (is_null($data)) {
179 return null;
180 }
181 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
182 if (false === $data) {
183 return null;
184 }
185 $this->createdAt = $data;
186 }
187
188 return $this->createdAt;
189 }
190
197 public function getLastModifiedAt()
198 {
199 if (is_null($this->lastModifiedAt)) {
201 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
202 if (is_null($data)) {
203 return null;
204 }
205 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
206 if (false === $data) {
207 return null;
208 }
209 $this->lastModifiedAt = $data;
210 }
211
213 }
214
221 public function getLastModifiedBy()
222 {
223 if (is_null($this->lastModifiedBy)) {
225 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
226 if (is_null($data)) {
227 return null;
228 }
229
230 $this->lastModifiedBy = LastModifiedByModel::of($data);
231 }
232
234 }
235
242 public function getCreatedBy()
243 {
244 if (is_null($this->createdBy)) {
246 $data = $this->raw(self::FIELD_CREATED_BY);
247 if (is_null($data)) {
248 return null;
249 }
250
251 $this->createdBy = CreatedByModel::of($data);
252 }
253
254 return $this->createdBy;
255 }
256
263 public function getKey()
264 {
265 if (is_null($this->key)) {
267 $data = $this->raw(self::FIELD_KEY);
268 if (is_null($data)) {
269 return null;
270 }
271 $this->key = (string) $data;
272 }
273
274 return $this->key;
275 }
276
283 public function getBuyerAssignable()
284 {
285 if (is_null($this->buyerAssignable)) {
287 $data = $this->raw(self::FIELD_BUYER_ASSIGNABLE);
288 if (is_null($data)) {
289 return null;
290 }
291 $this->buyerAssignable = (bool) $data;
292 }
293
295 }
296
303 public function getName()
304 {
305 if (is_null($this->name)) {
307 $data = $this->raw(self::FIELD_NAME);
308 if (is_null($data)) {
309 return null;
310 }
311 $this->name = (string) $data;
312 }
313
314 return $this->name;
315 }
316
323 public function getPermissions()
324 {
325 if (is_null($this->permissions)) {
327 $data = $this->raw(self::FIELD_PERMISSIONS);
328 if (is_null($data)) {
329 return null;
330 }
331 $this->permissions = $data;
332 }
333
334 return $this->permissions;
335 }
336
343 public function getCustom()
344 {
345 if (is_null($this->custom)) {
347 $data = $this->raw(self::FIELD_CUSTOM);
348 if (is_null($data)) {
349 return null;
350 }
351
352 $this->custom = CustomFieldsModel::of($data);
353 }
354
355 return $this->custom;
356 }
357
358
362 public function setId(?string $id): void
363 {
364 $this->id = $id;
365 }
366
370 public function setVersion(?int $version): void
371 {
372 $this->version = $version;
373 }
374
378 public function setCreatedAt(?DateTimeImmutable $createdAt): void
379 {
380 $this->createdAt = $createdAt;
381 }
382
386 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
387 {
388 $this->lastModifiedAt = $lastModifiedAt;
389 }
390
395 {
396 $this->lastModifiedBy = $lastModifiedBy;
397 }
398
402 public function setCreatedBy(?CreatedBy $createdBy): void
403 {
404 $this->createdBy = $createdBy;
405 }
406
410 public function setKey(?string $key): void
411 {
412 $this->key = $key;
413 }
414
418 public function setBuyerAssignable(?bool $buyerAssignable): void
419 {
420 $this->buyerAssignable = $buyerAssignable;
421 }
422
426 public function setName(?string $name): void
427 {
428 $this->name = $name;
429 }
430
434 public function setPermissions(?array $permissions): void
435 {
436 $this->permissions = $permissions;
437 }
438
442 public function setCustom(?CustomFields $custom): void
443 {
444 $this->custom = $custom;
445 }
446
447
448 #[\ReturnTypeWillChange]
449 public function jsonSerialize()
450 {
451 $data = $this->toArray();
452 if (isset($data[AssociateRole::FIELD_CREATED_AT]) && $data[AssociateRole::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
453 $data[AssociateRole::FIELD_CREATED_AT] = $data[AssociateRole::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
454 }
455
456 if (isset($data[AssociateRole::FIELD_LAST_MODIFIED_AT]) && $data[AssociateRole::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
457 $data[AssociateRole::FIELD_LAST_MODIFIED_AT] = $data[AssociateRole::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
458 }
459 return (object) $data;
460 }
461}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $key=null, ?bool $buyerAssignable=null, ?string $name=null, ?array $permissions=null, ?CustomFields $custom=null)