Skip to content

Commit 9297420

Browse files
wip
1 parent 5857210 commit 9297420

6 files changed

Lines changed: 78 additions & 14 deletions

File tree

src/Mappers/Orders/LineItemMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static function map(stdClass $data): LineItem
1616
$product = $mapper->map($data->product);
1717
}
1818

19-
$subLineItems = null;
19+
$subLineItems = [];
2020
if (isset($data->sub_line_items)) {
2121
$mapper = new SubLineItemsMapper();
2222
$subLineItems = $mapper->map($data->sub_line_items);

src/Mappers/Orders/OrderMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function map(stdClass $data): Order
2525

2626
$lineItems = [];
2727
if (isset($data->line_items)) {
28-
$mapper = new LineItemMapper();
28+
$mapper = new LineItemsMapper();
2929
$lineItems = $mapper->map($data->line_items);
3030
}
3131

src/Mappers/Products/ProductMapper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ public function map(stdClass $data): Product
1717
}
1818

1919
return new Product(
20-
$data->uuid,
20+
$data->uuid ?? '',
2121
$data->external_identifier,
2222
$data->name,
23-
$data->description,
24-
$categories
23+
$data->description ?? null,
24+
$categories ?? null
2525
);
2626
}
2727
}

src/Models/Orders/Order.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ class Order
8484
protected $updatedAt;
8585

8686
/**
87-
* @var Contact
87+
* @var Contact|null
8888
*/
8989
protected $contact;
9090

9191
/**
92-
* @var Shop
92+
* @var Shop|null
9393
*/
9494
protected $shop;
9595

@@ -133,8 +133,8 @@ public function __construct(
133133
?string $paidAt,
134134
string $createdAt,
135135
string $updatedAt,
136-
Contact $contact,
137-
Shop $shop,
136+
?Contact $contact,
137+
?Shop $shop,
138138
array $lineItems = [],
139139
array $appliedDiscounts = [],
140140
array $charges = []
@@ -230,12 +230,12 @@ public function getUpdatedAt(): string
230230
return $this->updatedAt;
231231
}
232232

233-
public function getContact(): Contact
233+
public function getContact(): ?Contact
234234
{
235235
return $this->contact;
236236
}
237237

238-
public function getShop(): Shop
238+
public function getShop(): ?Shop
239239
{
240240
return $this->shop;
241241
}

src/Models/Orders/SubLineItem.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class SubLineItem
4242
protected $totalAmount;
4343

4444
/**
45-
* @var LineItem
45+
* @var LineItem|null
4646
*/
4747
protected $lineItem;
4848

@@ -59,7 +59,7 @@ public function __construct(
5959
string $price,
6060
?int $discountAmount,
6161
int $totalAmount,
62-
LineItem $lineItem,
62+
?LineItem $lineItem,
6363
?Product $product
6464
) {
6565
$this->uuid = $uuid;
@@ -108,7 +108,7 @@ public function getTotalAmount(): int
108108
return $this->totalAmount;
109109
}
110110

111-
public function getLineItem(): LineItem
111+
public function getLineItem(): ?LineItem
112112
{
113113
return $this->lineItem;
114114
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace Piggy\Api\Tests\OAuth\Orders;
4+
5+
use Piggy\Api\Tests\OAuthTestCase;
6+
7+
class OrdersResourceTest extends OAuthTestCase
8+
{
9+
/**
10+
* @test
11+
*/
12+
public function it_can_list_orders(): void
13+
{
14+
//
15+
}
16+
17+
/**
18+
* @test
19+
*/
20+
public function it_can_get_an_order(): void
21+
{
22+
//
23+
}
24+
25+
/**
26+
* @test
27+
*/
28+
public function it_can_find_an_order(): void
29+
{
30+
//
31+
}
32+
33+
/**
34+
* @test
35+
*/
36+
public function it_can_create_orders(): void
37+
{
38+
//
39+
}
40+
41+
/**
42+
* @test
43+
*/
44+
public function it_can_process_orders(): void
45+
{
46+
//
47+
}
48+
49+
/**
50+
* @test
51+
*/
52+
public function it_can_create_and_process_orders(): void
53+
{
54+
//
55+
}
56+
57+
/**
58+
* @test
59+
*/
60+
public function it_can_calculate_orders(): void
61+
{
62+
//
63+
}
64+
}

0 commit comments

Comments
 (0)