commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
DiscountCodeCreatedMessagePayloadModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
17 use stdClass;
18 
23 {
24  public const DISCRIMINATOR_VALUE = 'DiscountCodeCreated';
29  protected $type;
30 
35  protected $discountCode;
36 
37 
41  public function __construct(
43  ?string $type = null
44  ) {
45  $this->discountCode = $discountCode;
46  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
47  }
48 
53  public function getType()
54  {
55  if (is_null($this->type)) {
57  $data = $this->raw(self::FIELD_TYPE);
58  if (is_null($data)) {
59  return null;
60  }
61  $this->type = (string) $data;
62  }
63 
64  return $this->type;
65  }
66 
73  public function getDiscountCode()
74  {
75  if (is_null($this->discountCode)) {
77  $data = $this->raw(self::FIELD_DISCOUNT_CODE);
78  if (is_null($data)) {
79  return null;
80  }
81 
82  $this->discountCode = DiscountCodeModel::of($data);
83  }
84 
85  return $this->discountCode;
86  }
87 
88 
92  public function setDiscountCode(?DiscountCode $discountCode): void
93  {
94  $this->discountCode = $discountCode;
95  }
96 }