selling-partner-api icon indicating copy to clipboard operation
selling-partner-api copied to clipboard

GetMyFeesEstimatesResponse dto() issue

Open MickDev13 opened this issue 1 year ago • 1 comments

Hi,

I already wrote in a previous issue #736 It seems to be fixed now, so I can do the request to the API without any problem.

$AMZConnector = SellingPartnerApi::seller(
  clientId: xxxx,
  clientSecret: xxxx,
  refreshToken: xxxxxx,
  endpoint: Endpoint::EU
);

$listing = new \SellingPartnerApi\Seller\ProductFeesV0\Dto\MoneyType("EUR", 100);

$shipping = new \SellingPartnerApi\Seller\ProductFeesV0\Dto\MoneyType("EUR", 0);

$priceToEstimateFees = new \SellingPartnerApi\Seller\ProductFeesV0\Dto\PriceToEstimateFees($listing, $shipping);

$feesRequest = new \SellingPartnerApi\Seller\ProductFeesV0\Dto\FeesEstimateRequest(xxxxxxxxxx, $priceToEstimateFees, "myidentifier-fee-" . date('YmdHis'), true);

$request = new \SellingPartnerApi\Seller\ProductFeesV0\Dto\FeesEstimateByIdRequest("SellerSKU", $sku, $feesRequest);
$body = array($request);

$apiInstance = $AMZConnector->productFeesV0();
$response = $apiInstance->getMyFeesEstimates($body);

I retrieve a GetMyFeesEstimatesResponse from the webservice call. If i call $response->json(), I can get the raw json from the response correctly, but if I try to get the dto with $response->dto(), I get the following error:

Fatal error: Uncaught ArgumentCountError: Too few arguments to function SellingPartnerApi\Seller\ProductFeesV0\Responses\GetMyFeesEstimatesResponse::__construct(), 0 passed in /trt/htdocs/admin/vendor/jlevers/selling-partner-api/src/Traits/Deserializes.php on line 72 and exactly 1 expected in /trt/htdocs/admin/vendor/jlevers/selling-partner-api/src/Seller/ProductFeesV0/Responses/GetMyFeesEstimatesResponse.php on line 23

ArgumentCountError: Too few arguments to function SellingPartnerApi\Seller\ProductFeesV0\Responses\GetMyFeesEstimatesResponse::__construct(), 0 passed in /trt/htdocs/admin/vendor/jlevers/selling-partner-api/src/Traits/Deserializes.php on line 72 and exactly 1 expected in /trt/htdocs/admin/vendor/jlevers/selling-partner-api/src/Seller/ProductFeesV0/Responses/GetMyFeesEstimatesResponse.php on line 23

Did I do something wrong?

Thank you for your work :)

MickDev13 avatar Jul 02 '24 10:07 MickDev13

Have you tried $apiInstance->getMyFeesEstimateForSku($sellerSku, $feesRequest)->dto();

That works for me. Otherwise can you post the response json body to see what response parameter might be missing in construction

simonsolutions avatar Jul 02 '24 17:07 simonsolutions

Hi,

Thank you for the answer. My example is not complete, this is why you thought about getMyFeesEstimateForSku, i will edit it I need to use getMyFeesEstimates method because of performance issues. For my project, I need to send multiples SKUs, and I think it's better to send them in a single call instead of one call for each SKU.

MickDev13 avatar Jul 04 '24 09:07 MickDev13

I haven't seen that the ProductFee API allows calls with multiple SellerSKUs. There are some SP API calls with multiple SKUs but not this one. In the documentation is always written "a product". So I'm not sure if multiple SKUs will be possible to send in one request.

simonsolutions avatar Jul 04 '24 13:07 simonsolutions

Here is the amazon documentation for this method: https://developer-docs.amazon.com/sp-api/docs/product-fees-api-v0-reference#post-productsfeesv0feesestimate

"Returns the estimated fees for a list of products."

MickDev13 avatar Jul 04 '24 13:07 MickDev13

Oh okay I missed that little part of the array :-)

simonsolutions avatar Jul 04 '24 13:07 simonsolutions

This should be fixed in v7.1.1.

jlevers avatar Aug 06 '24 23:08 jlevers