Skip to content

Commit 7b29f75

Browse files
wip
1 parent 20117a7 commit 7b29f75

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

src/Models/Orders/OrderReturn.php

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
use Piggy\Api\ApiClient;
77
use Piggy\Api\Exceptions\MaintenanceModeException;
88
use Piggy\Api\Exceptions\PiggyRequestException;
9-
use Piggy\Api\StaticMappers\Orders\OrderMapper;
9+
use Piggy\Api\StaticMappers\Orders\OrderReturnMapper;
10+
use stdClass;
1011

1112
class OrderReturn
1213
{
@@ -103,14 +104,47 @@ public function getSubLineItemReturns(): array
103104
/**
104105
* @param array<string, mixed> $body
105106
*
106-
* @return Order
107+
* @return OrderReturn
107108
*
108109
* @throws GuzzleException|MaintenanceModeException|PiggyRequestException
109110
*/
110-
public static function create(array $body): Order
111+
public static function create(array $body): OrderReturn
111112
{
112113
$response = ApiClient::post(self::resourceUri, $body);
113114

114-
return OrderMapper::map($response->getData());
115+
return OrderReturnMapper::map($response->getData());
116+
}
117+
118+
/**
119+
* @param string $uuid
120+
* @param array<string, mixed> $body
121+
*
122+
* @return stdClass
123+
*
124+
* @throws GuzzleException|MaintenanceModeException|PiggyRequestException
125+
*/
126+
public static function process(string $uuid, array $body = []): stdClass
127+
{
128+
$response = ApiClient::post(self::resourceUri."$uuid/process", $body);
129+
130+
return $response->getData();
131+
}
132+
133+
134+
/**
135+
* @param array<string, mixed> $body
136+
*
137+
* @return array<string, mixed>
138+
*
139+
* @throws GuzzleException|MaintenanceModeException|PiggyRequestException
140+
*/
141+
public static function createAndProcess(array $body): array
142+
{
143+
$response = ApiClient::post(self::resourceUri."/create-and-process", $body);
144+
145+
return [
146+
'return' => OrderReturnMapper::map($response->getData()->return),
147+
'result' => $response->getData()->result,
148+
];
115149
}
116150
}

0 commit comments

Comments
 (0)