Skip to content

Commit

Permalink
Merge pull request #124 from bc-joshroe/api-fix-1
Browse files Browse the repository at this point in the history
Adding getOrderStatus
  • Loading branch information
aleachjr committed Mar 4, 2015
2 parents 34e6ee8 + 0bdd143 commit 246e198
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/Bigcommerce/Api/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -960,14 +960,24 @@ public static function getOptionSet($id)
return self::getResource('/optionsets/' . $id, 'OptionSet');
}

/**
* Status codes used to represent the state of an order.
*
* @return array
*/
public static function getOrderStatus($id)
{
return self::getResource('/order_statuses/' . $id, 'OrderStatus');
}

/**
* Status codes used to represent the state of an order.
*
* @return array
*/
public static function getOrderStatuses()
{
return self::getCollection('/orderstatuses', 'OrderStatus');
return self::getCollection('/order_statuses', 'OrderStatus');
}

/**
Expand Down
17 changes: 14 additions & 3 deletions test/Unit/Api/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function collections()
array('orders', 'getOrders', 'Order'),
array('customers', 'getCustomers', 'Customer'),
array('coupons', 'getCoupons', 'Coupon'),
array('orderstatuses', 'getOrderStatuses', 'OrderStatus'),
array('order_statuses', 'getOrderStatuses', 'OrderStatus'),
array('categories', 'getCategories', 'Category'),
array('options', 'getOptions', 'Option'),
array('optionsets', 'getOptionSets', 'OptionSet'),
Expand Down Expand Up @@ -274,8 +274,8 @@ public function testGettingASpecificResourceReturnsACollectionOfThatResource($pa
*/
public function testGettingTheCountOfACollectionReturnsThatCollectionsCount($path, $fnName, $class)
{
if (in_array($path, array('coupons', 'orderstatuses', 'products/skus', 'requestlogs'))) {
$this->markTestSkipped(sprintf('Getting the count The php client does not support getting the count of %s', $path));
if (in_array($path, array('coupons', 'order_statuses', 'products/skus', 'requestlogs'))) {
$this->markTestSkipped(sprintf('The PHP client does not support getting the count of %s', $path));
}

$this->connection->expects($this->once())
Expand Down Expand Up @@ -561,4 +561,15 @@ public function testGettingASpecifiedCouponReturnsThatCoupon()
$resource = Client::getCoupon(1);
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\Coupon', $resource);
}

public function testGettingASpecifiedOrderStatusReturnsThatOrderStatus()
{
$this->connection->expects($this->once())
->method('get')
->with('/order_statuses/1', false)
->will($this->returnValue(array(array(), array())));

$resource = Client::getOrderStatus(1);
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\OrderStatus', $resource);
}
}

0 comments on commit 246e198

Please sign in to comment.