Skip to content

Commit b8bf1ee

Browse files
authored
Merge pull request #243 from Rickyxstar/master
Use product custom fields endpoints form official documentation to stop random 401 status codes.
2 parents a5950ee + cc6ad3b commit b8bf1ee

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/Bigcommerce/Api/Client.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ public static function getProductImages($id)
495495
*/
496496
public static function getProductCustomFields($id)
497497
{
498-
return self::getCollection('/products/' . $id . '/customfields', 'ProductCustomField');
498+
return self::getCollection('/products/' . $id . '/custom_fields', 'ProductCustomField');
499499
}
500500

501501
/**
@@ -506,7 +506,7 @@ public static function getProductCustomFields($id)
506506
*/
507507
public static function getProductCustomField($product_id, $id)
508508
{
509-
return self::getResource('/products/' . $product_id . '/customfields/' . $id, 'ProductCustomField');
509+
return self::getResource('/products/' . $product_id . '/custom_fields/' . $id, 'ProductCustomField');
510510
}
511511

512512
/**
@@ -518,7 +518,7 @@ public static function getProductCustomField($product_id, $id)
518518
*/
519519
public static function createProductCustomField($product_id, $object)
520520
{
521-
return self::createResource('/products/' . $product_id . '/customfields', $object);
521+
return self::createResource('/products/' . $product_id . '/custom_fields', $object);
522522
}
523523

524524
/**
@@ -542,7 +542,7 @@ public static function getProductReviews($id)
542542
*/
543543
public static function updateProductCustomField($product_id, $id, $object)
544544
{
545-
return self::updateResource('/products/' . $product_id . '/customfields/' . $id, $object);
545+
return self::updateResource('/products/' . $product_id . '/custom_fields/' . $id, $object);
546546
}
547547

548548
/**
@@ -554,7 +554,7 @@ public static function updateProductCustomField($product_id, $id, $object)
554554
*/
555555
public static function deleteProductCustomField($product_id, $id)
556556
{
557-
return self::deleteResource('/products/' . $product_id . '/customfields/' . $id);
557+
return self::deleteResource('/products/' . $product_id . '/custom_fields/' . $id);
558558
}
559559

560560
/**
@@ -1916,7 +1916,7 @@ public static function updateOptionValue($optionId, $optionValueId, $object)
19161916
$object
19171917
);
19181918
}
1919-
1919+
19201920
/**
19211921
* Returns all webhooks.
19221922
*
@@ -1926,7 +1926,7 @@ public static function listWebhooks()
19261926
{
19271927
return self::getCollection('/hooks');
19281928
}
1929-
1929+
19301930
/**
19311931
* Returns data for a specific web-hook.
19321932
*
@@ -1937,7 +1937,7 @@ public static function getWebhook($id)
19371937
{
19381938
return self::getResource('/hooks/' . $id);
19391939
}
1940-
1940+
19411941
/**
19421942
* Creates a web-hook.
19431943
*
@@ -1948,7 +1948,7 @@ public static function createWebhook($object)
19481948
{
19491949
return self::createResource('/hooks', $object);
19501950
}
1951-
1951+
19521952
/**
19531953
* Updates the given webhook.
19541954
*
@@ -1960,7 +1960,7 @@ public static function updateWebhook($id, $object)
19601960
{
19611961
return self::updateResource('/hooks/' . $id, $object);
19621962
}
1963-
1963+
19641964
/**
19651965
* Delete the given webhook.
19661966
*
@@ -2040,7 +2040,7 @@ public static function deleteShippingMethod($zoneId, $methodId)
20402040
{
20412041
return self::deleteResource('/shipping/zones/'. $zoneId . '/methods/'. $methodId);
20422042
}
2043-
2043+
20442044
/**
20452045
* Get collection of product skus by Product
20462046
*

test/Unit/Api/ClientTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public function testGettingProductCustomFieldsReturnsCollectionOfProductCustomFi
449449
{
450450
$this->connection->expects($this->once())
451451
->method('get')
452-
->with($this->basePath . '/products/1/customfields', false)
452+
->with($this->basePath . '/products/1/custom_fields', false)
453453
->will($this->returnValue(array(array(), array())));
454454

455455
$collection = Client::getProductCustomFields(1);
@@ -474,7 +474,7 @@ public function testGettingASpecifiedProductCustomFieldReturnsThatProductCustomF
474474
{
475475
$this->connection->expects($this->once())
476476
->method('get')
477-
->with($this->basePath . '/products/1/customfields/1', false)
477+
->with($this->basePath . '/products/1/custom_fields/1', false)
478478
->will($this->returnValue(array(array(), array())));
479479

480480
$resource = Client::getProductCustomField(1, 1);
@@ -560,7 +560,7 @@ public function testCreatingAProductCustomFieldPostsToTheProductCustomFieldResou
560560
{
561561
$this->connection->expects($this->once())
562562
->method('post')
563-
->with($this->basePath . '/products/1/customfields', (object)array());
563+
->with($this->basePath . '/products/1/custom_fields', (object)array());
564564

565565
Client::createProductCustomField(1, array());
566566
}
@@ -578,7 +578,7 @@ public function testUpdatingAProductCustomFieldPutsToTheProductCustomFieldResour
578578
{
579579
$this->connection->expects($this->once())
580580
->method('put')
581-
->with($this->basePath . '/products/1/customfields/1', (object)array());
581+
->with($this->basePath . '/products/1/custom_fields/1', (object)array());
582582

583583
Client::updateProductCustomField(1, 1, array());
584584
}
@@ -596,7 +596,7 @@ public function testDeletingAProductCustomFieldDeletesToTheProductCustomFieldRes
596596
{
597597
$this->connection->expects($this->once())
598598
->method('delete')
599-
->with($this->basePath . '/products/1/customfields/1');
599+
->with($this->basePath . '/products/1/custom_fields/1');
600600

601601
Client::deleteProductCustomField(1, 1);
602602
}
@@ -852,8 +852,8 @@ public function testDeletingAllGiftCertificatesDeletesToTheAllGiftCertificatesRe
852852

853853
Client::deleteAllGiftCertificates();
854854
}
855-
856-
855+
856+
857857
public function testGettingWebhooksReturnsAllWebhooks()
858858
{
859859
$this->connection->expects($this->once())
@@ -866,7 +866,7 @@ public function testGettingWebhooksReturnsAllWebhooks()
866866
$this->assertInstanceOf('Bigcommerce\\Api\\Resource', $resource);
867867
}
868868
}
869-
869+
870870
public function testGettingSpecifiedWebhookReturnsTheSpecifiedWebhook()
871871
{
872872
$this->connection->expects($this->once())
@@ -876,7 +876,7 @@ public function testGettingSpecifiedWebhookReturnsTheSpecifiedWebhook()
876876
$resource = Client::getWebhook(1);
877877
$this->assertInstanceOf('Bigcommerce\\Api\\Resource', $resource);
878878
}
879-
879+
880880
public function testCreatingWebhookPostsToTheSpecifiedResource()
881881
{
882882
$this->connection->expects($this->once())
@@ -891,7 +891,7 @@ public function testUpdatingWebhookPutsToTheSpecifiedResource()
891891
->with($this->basePath . '/hooks/1', (object)array());
892892
Client::updateWebhook(1, array());
893893
}
894-
894+
895895
public function testDeleteWebhookDeletesToTheSpecifiedResource()
896896
{
897897
$this->connection->expects($this->once())

0 commit comments

Comments
 (0)