Skip to content

Commit

Permalink
Merge pull request #129 from aleachjr/add-coupon-count
Browse files Browse the repository at this point in the history
BIG-16447: add coupon count method
  • Loading branch information
aleachjr committed Mar 21, 2015
2 parents 825638c + 8722e27 commit 15aaf1b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/Bigcommerce/Api/Client.php
Expand Up @@ -512,7 +512,11 @@ public static function getOptions($filter = array())
return self::getCollection('/options' . $filter->toQuery(), 'Option');
}

/** create options **/
/**
* Create Options
* @param $object
* @return hash|bool|mixed
*/
public static function createOptions($object)
{
return self::createResource('/options', $object);
Expand Down Expand Up @@ -1048,7 +1052,7 @@ public static function updateSku($id, $object)
*/
public static function getCoupon($id)
{
return self::getResource('/coupon/' . $id, 'Coupon');
return self::getResource('/coupons/' . $id, 'Coupon');
}

/**
Expand Down Expand Up @@ -1107,6 +1111,16 @@ public static function deleteAllCoupons()
return self::deleteResource('/coupons');
}

/**
* Return the number of coupons
*
* @return int
*/
public static function getCouponsCount()
{
return self::getCount('/coupons/count');
}

/**
* The request logs with usage history statistics.
*/
Expand Down
4 changes: 2 additions & 2 deletions test/Unit/Api/ClientTest.php
Expand Up @@ -274,7 +274,7 @@ public function testGettingASpecificResourceReturnsACollectionOfThatResource($pa
*/
public function testGettingTheCountOfACollectionReturnsThatCollectionsCount($path, $fnName, $class)
{
if (in_array($path, array('coupons', 'order_statuses', 'products/skus', 'requestlogs'))) {
if (in_array($path, array('order_statuses', 'products/skus', 'requestlogs'))) {
$this->markTestSkipped(sprintf('The PHP client does not support getting the count of %s', $path));
}

Expand Down Expand Up @@ -555,7 +555,7 @@ public function testGettingASpecifiedCouponReturnsThatCoupon()
{
$this->connection->expects($this->once())
->method('get')
->with('/coupon/1', false)
->with('/coupons/1', false)
->will($this->returnValue(array(array(), array())));

$resource = Client::getCoupon(1);
Expand Down

0 comments on commit 15aaf1b

Please sign in to comment.