diff --git a/src/Bigcommerce/Api/Client.php b/src/Bigcommerce/Api/Client.php index a7d40ab9..7042bdb2 100644 --- a/src/Bigcommerce/Api/Client.php +++ b/src/Bigcommerce/Api/Client.php @@ -1005,6 +1005,16 @@ public static function updateSku($id, $object) return self::updateResource('/product/skus/' . $id, $object); } + /** + * Get a single coupon by given id. + * + * @param int $id customer id + * @return Coupon + */ + public static function getCoupon($id) + { + return self::getResource('/coupon/' . $id, 'Coupon'); + } /** * Get coupons @@ -1041,6 +1051,27 @@ public static function updateCoupon($id, $object) return self::updateResource('/coupons/' . $id, $object); } + /** + * Delete the given coupon. + * + * @param int $id coupon id + * @return hash|bool|mixed + */ + public static function deleteCoupon($id) + { + return self::deleteResource('/coupons/' . $id); + } + + /** + * Delete all Coupons. + * + * @return hash|bool|mixed + */ + public static function deleteAllCoupons() + { + return self::deleteResource('/coupons'); + } + /** * The request logs with usage history statistics. */ diff --git a/test/Unit/Api/ClientTest.php b/test/Unit/Api/ClientTest.php index 1460aecc..405ce6e5 100644 --- a/test/Unit/Api/ClientTest.php +++ b/test/Unit/Api/ClientTest.php @@ -532,4 +532,33 @@ public function testDeletingACustomerDeletesToTheCustomerResource() Client::deleteCustomers(); } + + public function testDeletingAllCouponDeletesToTheCouponResource() + { + $this->connection->expects($this->once()) + ->method('delete') + ->with('/coupons'); + + Client::deleteAllCoupons(); + } + + public function testDeletingACouponDeletesToTheCouponResource() + { + $this->connection->expects($this->once()) + ->method('delete') + ->with('/coupons/1'); + + Client::deleteCoupon(1); + } + + public function testGettingASpecifiedCouponReturnsThatCoupon() + { + $this->connection->expects($this->once()) + ->method('get') + ->with('/coupon/1', false) + ->will($this->returnValue(array(array(), array()))); + + $resource = Client::getCoupon(1); + $this->assertInstanceOf('Bigcommerce\\Api\\Resources\\Coupon', $resource); + } }