Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

dto() for getOrder() response throws exception #798

Open
fakharimran77 opened this issue Oct 29, 2024 · 0 comments
Open

dto() for getOrder() response throws exception #798

fakharimran77 opened this issue Oct 29, 2024 · 0 comments

Comments

@fakharimran77
Copy link

Problem description:

Its just a simple test code and I am getting 200 in $response->status code but when I convert the response in dto(), it throws an exception. I have tried catalogue API and it works and converts in the DTO object successfully but in orders its not working. Please help.

Error:

Fatal error: Uncaught ArgumentCountError: Too few arguments to function SellingPartnerApi\Seller\OrdersV0\Dto\Order::__construct(), 0 passed in C:\amazon-seller-api-test\vendor\jlevers\selling-partner-api\src\Traits\Deserializes.php on line 71 and at least 4 expected in C:\amazon-seller-api-test\vendor\jlevers\selling-partner-api\src\Seller\OrdersV0\Dto\Order.php on line 130


ArgumentCountError: Too few arguments to function SellingPartnerApi\Seller\OrdersV0\Dto\Order::__construct(), 0 passed in C:\amazon-seller-api-test\vendor\jlevers\selling-partner-api\src\Traits\Deserializes.php on line 71 and at least 4 expected in C:\amazon-seller-api-test\vendor\jlevers\selling-partner-api\src\Seller\OrdersV0\Dto\Order.php on line 130

Code

    $ordersApi = $connector->ordersV0();

    $orderId = $_ENV['ORDER_ID']; // Replace with the actual order ID

    $response = $ordersApi->getOrder($orderId);

    if ($response->status() === 200) {

        // Get the response as a DTO
        $orderDetails = $response->dto();

        // Display order details
        echo "Order ID: " . $orderDetails->payload->orderId . "\n";
        echo "Purchase Date: " . $orderDetails->payload->purchaseDate . "\n";
        echo "Order Status: " . $orderDetails->payload->orderStatus . "\n";
        echo "Buyer Email: " . $orderDetails->payload->buyerEmail . "\n";
    }
    else {
        throw new Exception("Failed to fetch order details. Status code: " . $response->status());
    }

Seller Central SP API config page screenshot

your screenshot here

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

No branches or pull requests

1 participant