Closed compujo closed 8 years ago
@compujosh If you don't have orders it will return a 404. It should probably return a 200 with an empty result set since the URI/Resource is valid but there are no results, unfortunately that is not the case.
As for the mock environment it works by matching exact request URLs + Method in the mock data files. You can update the files in src/mock/
to add or update urls for your testing. It is not the most robust mock environment but provides the ability to setup different responses based on different parameters.
Alright, is there a preferred way to check for a 404/no orders? like a PageNotFoundException or something
Now that I think about, just because the API has a weird behavior in this situation doesn't mean the SDK needs to follow it. I can probably refactor it to catch the exception and if 404 return a static response like below or just throw the exception. What do you think of that idea?
[
'list' => [
'meta' => [
'totalCount' => 0
]
],
'elements' => []
]
With a response like that you can either check the ['list']['meta']['totalCount']
value or just iterate over ['elements']
which would either have orders or not.
As long as you're not changing the existing structure in a way that will break existing stuff, sounds good
@compujosh I updated the library so both list() and listReleased() will return the following when the Walmart API returns a 404. Code is just in develop
branch for now if you can try it out by changing your composer requirements to dev-develop
and let me know if this works for you then I can release to master and bump version.
[
'statusCode' => 200,
'list' => [
'meta' => [
'totalCount' => 0
]
],
'elements' => []
]
Hi @compujosh I went ahead and merged my changes into master
and released version 1.0.3
. Hopefully that will make your integration a little smoother.
Hi,
I have same problem here.
When I try to use API in this way:
$client = new Order([
'consumerId' => CONSUMER_ID,
'privateKey' => PRIVATE_KEY,
'wmConsumerChannelType' => WM_CONSUMER_CHANNEL_TYPE,
]);
try {
$resultsArr = $client->listReleased([
'createdStartDate' => '2018-03-13', // optional
'limit' => 10, // optional, default 10
'nextCursor' => '', // optional, value comes from previous call, used for pagination
]);
}
catch (Exception $e) {
die("There was a problem requesting the data: ".$e->getMessage());
}
print_r($resultsArr);
I always get 400 Bad request with a bunch of GuzzleHttp\Exception\RequestException
When I delete createdStartDate, then I just get blank 200 page (and I have orders on my products, they are just not showing).
Do you know what I'm doing wrong (link to my demo page: https://nemanjatanaskovic.com/walmart/ )?
P.s. when I test orders on https://developer.walmart.com/#/explorer/order I'm also getting this 400 error (you can see screenshot on this url: https://nemanjatanaskovic.com/walmart/001.png)
Thanks for your help, Nemanja
I'm trying to fetch new orders, but it's failing for both production and mock environments
Error:
Error for production:
I figure the error in production could be because we don't have any orders yet (account is not fully launched since we don't have the API client set up), but I'm not sure what's wrong with the Mock environment... do I have to add the mock responses myself somewhere?
Update: Mock environment works with $client->list(), but not if I add 'status' => 'Created', as a parameter