|
10 | 10 | use Piggy\Api\Models\Shops\Shop; |
11 | 11 | use Piggy\Api\StaticMappers\Orders\OrderMapper; |
12 | 12 | use Piggy\Api\StaticMappers\Orders\OrdersMapper; |
13 | | -use stdClass; |
14 | 13 |
|
15 | 14 | class Order |
16 | 15 | { |
@@ -95,17 +94,17 @@ class Order |
95 | 94 | protected $shop; |
96 | 95 |
|
97 | 96 | /** |
98 | | - * @var LineItem[] $lineItems |
| 97 | + * @var LineItem[] |
99 | 98 | */ |
100 | | - protected $lineItems; |
| 99 | + protected $lineItems = []; |
101 | 100 |
|
102 | 101 | /** |
103 | | - * @var AppliedDiscount[] $appliedDiscounts |
| 102 | + * @var AppliedDiscount[] |
104 | 103 | */ |
105 | 104 | protected $appliedDiscounts = []; |
106 | 105 |
|
107 | 106 | /** |
108 | | - * @var Charge[] $charges |
| 107 | + * @var Charge[] |
109 | 108 | */ |
110 | 109 | protected $charges = []; |
111 | 110 |
|
@@ -136,7 +135,7 @@ public function __construct( |
136 | 135 | string $updatedAt, |
137 | 136 | Contact $contact, |
138 | 137 | Shop $shop, |
139 | | - array $lineItems, |
| 138 | + array $lineItems = [], |
140 | 139 | array $appliedDiscounts = [], |
141 | 140 | array $charges = [] |
142 | 141 | ) { |
@@ -242,23 +241,23 @@ public function getShop(): Shop |
242 | 241 | } |
243 | 242 |
|
244 | 243 | /** |
245 | | - * @return array|LineItem[] |
| 244 | + * @return LineItem[] |
246 | 245 | */ |
247 | 246 | public function getLineItems(): array |
248 | 247 | { |
249 | 248 | return $this->lineItems; |
250 | 249 | } |
251 | 250 |
|
252 | 251 | /** |
253 | | - * @return array|AppliedDiscount[] |
| 252 | + * @return AppliedDiscount[] |
254 | 253 | */ |
255 | 254 | public function getAppliedDiscounts(): array |
256 | 255 | { |
257 | 256 | return $this->appliedDiscounts; |
258 | 257 | } |
259 | 258 |
|
260 | 259 | /** |
261 | | - * @return array|Charge[] |
| 260 | + * @return Charge[] |
262 | 261 | */ |
263 | 262 | public function charges(): array |
264 | 263 | { |
@@ -326,39 +325,42 @@ public static function create(array $body): Order |
326 | 325 | * @param string $uuid |
327 | 326 | * @param array<string, mixed> $body |
328 | 327 | * |
329 | | - * @return Order |
| 328 | + * @return array<string, mixed> |
330 | 329 | * |
331 | 330 | * @throws GuzzleException|MaintenanceModeException|PiggyRequestException |
332 | 331 | */ |
333 | | - public static function process(string $uuid, array $body): Order |
| 332 | + public static function process(string $uuid, array $body): array |
334 | 333 | { |
335 | 334 | $response = ApiClient::post(self::resourceUri."$uuid/process", $body); |
336 | 335 |
|
337 | | - return OrderMapper::map($response->getData()); |
| 336 | + return $response->getData(); |
338 | 337 | } |
339 | 338 |
|
340 | 339 | /** |
341 | 340 | * @param array<string, mixed> $body |
342 | 341 | * |
343 | | - * @return Order |
| 342 | + * @return array<string, mixed> |
344 | 343 | * |
345 | 344 | * @throws GuzzleException|MaintenanceModeException|PiggyRequestException |
346 | 345 | */ |
347 | | - public static function createAndProcess(array $body): Order |
| 346 | + public static function createAndProcess(array $body): array |
348 | 347 | { |
349 | 348 | $response = ApiClient::post(self::resourceUri."/create-and-process", $body); |
350 | 349 |
|
351 | | - return OrderMapper::map($response->getData()); |
| 350 | + return [ |
| 351 | + 'order' => OrderMapper::map($response->getData()->order), |
| 352 | + 'result' => $response->getData()->result, |
| 353 | + ]; |
352 | 354 | } |
353 | 355 |
|
354 | 356 | /** |
355 | 357 | * @param array<string, mixed> $body |
356 | 358 | * |
357 | | - * @return stdClass |
| 359 | + * @return array<string, mixed> |
358 | 360 | * |
359 | 361 | * @throws GuzzleException|MaintenanceModeException|PiggyRequestException |
360 | 362 | */ |
361 | | - public static function calculate(array $body): stdClass |
| 363 | + public static function calculate(array $body): array |
362 | 364 | { |
363 | 365 | $response = ApiClient::post(self::resourceUri."/calculate", $body); |
364 | 366 |
|
|
0 commit comments