55use Illuminate \Http \JsonResponse ;
66use GuzzleHttp \Exception \GuzzleException ;
77use Codeboxr \EcourierCourier \Exceptions \EcourierException ;
8+ use Codeboxr \EcourierCourier \Exceptions \EcourierValidationException ;
89
910class OrderApi extends BaseApi
1011{
@@ -28,10 +29,30 @@ public function packageList()
2829 *
2930 * @return JsonResponse
3031 * @throws EcourierException
31- * @throws GuzzleException
32+ * @throws GuzzleException|EcourierValidationException
3233 */
3334 public function create ($ array )
3435 {
36+ $ this ->validation ($ array , [
37+ "pick_district " ,
38+ "pick_thana " ,
39+ "pick_union " ,
40+ "pick_address " ,
41+ "pick_mobile " ,
42+ "recipient_name " ,
43+ "recipient_mobile " ,
44+ "recipient_city " ,
45+ "recipient_area " ,
46+ "recipient_thana " ,
47+ "recipient_union " ,
48+ "recipient_address " ,
49+ "package_code " ,
50+ "product_price " ,
51+ "payment_method " ,
52+ "ep_id " ,
53+ "pick_hub "
54+ ]);
55+
3556 $ response = $ this ->authorization ()->send ("POST " , "api/order-place-reseller " , $ array );
3657 return response ()->json ([
3758 "success " => $ response ->success ,
@@ -41,10 +62,34 @@ public function create($array)
4162 ]);
4263 }
4364
44-
65+ /**
66+ * @param $trackingId
67+ *
68+ * @return mixed
69+ * @throws EcourierException
70+ * @throws GuzzleException
71+ */
4572 public function tracking ($ trackingId )
4673 {
4774 $ response = $ this ->authorization ()->send ("POST " , "api/track " , ["ecr " => $ trackingId ]);
4875 return $ response ;
4976 }
77+
78+
79+ /**
80+ * Cancel Order
81+ *
82+ * @param array $array
83+ *
84+ * @return mixed
85+ * @throws EcourierException
86+ * @throws EcourierValidationException
87+ * @throws GuzzleException
88+ */
89+ public function cancelOrder ($ array )
90+ {
91+ $ this ->validation ($ array , ["tracking " , "comment " ]);
92+ $ response = $ this ->authorization ()->send ("POST " , "api/cancel-order " , $ array );
93+ return $ response ;
94+ }
5095}
0 commit comments