Open 0xSekar opened 2 months ago
I had the same problem. I then just used ->json() instead of ->dto()
Yes, that was my first solution. Then I manually updated the file so I can continue using my internal library (that uses ->dto()), but need to redo the changes on each update, so modifying the generator will be a better solution, just that I'm not sure how to do it. The file /src/Seller/ProductPricingV0/Responses/GetOffersResponse.php should look something like this:
/**
* This file is auto-generated by Saloon SDK Generator
* Generator: SellingPartnerApi\Generator\Generators\ResponseGenerator
* Do not modify it directly.
*/
declare(strict_types=1);
namespace SellingPartnerApi\Seller\ProductPricingV0\Responses;
use SellingPartnerApi\Response;
use SellingPartnerApi\Seller\ProductPricingV0\Dto\Error;
use SellingPartnerApi\Seller\ProductPricingV0\Dto\GetOffersResult;
final class GetOffersResponse extends Response
{
protected static array $complexArrayTypes = ['errors' => Error::class];
/**
* @param ?ErrorList $errors A list of error responses returned when a request is unsuccessful.
*/
public function __construct(
public readonly ?GetOffersResult $payload = null,
public readonly ?array $errors = null,
) {}
}
I can confirm existence of this issue. Can we expect a fix implementation?
Problem description:
The commit ec9522aa6b92d9adb05770317d75cbaec78a2d12 fixed an issue with error responses defined as arrays instead of objects, but this change introduced an error in the call to GetListingOffersBatchRequest in ProductPricingV0 API.
In this particular case, The response at GetOffersResponse is an array of errors and not an ErrorList object.
The issue can be reproduced by sending an incorrect SKU or ASIN. I'm not sure yet how to revert the change for this specific response in the generator.
Original Response:
Error: