File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -1005,6 +1005,16 @@ public static function updateSku($id, $object)
1005
1005
return self ::updateResource ('/product/skus/ ' . $ id , $ object );
1006
1006
}
1007
1007
1008
+ /**
1009
+ * Get a single coupon by given id.
1010
+ *
1011
+ * @param int $id customer id
1012
+ * @return Coupon
1013
+ */
1014
+ public static function getCoupon ($ id )
1015
+ {
1016
+ return self ::getResource ('/coupon/ ' . $ id , 'Coupon ' );
1017
+ }
1008
1018
1009
1019
/**
1010
1020
* Get coupons
@@ -1041,6 +1051,27 @@ public static function updateCoupon($id, $object)
1041
1051
return self ::updateResource ('/coupons/ ' . $ id , $ object );
1042
1052
}
1043
1053
1054
+ /**
1055
+ * Delete the given coupon.
1056
+ *
1057
+ * @param int $id coupon id
1058
+ * @return hash|bool|mixed
1059
+ */
1060
+ public static function deleteCoupon ($ id )
1061
+ {
1062
+ return self ::deleteResource ('/coupons/ ' . $ id );
1063
+ }
1064
+
1065
+ /**
1066
+ * Delete all Coupons.
1067
+ *
1068
+ * @return hash|bool|mixed
1069
+ */
1070
+ public static function deleteAllCoupons ()
1071
+ {
1072
+ return self ::deleteResource ('/coupons ' );
1073
+ }
1074
+
1044
1075
/**
1045
1076
* The request logs with usage history statistics.
1046
1077
*/
Original file line number Diff line number Diff line change @@ -532,4 +532,33 @@ public function testDeletingACustomerDeletesToTheCustomerResource()
532
532
533
533
Client::deleteCustomers ();
534
534
}
535
+
536
+ public function testDeletingAllCouponDeletesToTheCouponResource ()
537
+ {
538
+ $ this ->connection ->expects ($ this ->once ())
539
+ ->method ('delete ' )
540
+ ->with ('/coupons ' );
541
+
542
+ Client::deleteAllCoupons ();
543
+ }
544
+
545
+ public function testDeletingACouponDeletesToTheCouponResource ()
546
+ {
547
+ $ this ->connection ->expects ($ this ->once ())
548
+ ->method ('delete ' )
549
+ ->with ('/coupons/1 ' );
550
+
551
+ Client::deleteCoupon (1 );
552
+ }
553
+
554
+ public function testGettingASpecifiedCouponReturnsThatCoupon ()
555
+ {
556
+ $ this ->connection ->expects ($ this ->once ())
557
+ ->method ('get ' )
558
+ ->with ('/coupon/1 ' , false )
559
+ ->will ($ this ->returnValue (array (array (), array ())));
560
+
561
+ $ resource = Client::getCoupon (1 );
562
+ $ this ->assertInstanceOf ('Bigcommerce \\Api \\Resources \\Coupon ' , $ resource );
563
+ }
535
564
}
You can’t perform that action at this time.
0 commit comments