Skip to content
Snippets Groups Projects
Commit 50812707 authored by Paul Erickson's avatar Paul Erickson
Browse files

Expose pricing template and rename "item number" to the more common "sku"

parent fd32aaeb
No related branches found
No related tags found
No related merge requests found
{
"name": "adi-ia/cbs-techstore-client-php",
"description": "A PHP client used to connect with the CBS API and perform requests",
"version": "1.0.0",
"version": "2.0.0",
"license": "Apache-2.0",
"homepage": "https://wiki.doit.wisc.edu/confluence/display/ADIIA/CBS",
"authors": [
......
sonar.host.url=http://ia-builds.doit.wisc.edu:9000
sonar.projectKey=cbs-techstore-client-php
sonar.projectName=cbs-techstore-client-php
sonar.projectVersion=1.0.0
sonar.projectVersion=2.0.0
sonar.sources=src/main
sonar.tests=src/test
sonar.php.tests.reportPath=reports/phpunit.xml
......
......@@ -11,8 +11,8 @@ use Money\Money;
*/
class Product
{
/** @var string unique item number */
private $itemNumber = '';
/** @var string Stock Keeping Unit, a unique product identifier */
private $sku = '';
/** @var string name / short description */
private $name = '';
......@@ -34,8 +34,11 @@ class Product
/** @var float maximum quantity allowed in inventory */
private $maxQuantity;
/** @var string */
private $pricingTemplate;
/** @var string state of the item within the Techstore */
/** @var string state of the item within the Techstore, e.g. 'FULLY_SELLABLE' or 'FROZEN'*/
private $lifecycle = '';
/** @var string control flag for capturing serial numbers */
......@@ -56,18 +59,17 @@ class Product
/**
* @return string
*/
public function getItemNumber()
public function getSku()
{
return $this->itemNumber;
return $this->sku;
}
/**
* @param string $itemNumber
* @param string $sku
* @return Product
*/
public function setItemNumber($itemNumber)
public function setSku($sku)
{
$this->itemNumber = $itemNumber;
$this->sku = $sku;
return $this;
}
......@@ -305,4 +307,22 @@ class Product
return $this;
}
/**
* @param string $pricingTemplate
* @return Product
*/
public function setPricingTemplate($pricingTemplate)
{
$this->pricingTemplate = $pricingTemplate;
return $this;
}
/**
* @return string
*/
public function getPricingTemplate()
{
return $this->pricingTemplate;
}
}
......@@ -39,19 +39,20 @@ class ProductInputParametersMapper
''
))
->setP_CBS_ITEM_TEMPLATE($product->getCbsItemTemplate())
->setP_ITEM_NUMBER($product->getItemNumber())
->setP_ITEM_DESCRIPTION($product->getName())
->setP_COST(static::convertMoneyToFloat($product->getCost()))
->setP_ITEM_CATEGORY($product->getCategory())
->setP_ITEM_DESCRIPTION($product->getName())
->setP_ITEM_NUMBER($product->getSku())
->setP_LIFE_CYCLE($product->getLifecycle())
->setP_MANUFACTURER_NAME($product->getManufacturer())
->setP_MANUFACTURER_PART_NUMBER($product->getManufacturerPartNumber())
->setP_COST(static::convertMoneyToFloat($product->getCost()))
->setP_MINMAX_LEVEL_MIN($product->getMinQuantity())
->setP_MINMAX_LEVEL_MAX($product->getMaxQuantity())
->setP_LIFE_CYCLE($product->getLifecycle())
->setP_MINMAX_LEVEL_MIN($product->getMinQuantity())
->setP_PRICING_TEMPLATE($product->getPricingTemplate())
->setP_SERIAL_CONTROL_FLAG($product->getSerialControlFlag())
->setP_VENDOR($product->getVendor())
->setP_SUPPLIER_PART_NUMBER($product->getVendorPartNumber())
->setP_UPC($product->getUpc());
->setP_UPC($product->getUpc())
->setP_VENDOR($product->getVendor());
}
/**
......
......@@ -14,7 +14,7 @@ class ProductInputParametersMapperTest extends \PHPUnit_Framework_TestCase
public function mapsProductToInputParameters()
{
$product = (new Product())
->setItemNumber('itemNumber')
->setSku('itemNumber')
->setName('name')
->setCategory('category')
->setManufacturer('manufacturer')
......@@ -30,7 +30,7 @@ class ProductInputParametersMapperTest extends \PHPUnit_Framework_TestCase
$inputParameters = ProductInputParametersMapper::toInputParameters($product);
static::assertEquals($product->getItemNumber(), $inputParameters->getP_ITEM_NUMBER());
static::assertEquals($product->getSku(), $inputParameters->getP_ITEM_NUMBER());
static::assertEquals($product->getName(), $inputParameters->getP_ITEM_DESCRIPTION());
static::assertEquals($product->getCategory(), $inputParameters->getP_ITEM_CATEGORY());
static::assertEquals($product->getManufacturer(), $inputParameters->getP_MANUFACTURER_NAME());
......
......@@ -35,32 +35,34 @@ class ProductServiceSoapClientIT extends IntegrationTestCase
// First create the product so that it exists in the first place
$product = $this->generateSampleProduct();
$response = $this->client->createProduct($product);
static::assertTrue($response->isSuccess());
static::assertTrue($response->isSuccess(), $response->getMessage());
// Then update it
$product->setCost(Money::USD(100));
$response = $this->client->updateProduct($product);
static::assertTrue($response->isSuccess());
static::assertTrue($response->isSuccess(), $response->getMessage());
}
private function generateSampleProduct() {
$itemNumber = mt_rand(0, 99999);
$cost = mt_rand(1, 10000);
return (new Product())
->setCbsItemTemplate(1390)
->setItemNumber("ADI-test-$itemNumber")
->setName('ADI IA Test Product')
->setCategory('ADI IA Test Category')
->setCbsItemTemplate(1390)
->setCost(Money::USD($cost))
->setLifecycle('FULLY_SELLABLE')
->setManufacturer('Hoffmann Manufacturers')
->setManufacturerPartNumber("HOFF$itemNumber")
->setCost(Money::USD($cost))
->setMinQuantity(1)
->setMaxQuantity(5)
->setLifecycle('TEST')
->setMinQuantity(1)
->setName('ADI IA Test Product')
->setPricingTemplate(1)
->setSerialControlFlag('1')
->setSku("ADI-test-$itemNumber")
->setUpc(uniqid('', false))
->setVendor('Blair Wholesale Goods')
->setVendorPartNumber("BLAIR$itemNumber")
->setUpc(uniqid('', false));
;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment