-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Version info
- intercom-php version: 2.0.0
- PHP version: 5.6
Expected behavior
when user is not in intercom and getUser is called, the api should return with status with the user not found in the result
Actual behavior
api never returns, after further investigation guzzle dies on the 404 error returned by intercom api call. Page exists, has response code, but the http status of 404 causes guzzle to die.
Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: GET https://api.intercom.io/users?email=expiration%40test.com resulted in a 404 Not Found response: {"type":"error.list","request_id":"aomm6mt35nhsscst6fhg","errors":[{"code":"not_found","message":"User Not Found"}]} ' in /datadisk/vhosts/blueprintprep.com/myrest/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:107 Stack trace: #0 /datadisk/vhosts/blueprintprep.com/myrest/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /datadisk/vhosts/blueprintprep.com/myrest/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /datadisk/vhosts/blueprintprep.com/myrest/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /datadisk/vhosts/blueprintprep.co in /datadisk/vhosts/blueprintprep.com/myrest/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 107
Steps to reproduce (as granular as possible, including screenshots where appropriate)
- use this code:
require_once 'vendor/autoload.php';
use Intercom\IntercomClient;
$client = new IntercomClient('YOUR TOKEN GOES HERE',null);
echo 'Client Defined<br>';
$user = $client->users->getUsers(["email" => "bogus@noserver.com"]);
echo $user->id;
echo '<br>';
$delete_user = $user->id;
echo $user->name;
echo '<br>';
$client->users->deleteUser($delete_user);
-
Run code from 1 and you will see the Client Defined, and the error. However none of the other echo are seen since the getUsers call never returned.
-
Intercom is overloading the 404 to mean user not found. The page is found and has the proper response data to indicate user not found. However, since the http status is 404 and guzzle sees as a page not found guzzle errors out. Intercom needs to return 200 or intercom api needs to handle the 404 and return the response back up the line so I can handle it in my codebase.