commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
DeliveryPayloadModel.php
1<?php
2
3declare(strict_types=1);
10
19use stdClass;
20
25{
26 public const DISCRIMINATOR_VALUE = '';
31 protected $projectKey;
32
38
43 protected $resource;
44
50
55 private static $discriminatorClasses = [
56 'Message' => MessageDeliveryPayloadModel::class,
57 'ResourceCreated' => ResourceCreatedDeliveryPayloadModel::class,
58 'ResourceDeleted' => ResourceDeletedDeliveryPayloadModel::class,
59 'ResourceUpdated' => ResourceUpdatedDeliveryPayloadModel::class,
60 ];
61
65 public function __construct(
66 ?string $projectKey = null,
67 ?Reference $resource = null,
69 ?string $notificationType = null
70 ) {
71 $this->projectKey = $projectKey;
72 $this->resource = $resource;
73 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
74 $this->notificationType = $notificationType;
75 }
76
84 public function getProjectKey()
85 {
86 if (is_null($this->projectKey)) {
88 $data = $this->raw(self::FIELD_PROJECT_KEY);
89 if (is_null($data)) {
90 return null;
91 }
92 $this->projectKey = (string) $data;
93 }
94
95 return $this->projectKey;
96 }
97
104 public function getNotificationType()
105 {
106 if (is_null($this->notificationType)) {
108 $data = $this->raw(self::FIELD_NOTIFICATION_TYPE);
109 if (is_null($data)) {
110 return null;
111 }
112 $this->notificationType = (string) $data;
113 }
114
116 }
117
124 public function getResource()
125 {
126 if (is_null($this->resource)) {
128 $data = $this->raw(self::FIELD_RESOURCE);
129 if (is_null($data)) {
130 return null;
131 }
132 $className = ReferenceModel::resolveDiscriminatorClass($data);
133 $this->resource = $className::of($data);
134 }
135
136 return $this->resource;
137 }
138
146 {
147 if (is_null($this->resourceUserProvidedIdentifiers)) {
149 $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
150 if (is_null($data)) {
151 return null;
152 }
153
154 $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
155 }
156
158 }
159
160
164 public function setProjectKey(?string $projectKey): void
165 {
166 $this->projectKey = $projectKey;
167 }
168
172 public function setResource(?Reference $resource): void
173 {
174 $this->resource = $resource;
175 }
176
181 {
182 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
183 }
184
185
186
191 public static function resolveDiscriminatorClass($value): string
192 {
194 if (is_object($value) && isset($value->$fieldName)) {
196 $discriminatorValue = $value->$fieldName;
197 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
198 return self::$discriminatorClasses[$discriminatorValue];
199 }
200 }
201 if (is_array($value) && isset($value[$fieldName])) {
203 $discriminatorValue = $value[$fieldName];
204 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
205 return self::$discriminatorClasses[$discriminatorValue];
206 }
207 }
208
210 $type = DeliveryPayloadModel::class;
211 return $type;
212 }
213}
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)
__construct(?string $projectKey=null, ?Reference $resource=null, ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers=null, ?string $notificationType=null)