66use Piggy \Api \ApiClient ;
77use Piggy \Api \Exceptions \MaintenanceModeException ;
88use Piggy \Api \Exceptions \PiggyRequestException ;
9- use Piggy \Api \StaticMappers \Orders \OrderMapper ;
9+ use Piggy \Api \StaticMappers \Orders \OrderReturnMapper ;
10+ use stdClass ;
1011
1112class 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