{"action":"created","issue":{"url":"https://api.github.com/repos/Nexmo/nexmo-php/issues/147","repository_url":"https://api.github.com/repos/Nexmo/nexmo-php","labels_url":"https://api.github.com/repos/Nexmo/nexmo-php/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/Nexmo/nexmo-php/issues/147/comments","events_url":"https://api.github.com/repos/Nexmo/nexmo-php/issues/147/events","html_url":"https://github.com/Nexmo/nexmo-php/issues/147","id":376967122,"node_id":"MDU6SXNzdWUzNzY5NjcxMjI=","number":147,"title":"Nexmo\\Insights\\Client doesnt handle error responses well","user":{"login":"runawaycoin","id":26024569,"node_id":"MDQ6VXNlcjI2MDI0NTY5","avatar_url":"https://avatars3.githubusercontent.com/u/26024569?v=4","gravatar_id":"","url":"https://api.github.com/users/runawaycoin","html_url":"https://github.com/runawaycoin","followers_url":"https://api.github.com/users/runawaycoin/followers","following_url":"https://api.github.com/users/runawaycoin/following{/other_user}","gists_url":"https://api.github.com/users/runawaycoin/gists{/gist_id}","starred_url":"https://api.github.com/users/runawaycoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runawaycoin/subscriptions","organizations_url":"https://api.github.com/users/runawaycoin/orgs","repos_url":"https://api.github.com/users/runawaycoin/repos","events_url":"https://api.github.com/users/runawaycoin/events{/privacy}","received_events_url":"https://api.github.com/users/runawaycoin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-02T21:04:03Z","updated_at":"2018-11-05T11:29:09Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nThe Nexmo\\Insights\\Client class doesnt seem to handle error responses well.\r\n\r\nFor example\r\nFollowing code example from here:\r\nhttps://developer.nexmo.com/number-insight/building-blocks/number-insight-basic\r\n\r\n```\r\n $basic  = new \\Nexmo\\Client\\Credentials\\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);\r\n $client = new \\Nexmo\\Client($basic);\r\n $insights = $client->insights()->basic('07999999999');\r\n```\r\n\r\nThe above will fail - as the number is not in internalised format (it would also be great if the basic function accepts the $additionalParams argument like the generic makeRequest function does) - but php code errors with:\r\n```\r\nNotice: Undefined index: national_format_number\r\nin vendor\\nexmo\\client\\src\\Insights\\Client.php (line 27)\r\n```\r\nWhich is:\r\n```\r\n    $basic = new Basic($insightsResults['national_format_number']);\r\n```\r\n\r\nThe server API response does not contain the key 'national_format_number'.\r\n\r\n\r\nAdditionally if the Nexmo API response is not 200, the code fails with this:\r\n```\r\nArgument 1 passed to Nexmo\\Insights\\Client::getException() must be an instance of Nexmo\\Insights\\ResponseInterface, instance of GuzzleHttp\\Psr7\\Response given, called in vendor\\nexmo\\client\\src\\Insights\\Client.php on line 96\r\n```\r\n\r\n\r\nThanks very much - i could write up a PR with these implemented / corrected if you would prefer?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Nexmo/nexmo-php/issues/comments/435842518","html_url":"https://github.com/Nexmo/nexmo-php/issues/147#issuecomment-435842518","issue_url":"https://api.github.com/repos/Nexmo/nexmo-php/issues/147","id":435842518,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTg0MjUxOA==","user":{"login":"mheap","id":59130,"node_id":"MDQ6VXNlcjU5MTMw","avatar_url":"https://avatars0.githubusercontent.com/u/59130?v=4","gravatar_id":"","url":"https://api.github.com/users/mheap","html_url":"https://github.com/mheap","followers_url":"https://api.github.com/users/mheap/followers","following_url":"https://api.github.com/users/mheap/following{/other_user}","gists_url":"https://api.github.com/users/mheap/gists{/gist_id}","starred_url":"https://api.github.com/users/mheap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mheap/subscriptions","organizations_url":"https://api.github.com/users/mheap/orgs","repos_url":"https://api.github.com/users/mheap/repos","events_url":"https://api.github.com/users/mheap/events{/privacy}","received_events_url":"https://api.github.com/users/mheap/received_events","type":"User","site_admin":false},"created_at":"2018-11-05T11:29:09Z","updated_at":"2018-11-05T11:29:09Z","author_association":"COLLABORATOR","body":"@runawaycoin A PR would be very much appreciated!"}}
{"actor":{"display_login":"mheap"}}