|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Tamara\Model\Order; |
| 6 | + |
| 7 | +use Tamara\Model\Money; |
| 8 | + |
| 9 | +class InstoreOrder |
| 10 | +{ |
| 11 | + public const |
| 12 | + ORDER_ID = 'order_id', |
| 13 | + TOTAL_AMOUNT = 'total_amount', |
| 14 | + PHONE_NUMBER = 'phone_number', |
| 15 | + EMAIL = 'email', |
| 16 | + EXPIRY_TIME = 'expiry_time', |
| 17 | + ITEMS = 'items', |
| 18 | + PAYMENT_TYPE = 'payment_type', |
| 19 | + ORDER_REFERENCE_ID = 'order_reference_id', |
| 20 | + ORDER_NUMBER = 'order_number', |
| 21 | + LOCALE = 'locale', |
| 22 | + ADDITIONAL_DATA = 'additional_data'; |
| 23 | + |
| 24 | + /** |
| 25 | + * @var Money |
| 26 | + */ |
| 27 | + private $totalAmount; |
| 28 | + /** |
| 29 | + * @var string |
| 30 | + */ |
| 31 | + private $phoneNumber; |
| 32 | + /** |
| 33 | + * @var string|null |
| 34 | + */ |
| 35 | + private $email; |
| 36 | + /** |
| 37 | + * @var int|null |
| 38 | + */ |
| 39 | + private $expiryTime; |
| 40 | + /** |
| 41 | + * @var OrderItemCollection |
| 42 | + */ |
| 43 | + private $items; |
| 44 | + /** |
| 45 | + * @var string |
| 46 | + */ |
| 47 | + private $orderReferenceId; |
| 48 | + /** |
| 49 | + * @var string|null |
| 50 | + */ |
| 51 | + private $orderNumber; |
| 52 | + /** |
| 53 | + * @var array|null |
| 54 | + */ |
| 55 | + private $additionalData; |
| 56 | + /** |
| 57 | + * @var string|null |
| 58 | + */ |
| 59 | + private $locale; |
| 60 | + /** |
| 61 | + * @var string|null |
| 62 | + */ |
| 63 | + private $paymentType; |
| 64 | + |
| 65 | + public function toArray(): array |
| 66 | + { |
| 67 | + $result = [ |
| 68 | + self::TOTAL_AMOUNT => $this->getTotalAmount()->toArray(), |
| 69 | + self::PHONE_NUMBER => $this->getPhoneNumber(), |
| 70 | + self::ITEMS => $this->getItems()->toArray(), |
| 71 | + self::ORDER_REFERENCE_ID => $this->getOrderReferenceId(), |
| 72 | + ]; |
| 73 | + |
| 74 | + if ($this->getEmail() !== null) { |
| 75 | + $result[self::EMAIL] = $this->getEmail(); |
| 76 | + } |
| 77 | + if ($this->getExpiryTime() > 0) { |
| 78 | + $result[self::EXPIRY_TIME] = $this->getExpiryTime(); |
| 79 | + } |
| 80 | + if ($this->getOrderNumber() !== null) { |
| 81 | + $result[self::ORDER_NUMBER] = $this->getOrderNumber(); |
| 82 | + } |
| 83 | + if ($this->getAdditionalData() !== null) { |
| 84 | + $result[self::ADDITIONAL_DATA] = $this->getAdditionalData(); |
| 85 | + } |
| 86 | + if ($this->getLocale() !== null) { |
| 87 | + $result[self::LOCALE] = $this->getLocale(); |
| 88 | + } |
| 89 | + if ($this->getPaymentType() !== null) { |
| 90 | + $result[self::PAYMENT_TYPE] = $this->getPaymentType(); |
| 91 | + } |
| 92 | + |
| 93 | + return $result; |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * @return Money |
| 98 | + */ |
| 99 | + public function getTotalAmount(): Money |
| 100 | + { |
| 101 | + return $this->totalAmount; |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * @param Money $totalAmount |
| 106 | + * @return InstoreOrder |
| 107 | + */ |
| 108 | + public function setTotalAmount(Money $totalAmount): InstoreOrder |
| 109 | + { |
| 110 | + $this->totalAmount = $totalAmount; |
| 111 | + return $this; |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * @return string |
| 116 | + */ |
| 117 | + public function getPhoneNumber(): string |
| 118 | + { |
| 119 | + return $this->phoneNumber; |
| 120 | + } |
| 121 | + |
| 122 | + /** |
| 123 | + * @param string $phoneNumber |
| 124 | + * @return InstoreOrder |
| 125 | + */ |
| 126 | + public function setPhoneNumber(string $phoneNumber): InstoreOrder |
| 127 | + { |
| 128 | + $this->phoneNumber = $phoneNumber; |
| 129 | + return $this; |
| 130 | + } |
| 131 | + |
| 132 | + /** |
| 133 | + * @return OrderItemCollection |
| 134 | + */ |
| 135 | + public function getItems(): OrderItemCollection |
| 136 | + { |
| 137 | + return $this->items; |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * @param OrderItemCollection $items |
| 142 | + * @return InstoreOrder |
| 143 | + */ |
| 144 | + public function setItems(OrderItemCollection $items): InstoreOrder |
| 145 | + { |
| 146 | + $this->items = $items; |
| 147 | + return $this; |
| 148 | + } |
| 149 | + |
| 150 | + /** |
| 151 | + * @return string |
| 152 | + */ |
| 153 | + public function getOrderReferenceId(): string |
| 154 | + { |
| 155 | + return $this->orderReferenceId; |
| 156 | + } |
| 157 | + |
| 158 | + /** |
| 159 | + * @param string $orderReferenceId |
| 160 | + * @return InstoreOrder |
| 161 | + */ |
| 162 | + public function setOrderReferenceId(string $orderReferenceId): InstoreOrder |
| 163 | + { |
| 164 | + $this->orderReferenceId = $orderReferenceId; |
| 165 | + return $this; |
| 166 | + } |
| 167 | + |
| 168 | + /** |
| 169 | + * @return string|null |
| 170 | + */ |
| 171 | + public function getEmail(): ?string |
| 172 | + { |
| 173 | + return $this->email; |
| 174 | + } |
| 175 | + |
| 176 | + /** |
| 177 | + * @param string|null $email |
| 178 | + * @return InstoreOrder |
| 179 | + */ |
| 180 | + public function setEmail(?string $email): InstoreOrder |
| 181 | + { |
| 182 | + $this->email = $email; |
| 183 | + return $this; |
| 184 | + } |
| 185 | + |
| 186 | + /** |
| 187 | + * @return int|null |
| 188 | + */ |
| 189 | + public function getExpiryTime(): ?int |
| 190 | + { |
| 191 | + return $this->expiryTime; |
| 192 | + } |
| 193 | + |
| 194 | + /** |
| 195 | + * @param int|null $expiryTime |
| 196 | + * @return InstoreOrder |
| 197 | + */ |
| 198 | + public function setExpiryTime(?int $expiryTime): InstoreOrder |
| 199 | + { |
| 200 | + $this->expiryTime = $expiryTime; |
| 201 | + return $this; |
| 202 | + } |
| 203 | + |
| 204 | + /** |
| 205 | + * @return string|null |
| 206 | + */ |
| 207 | + public function getOrderNumber(): ?string |
| 208 | + { |
| 209 | + return $this->orderNumber; |
| 210 | + } |
| 211 | + |
| 212 | + /** |
| 213 | + * @param string|null $orderNumber |
| 214 | + * @return InstoreOrder |
| 215 | + */ |
| 216 | + public function setOrderNumber(?string $orderNumber): InstoreOrder |
| 217 | + { |
| 218 | + $this->orderNumber = $orderNumber; |
| 219 | + return $this; |
| 220 | + } |
| 221 | + |
| 222 | + /** |
| 223 | + * @return array|null |
| 224 | + */ |
| 225 | + public function getAdditionalData(): ?array |
| 226 | + { |
| 227 | + return $this->additionalData; |
| 228 | + } |
| 229 | + |
| 230 | + /** |
| 231 | + * @param array|null $additionalData |
| 232 | + * @return InstoreOrder |
| 233 | + */ |
| 234 | + public function setAdditionalData(?array $additionalData): InstoreOrder |
| 235 | + { |
| 236 | + $this->additionalData = $additionalData; |
| 237 | + return $this; |
| 238 | + } |
| 239 | + |
| 240 | + /** |
| 241 | + * @return string|null |
| 242 | + */ |
| 243 | + public function getLocale(): ?string |
| 244 | + { |
| 245 | + return $this->locale; |
| 246 | + } |
| 247 | + |
| 248 | + /** |
| 249 | + * @param string|null $locale |
| 250 | + * @return InstoreOrder |
| 251 | + */ |
| 252 | + public function setLocale(?string $locale): InstoreOrder |
| 253 | + { |
| 254 | + $this->locale = $locale; |
| 255 | + return $this; |
| 256 | + } |
| 257 | + |
| 258 | + /** |
| 259 | + * @return string|null |
| 260 | + */ |
| 261 | + public function getPaymentType(): ?string |
| 262 | + { |
| 263 | + return $this->paymentType; |
| 264 | + } |
| 265 | + |
| 266 | + /** |
| 267 | + * @param string|null $paymentType |
| 268 | + * @return InstoreOrder |
| 269 | + */ |
| 270 | + public function setPaymentType(?string $paymentType): InstoreOrder |
| 271 | + { |
| 272 | + $this->paymentType = $paymentType; |
| 273 | + return $this; |
| 274 | + } |
| 275 | +} |
0 commit comments