Skip to content

Commit

Permalink
Add ProductGoogleProductSearch resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Morrissey committed Aug 3, 2016
1 parent 71c6d49 commit a3f816c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Bigcommerce/Api/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ private static function mapResource($resource, $object)

$baseResource = __NAMESPACE__ . '\\' . $resource;
$class = (class_exists($baseResource)) ? $baseResource : 'Bigcommerce\\Api\\Resources\\' . $resource;

return new $class($object);
}

Expand Down Expand Up @@ -1222,6 +1221,16 @@ public static function getSkusCount()
return self::getCount('/products/skus/count');
}

/**
* Returns the googleproductsearch mapping for a product.
*
* @return Resources\ProductGoogleProductSearch
*/
public static function getGoogleProductSearch($productId)
{
return self::getResource('/products/' . $productId . '/googleproductsearch', 'ProductGoogleProductSearch');
}

/**
* Get a single coupon by given id.
*
Expand Down
14 changes: 14 additions & 0 deletions src/Bigcommerce/Api/Resources/ProductGoogleProductSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Bigcommerce\Api\Resources;

use Bigcommerce\Api\Resource;
use Bigcommerce\Api\Client;

/**
* A product review.
*/
class ProductGoogleProductSearch extends Resource
{

}
11 changes: 11 additions & 0 deletions test/Unit/Api/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,17 @@ public function testUpdatingASkuPutsToTheSkuResource()
Client::updateSku(1, array());
}

public function testGettingProductGoogleProductSearch()
{
$this->connection->expects($this->once())
->method('get')
->with($this->basePath . '/products/1/googleproductsearch')
->will($this->returnValue((object)array()));

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

public function testGettingProductImagesReturnsCollectionOfProductImages()
{
$this->connection->expects($this->once())
Expand Down

0 comments on commit a3f816c

Please sign in to comment.