Fixes to Model Object Property Type

This commit is contained in:
Jay Patel
2015-03-19 14:13:52 -05:00
parent 0a32a6323c
commit 2c90b77c5a
3 changed files with 16 additions and 4 deletions

View File

@@ -3,6 +3,8 @@
namespace PayPal\Api; namespace PayPal\Api;
use PayPal\Common\PayPalModel; use PayPal\Common\PayPalModel;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
/** /**
* Class InvoiceItem * Class InvoiceItem
@@ -70,12 +72,14 @@ class InvoiceItem extends PayPalModel
/** /**
* Quantity of the item. Range of 0 to 9999.999. * Quantity of the item. Range of 0 to 9999.999.
* *
* @param \PayPal\Api\number $quantity * @param string|double $quantity
* *
* @return $this * @return $this
*/ */
public function setQuantity($quantity) public function setQuantity($quantity)
{ {
NumericValidator::validate($quantity, "Percent");
$quantity = FormatConverter::formatToPrice($quantity);
$this->quantity = $quantity; $this->quantity = $quantity;
return $this; return $this;
} }
@@ -83,7 +87,7 @@ class InvoiceItem extends PayPalModel
/** /**
* Quantity of the item. Range of 0 to 9999.999. * Quantity of the item. Range of 0 to 9999.999.
* *
* @return \PayPal\Api\number * @return string
*/ */
public function getQuantity() public function getQuantity()
{ {

View File

@@ -3,6 +3,8 @@
namespace PayPal\Api; namespace PayPal\Api;
use PayPal\Common\PayPalModel; use PayPal\Common\PayPalModel;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
/** /**
* Class Tax * Class Tax
@@ -67,12 +69,14 @@ class Tax extends PayPalModel
/** /**
* Rate of the specified tax. Range of 0.001 to 99.999. * Rate of the specified tax. Range of 0.001 to 99.999.
* *
* @param \PayPal\Api\number $percent * @param string|double $percent
* *
* @return $this * @return $this
*/ */
public function setPercent($percent) public function setPercent($percent)
{ {
NumericValidator::validate($percent, "Percent");
$percent = FormatConverter::formatToPrice($percent);
$this->percent = $percent; $this->percent = $percent;
return $this; return $this;
} }
@@ -80,7 +84,7 @@ class Tax extends PayPalModel
/** /**
* Rate of the specified tax. Range of 0.001 to 99.999. * Rate of the specified tax. Range of 0.001 to 99.999.
* *
* @return \PayPal\Api\number * @return string
*/ */
public function getPercent() public function getPercent()
{ {

View File

@@ -4,7 +4,9 @@ namespace PayPal\Test\Common;
use PayPal\Api\Amount; use PayPal\Api\Amount;
use PayPal\Api\Currency; use PayPal\Api\Currency;
use PayPal\Api\Details; use PayPal\Api\Details;
use PayPal\Api\InvoiceItem;
use PayPal\Api\Item; use PayPal\Api\Item;
use PayPal\Api\Tax;
use PayPal\Converter\FormatConverter; use PayPal\Converter\FormatConverter;
use PayPal\Common\PayPalModel; use PayPal\Common\PayPalModel;
use PayPal\Test\Validation\NumericValidatorTest; use PayPal\Test\Validation\NumericValidatorTest;
@@ -27,6 +29,8 @@ class FormatConverterTest extends \PHPUnit_Framework_TestCase
array(new Details(), 'Insurance'), array(new Details(), 'Insurance'),
array(new Details(), 'HandlingFee'), array(new Details(), 'HandlingFee'),
array(new Details(), 'GiftWrap'), array(new Details(), 'GiftWrap'),
array(new InvoiceItem(), 'Quantity'),
array(new Tax(), 'Percent')
); );
} }