Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

OrdersV0->confirmShipment returns 204 result and throws Exception "Class to be deserialized must have a constructor" #842

Open
gwharton opened this issue Jan 9, 2025 · 3 comments

Comments

@gwharton
Copy link

gwharton commented Jan 9, 2025

Problem description:

$response = $this->spapi
->getConnector()
->ordersV0()
->confirmShipment(
$amazonOrderId,
$confirmShipmentRequest
)->dto();

with valid confirmShipmentRequest and amazonOrderId objects. Call is successful and the confirmation is registered on Amazon.

Call returns a 204 with zero body.

Error:

Exception is thrown

"Class to be deserialized must have a constructor"

@gwharton
Copy link
Author

gwharton commented Jan 9, 2025

Screenshot_1

$reflectionClass->getConstructor() returns null when reflectionClass is SellingPartnerApi\EmptyResponse

@gwharton
Copy link
Author

gwharton commented Jan 9, 2025

Sure its not right. Feels like a hack, but i'm working round with the following patch.

--- vendor/jlevers/selling-partner-api/src/EmptyResponse.orig.php	2025-01-09 21:40:04.421251942 +0000
+++ vendor/jlevers/selling-partner-api/src/EmptyResponse.php	2025-01-09 21:40:49.121515701 +0000
@@ -4,4 +4,6 @@

 namespace SellingPartnerApi;

-class EmptyResponse extends Response {}
+class EmptyResponse extends Response {
+    public function __construct() {}
+}

@gwharton
Copy link
Author

I'm guessing this is a result of me calling ->dto() on a response with no body. Should the selling-partner-api handle this scenareo itself, or should I be checking the status of the response object before calling dto().

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant