commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ApiClientModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use DateTimeImmutable;
16 use stdClass;
17 
21 final class ApiClientModel extends JsonObjectModel implements ApiClient
22 {
27  protected $id;
28 
33  protected $name;
34 
39  protected $scope;
40 
45  protected $secret;
46 
51  protected $lastUsedAt;
52 
57  protected $deleteAt;
58 
63  protected $createdAt;
64 
70 
76 
77 
81  public function __construct(
82  ?string $id = null,
83  ?string $name = null,
84  ?string $scope = null,
85  ?string $secret = null,
86  ?DateTimeImmutable $lastUsedAt = null,
87  ?DateTimeImmutable $deleteAt = null,
88  ?DateTimeImmutable $createdAt = null,
89  ?int $accessTokenValiditySeconds = null,
91  ) {
92  $this->id = $id;
93  $this->name = $name;
94  $this->scope = $scope;
95  $this->secret = $secret;
96  $this->lastUsedAt = $lastUsedAt;
97  $this->deleteAt = $deleteAt;
98  $this->createdAt = $createdAt;
99  $this->accessTokenValiditySeconds = $accessTokenValiditySeconds;
100  $this->refreshTokenValiditySeconds = $refreshTokenValiditySeconds;
101  }
102 
109  public function getId()
110  {
111  if (is_null($this->id)) {
113  $data = $this->raw(self::FIELD_ID);
114  if (is_null($data)) {
115  return null;
116  }
117  $this->id = (string) $data;
118  }
119 
120  return $this->id;
121  }
122 
129  public function getName()
130  {
131  if (is_null($this->name)) {
133  $data = $this->raw(self::FIELD_NAME);
134  if (is_null($data)) {
135  return null;
136  }
137  $this->name = (string) $data;
138  }
139 
140  return $this->name;
141  }
142 
149  public function getScope()
150  {
151  if (is_null($this->scope)) {
153  $data = $this->raw(self::FIELD_SCOPE);
154  if (is_null($data)) {
155  return null;
156  }
157  $this->scope = (string) $data;
158  }
159 
160  return $this->scope;
161  }
162 
170  public function getSecret()
171  {
172  if (is_null($this->secret)) {
174  $data = $this->raw(self::FIELD_SECRET);
175  if (is_null($data)) {
176  return null;
177  }
178  $this->secret = (string) $data;
179  }
180 
181  return $this->secret;
182  }
183 
190  public function getLastUsedAt()
191  {
192  if (is_null($this->lastUsedAt)) {
194  $data = $this->raw(self::FIELD_LAST_USED_AT);
195  if (is_null($data)) {
196  return null;
197  }
198  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATE_FORMAT, $data);
199  if (false === $data) {
200  return null;
201  }
202  $this->lastUsedAt = $data;
203  }
204 
205  return $this->lastUsedAt;
206  }
207 
214  public function getDeleteAt()
215  {
216  if (is_null($this->deleteAt)) {
218  $data = $this->raw(self::FIELD_DELETE_AT);
219  if (is_null($data)) {
220  return null;
221  }
222  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
223  if (false === $data) {
224  return null;
225  }
226  $this->deleteAt = $data;
227  }
228 
229  return $this->deleteAt;
230  }
231 
238  public function getCreatedAt()
239  {
240  if (is_null($this->createdAt)) {
242  $data = $this->raw(self::FIELD_CREATED_AT);
243  if (is_null($data)) {
244  return null;
245  }
246  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
247  if (false === $data) {
248  return null;
249  }
250  $this->createdAt = $data;
251  }
252 
253  return $this->createdAt;
254  }
255 
263  {
264  if (is_null($this->accessTokenValiditySeconds)) {
266  $data = $this->raw(self::FIELD_ACCESS_TOKEN_VALIDITY_SECONDS);
267  if (is_null($data)) {
268  return null;
269  }
270  $this->accessTokenValiditySeconds = (int) $data;
271  }
272 
274  }
275 
283  {
284  if (is_null($this->refreshTokenValiditySeconds)) {
286  $data = $this->raw(self::FIELD_REFRESH_TOKEN_VALIDITY_SECONDS);
287  if (is_null($data)) {
288  return null;
289  }
290  $this->refreshTokenValiditySeconds = (int) $data;
291  }
292 
294  }
295 
296 
300  public function setId(?string $id): void
301  {
302  $this->id = $id;
303  }
304 
308  public function setName(?string $name): void
309  {
310  $this->name = $name;
311  }
312 
316  public function setScope(?string $scope): void
317  {
318  $this->scope = $scope;
319  }
320 
324  public function setSecret(?string $secret): void
325  {
326  $this->secret = $secret;
327  }
328 
332  public function setLastUsedAt(?DateTimeImmutable $lastUsedAt): void
333  {
334  $this->lastUsedAt = $lastUsedAt;
335  }
336 
340  public function setDeleteAt(?DateTimeImmutable $deleteAt): void
341  {
342  $this->deleteAt = $deleteAt;
343  }
344 
348  public function setCreatedAt(?DateTimeImmutable $createdAt): void
349  {
350  $this->createdAt = $createdAt;
351  }
352 
357  {
358  $this->accessTokenValiditySeconds = $accessTokenValiditySeconds;
359  }
360 
365  {
366  $this->refreshTokenValiditySeconds = $refreshTokenValiditySeconds;
367  }
368 
369 
370  #[\ReturnTypeWillChange]
371  public function jsonSerialize()
372  {
373  $data = $this->toArray();
374  if (isset($data[ApiClient::FIELD_LAST_USED_AT]) && $data[ApiClient::FIELD_LAST_USED_AT] instanceof \DateTimeImmutable) {
375  $data[ApiClient::FIELD_LAST_USED_AT] = $data[ApiClient::FIELD_LAST_USED_AT]->format('Y-m-d');
376  }
377 
378  if (isset($data[ApiClient::FIELD_DELETE_AT]) && $data[ApiClient::FIELD_DELETE_AT] instanceof \DateTimeImmutable) {
379  $data[ApiClient::FIELD_DELETE_AT] = $data[ApiClient::FIELD_DELETE_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
380  }
381 
382  if (isset($data[ApiClient::FIELD_CREATED_AT]) && $data[ApiClient::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
383  $data[ApiClient::FIELD_CREATED_AT] = $data[ApiClient::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
384  }
385  return (object) $data;
386  }
387 }
setLastUsedAt(?DateTimeImmutable $lastUsedAt)
__construct(?string $id=null, ?string $name=null, ?string $scope=null, ?string $secret=null, ?DateTimeImmutable $lastUsedAt=null, ?DateTimeImmutable $deleteAt=null, ?DateTimeImmutable $createdAt=null, ?int $accessTokenValiditySeconds=null, ?int $refreshTokenValiditySeconds=null)
setRefreshTokenValiditySeconds(?int $refreshTokenValiditySeconds)
setAccessTokenValiditySeconds(?int $accessTokenValiditySeconds)