jlevers / selling-partner-api

A PHP client library for Amazon's Selling Partner API
BSD 3-Clause "New" or "Revised" License
404 stars 196 forks source link

productFeesV0: getMyFeesEstimates: Can not parse the response #759

Closed thinh-intersoft closed 3 months ago

thinh-intersoft commented 3 months ago

Version: 7.0.4

Problem description:

Can not parse the resposne using $request->dto()

Error

[2024-07-16 00:25:20] local.ERROR: {"Exception":"[object] (ArgumentCountError(code: 0): Too few arguments to function SellingPartnerApi\\Seller\\ProductFeesV0\\Responses\\GetMyFeesEstimatesResponse::__construct(), 0 passed in /home/vagrant/code/datadash-saas/vendor/jlevers/selling-partner-api/src/Traits/Deserializes.php on line 74 and exactly 1 expected at /home/vagrant/code/datadash-saas/vendor/jlevers/selling-partner-api/src/Seller/ProductFeesV0/Responses/GetMyFeesEstimatesResponse.php:23)
...

Reason

The structure of the response returned from the API does not match to parsing

Response:

[
  {
    "key": "value"
  },
  {
    "key": "value"
  }
]

Expected:

{
  "getMyFeesEstimatesResponse": [
    {
      "key": "value"
    },
    {
      "key": "value"
    }
  ]
}

Temp solution:

Parse manually using the deserialize function of GetMyFeesEstimatesResponse

        return GetMyFeesEstimatesResponse::deserialize([
            'getMyFeesEstimatesResponse' => $response->json()
        ]);
jlevers commented 3 months ago

This should be fixed in v7.1.1