davidtsadler / ebay-sdk-examples

Several examples of using the eBay SDK for PHP
http://devbay.net
Apache License 2.0
184 stars 100 forks source link

Help with ReviseInventoryStatusRequestType. #9

Closed acubino closed 9 years ago

acubino commented 9 years ago

Hi.

I was trying to update the qty of the item that previusly listed using the example. But i'm managed some bad.

My code

$request = new Types\ReviseInventoryStatusRequestType();

$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $this->config[$entorno]['userToken'];

$inventory = new Types\InventoryStatusType();

$inventory->ItemID = "281689406834";
$inventory->SKU = "MO-10240";
$inventory->Quantity = 100;
$inventory->StartPrice = new Types\AmountType(array('value' => (float)4.95));

$request->InventoryStatus = $inventory;

$response = $this->service->ReviseInventoryStatus($request);

The error I get from SDK is.

( ! ) Fatal error: Uncaught exception 'DTS\eBaySDK\Exceptions\InvalidPropertyTypeException' with message 'Invalid property type: DTS\eBaySDK\Trading\Types\ReviseInventoryStatusRequestType::InventoryStatus expected <DTS\eBaySDK\Types\UnboundType>, got <DTS\eBaySDK\Trading\Types\InventoryStatusType>' in /var/www/ebay-sdk-trading-master/ebay-sdk-examples-master/vendor/dts/ebay-sdk/src/DTS/eBaySDK/Types/BaseType.php on line 334

( ! ) DTS\eBaySDK\Exceptions\InvalidPropertyTypeException: Invalid property type: DTS\eBaySDK\Trading\Types\ReviseInventoryStatusRequestType::InventoryStatus expected <DTS\eBaySDK\Types\UnboundType>, got <DTS\eBaySDK\Trading\Types\InventoryStatusType> in /var/www/ebay-sdk-trading-master/ebay-sdk-examples-master/vendor/dts/ebay-sdk/src/DTS/eBaySDK/Types/BaseType.php on line 334

Can you help me?. Thx.

davidtsadler commented 9 years ago

$request->InventoryStatus is a repeatable field in the API which basically means that you can provide more than one value. This is handled in the SDK by using array properties. To stop the error you just need to assign a value using the square bracket syntax.

$request->InventoryStatus[] = $inventory;