Skip to content

Commit

Permalink
Merge pull request #181 from HubLogix/add-productgoogleproductsearch-…
Browse files Browse the repository at this point in the history
…resource

Add ProductGoogleProductSearch resource
  • Loading branch information
bookernath authored Aug 22, 2018
2 parents b0a8ad8 + a3f816c commit cbb7175
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 @@ -1227,6 +1226,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 cbb7175

Please sign in to comment.