davidtsadler / ebay-sdk-php

An eBay SDK for PHP. Use the eBay API in your PHP projects.
Apache License 2.0
350 stars 343 forks source link

JsonParser::assignProperties error when getting item using Browse Service #150

Closed jaskolek closed 4 years ago

jaskolek commented 7 years ago

Hello,

First of all, thanks for your work on this project!

I have some problems with BrowseService::getItem() method. Usually it works well but for one specific id 'v1|122185519308|422430345674' it crashes:

Catchable fatal error: Argument 2 passed to DTS\eBaySDK\Parser\JsonParser::assignProperties() must be of the type array, string given, called in /home/xxx/public_html/vendor/dts/ebay-sdk-php/src/Parser/JsonParser.php on line 99 and defined in /home/xxx/public_html/vendor/dts/ebay-sdk-php/src/Parser/JsonParser.php on line 16

Here is the code:

$id = 'v1|122185519308|422430345674';
$browseService = getBrowseService();

$request = new GetItemRestRequest();
$request->item_id = $id;
$browseService->getItem($request);

If this helps, I already dumped variables right before error (JsonParser::actualValue, $propertyMeta and $value):

object(stdClass)#902 (6) {
  ["propertyName"]=>
  string(7) "taxType"
  ["phpType"]=>
  string(32) "DTS\eBaySDK\Browse\Types\TaxType"
  ["repeatable"]=>
  bool(false)
  ["attribute"]=>
  bool(false)
  ["elementName"]=>
  string(7) "taxType"
  ["strData"]=>
  string(0) ""
}

string(3) "VAT"
andreyzp87 commented 6 years ago

Same for me. Seems like "DTS\eBaySDK\Browse\Types\TaxType" constructor expects an array, but the string is passed as value

andreyzp87 commented 6 years ago

This one fixes the issue temporarily: /dts/ebay-sdk-php/src/Browse/Types/Taxes.php change string 52 from 'type' => 'DTS\eBaySDK\Browse\Types\TaxType', to 'type' => 'string',

godscreature commented 6 years ago

can it be resolve in future?

michabbb commented 6 years ago

@davidtsadler any news about your new process creating these files?

davidtsadler commented 6 years ago

@michabbb Work on the new process is going slowing because I'm struggling to find the time to work on development. In addition it looks like I'm going to have to drop support for Enum classes in the Restful API as this information can't be generated from the OpenAPI files that eBay provide. This means that files such as https://github.com/davidtsadler/ebay-sdk-php/blob/master/src/Browse/Enums/AvailabilityStatusEnum.php will no longer be in the SDK once I switch to using the OpenAPI.

I've created an issue over here https://github.com/davidtsadler/ebay-api-sdk-php/issues/8 regarding the new OpenAPI code generation.