Skip to content

Commit cbb7175

Browse files
authored
Merge pull request #181 from HubLogix/add-productgoogleproductsearch-resource
Add ProductGoogleProductSearch resource
2 parents b0a8ad8 + a3f816c commit cbb7175

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

src/Bigcommerce/Api/Client.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ private static function mapResource($resource, $object)
384384

385385
$baseResource = __NAMESPACE__ . '\\' . $resource;
386386
$class = (class_exists($baseResource)) ? $baseResource : 'Bigcommerce\\Api\\Resources\\' . $resource;
387-
388387
return new $class($object);
389388
}
390389

@@ -1227,6 +1226,16 @@ public static function getSkusCount()
12271226
return self::getCount('/products/skus/count');
12281227
}
12291228

1229+
/**
1230+
* Returns the googleproductsearch mapping for a product.
1231+
*
1232+
* @return Resources\ProductGoogleProductSearch
1233+
*/
1234+
public static function getGoogleProductSearch($productId)
1235+
{
1236+
return self::getResource('/products/' . $productId . '/googleproductsearch', 'ProductGoogleProductSearch');
1237+
}
1238+
12301239
/**
12311240
* Get a single coupon by given id.
12321241
*
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Bigcommerce\Api\Resources;
4+
5+
use Bigcommerce\Api\Resource;
6+
use Bigcommerce\Api\Client;
7+
8+
/**
9+
* A product review.
10+
*/
11+
class ProductGoogleProductSearch extends Resource
12+
{
13+
14+
}

test/Unit/Api/ClientTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,17 @@ public function testUpdatingASkuPutsToTheSkuResource()
422422
Client::updateSku(1, array());
423423
}
424424

425+
public function testGettingProductGoogleProductSearch()
426+
{
427+
$this->connection->expects($this->once())
428+
->method('get')
429+
->with($this->basePath . '/products/1/googleproductsearch')
430+
->will($this->returnValue((object)array()));
431+
432+
$resource = Client::getGoogleProductSearch(1);
433+
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\ProductGoogleProductSearch', $resource);
434+
}
435+
425436
public function testGettingProductImagesReturnsCollectionOfProductImages()
426437
{
427438
$this->connection->expects($this->once())

0 commit comments

Comments
 (0)