Skip to content

Commit 15aaf1b

Browse files
committed
Merge pull request #129 from aleachjr/add-coupon-count
BIG-16447: add coupon count method
2 parents 825638c + 8722e27 commit 15aaf1b

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Bigcommerce/Api/Client.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,11 @@ public static function getOptions($filter = array())
512512
return self::getCollection('/options' . $filter->toQuery(), 'Option');
513513
}
514514

515-
/** create options **/
515+
/**
516+
* Create Options
517+
* @param $object
518+
* @return hash|bool|mixed
519+
*/
516520
public static function createOptions($object)
517521
{
518522
return self::createResource('/options', $object);
@@ -1048,7 +1052,7 @@ public static function updateSku($id, $object)
10481052
*/
10491053
public static function getCoupon($id)
10501054
{
1051-
return self::getResource('/coupon/' . $id, 'Coupon');
1055+
return self::getResource('/coupons/' . $id, 'Coupon');
10521056
}
10531057

10541058
/**
@@ -1107,6 +1111,16 @@ public static function deleteAllCoupons()
11071111
return self::deleteResource('/coupons');
11081112
}
11091113

1114+
/**
1115+
* Return the number of coupons
1116+
*
1117+
* @return int
1118+
*/
1119+
public static function getCouponsCount()
1120+
{
1121+
return self::getCount('/coupons/count');
1122+
}
1123+
11101124
/**
11111125
* The request logs with usage history statistics.
11121126
*/

test/Unit/Api/ClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function testGettingASpecificResourceReturnsACollectionOfThatResource($pa
274274
*/
275275
public function testGettingTheCountOfACollectionReturnsThatCollectionsCount($path, $fnName, $class)
276276
{
277-
if (in_array($path, array('coupons', 'order_statuses', 'products/skus', 'requestlogs'))) {
277+
if (in_array($path, array('order_statuses', 'products/skus', 'requestlogs'))) {
278278
$this->markTestSkipped(sprintf('The PHP client does not support getting the count of %s', $path));
279279
}
280280

@@ -555,7 +555,7 @@ public function testGettingASpecifiedCouponReturnsThatCoupon()
555555
{
556556
$this->connection->expects($this->once())
557557
->method('get')
558-
->with('/coupon/1', false)
558+
->with('/coupons/1', false)
559559
->will($this->returnValue(array(array(), array())));
560560

561561
$resource = Client::getCoupon(1);

0 commit comments

Comments
 (0)