library/PostcodeNl/Api/RestClient.php
protected function _checkResponse(array $response)
	{
		// Data present and status code class is 200-299: all is ok
		if (is_array($response['data']) && $response['statusCodeClass'] == 200)
			return;

		// No valid exception message was returned in the JSON (or no JSON at all)
		// Make our own messages based on the HTTP status code
		if (!is_array($response['data']) || !isset($response['data']['exceptionId']))
		{
			if ($response['statusCode'] == 503)
			{
				throw new PostcodeNl_Api_RestClient_ServiceException('Postcode.nl API returned no valid JSON data. HTTP status code `'. $response['statusCode'] .'`: Service Unavailable. You might be rate-limited if you are sending too many requests.');
			}

			throw new PostcodeNl_Api_RestClient_ServiceException('Postcode.nl API returned no valid JSON data. HTTP status code `'. $response['statusCode'] .'`.');
		}

		// Some specific exceptionIds we clarify within the context of our client.
		if ($response['statusCode'] == 401)
		{
			if ($response['data']['exceptionId'] === 'PostcodeNl_Controller_Plugin_HttpBasicAuthentication_PasswordNotCorrectException')
				throw new PostcodeNl_Api_RestClient_AuthenticationException('`Secret` specified in HTTP authentication password is incorrect. ("'. $response['data']['exception'] .'")', $response['data']['exceptionId']);
			if ($response['data']['exceptionId'] === 'PostcodeNl_Controller_Plugin_HttpBasicAuthentication_NotAuthorizedException')
				throw new PostcodeNl_Api_RestClient_AuthenticationException('`Key` specified in HTTP authentication is incorrect. ("'. $response['data']['exception'] .'")', $response['data']['exceptionId']);
		}

		// Specific exception for the Address API when input is correct, but no address is found
		if ($response['statusCode'] == 404)
		{
			if ($response['data']['exceptionId'] === 'PostcodeNl_Service_PostcodeAddress_AddressNotFoundException')
				throw new PostcodeNl_Api_RestClient_AddressNotFoundException($response['data']['exception'], $response['data']['exceptionId']);
		}

		// Our exception types are based on the HTTP status of the response
		if ($response['statusCode'] == 401 || $response['statusCode'] == 403)
		{
			throw new PostcodeNl_Api_RestClient_AuthenticationException($response['data']['exception'], $response['data']['exceptionId']);
		}
		else if ($response['statusCodeClass'] == 400)
		{
			throw new PostcodeNl_Api_RestClient_InputInvalidException($response['data']['exception'], $response['data']['exceptionId']);
		}

		throw new PostcodeNl_Api_RestClient_ServiceException($response['data']['exception'], $response['data']['exceptionId']);
	}
protected function _checkResponse(array $response)
	{
		// Data present and status code class is 200-299: all is ok
		if (is_array($response['data']) && $response['statusCodeClass'] == 200)
			return;

		// No valid exception message was returned in the JSON (or no JSON at all)
		// Make our own messages based on the HTTP status code
		if (!is_array($response['data']) || !isset($response['data']['exceptionId']))
		{
			if ($response['statusCode'] == 503)
			{
				throw new PostcodeNl_Api_RestClient_ServiceException('Postcode.nl API returned no valid JSON data. HTTP status code `'. $response['statusCode'] .'`: Service Unavailable. You might be rate-limited if you are sending too many requests.');
			}

			throw new PostcodeNl_Api_RestClient_ServiceException('Postcode.nl API returned no valid JSON data. HTTP status code `'. $response['statusCode'] .'`.');
		}

		// Some specific exceptionIds we clarify within the context of our client.
		if ($response['statusCode'] == 401)
		{
			if ($response['data']['exceptionId'] === 'PostcodeNl_Controller_Plugin_HttpBasicAuthentication_PasswordNotCorrectException')
				throw new PostcodeNl_Api_RestClient_AuthenticationException('`Secret` specified in HTTP authentication password is incorrect. ("'. $response['data']['exception'] .'")', $response['data']['exceptionId']);
			if ($response['data']['exceptionId'] === 'PostcodeNl_Controller_Plugin_HttpBasicAuthentication_NotAuthorizedException')
				throw new PostcodeNl_Api_RestClient_AuthenticationException('`Key` specified in HTTP authentication is incorrect. ("'. $response['data']['exception'] .'")', $response['data']['exceptionId']);
		}

		// Specific exception for the Address API when input is correct, but no address is found
		if ($response['statusCode'] == 404)
		{
			if ($response['data']['exceptionId'] === 'PostcodeNl_Service_PostcodeAddress_AddressNotFoundException')
				throw new PostcodeNl_Api_RestClient_AddressNotFoundException($response['data']['exception'], $response['data']['exceptionId']);
		}

		// Our exception types are based on the HTTP status of the response
		if ($response['statusCode'] == 401 || $response['statusCode'] == 403)
		{
			throw new PostcodeNl_Api_RestClient_AuthenticationException($response['data']['exception'], $response['data']['exceptionId']);
		}
		else if ($response['statusCodeClass'] == 400)
		{
			throw new PostcodeNl_Api_RestClient_InputInvalidException($response['data']['exception'], $response['data']['exceptionId']);
		}

		throw new PostcodeNl_Api_RestClient_ServiceException($response['data']['exception'], $response['data']['exceptionId']);
	}
protected function _checkResponse ( array $ response ) { // Data present and status code class is 200-299: all is ok if ( is_array ( $ response [ 'data' ] ) && $ response [ 'statusCodeClass' ] == 200 ) return ; // No valid exception message was returned in the JSON (or no JSON at all) // Make our own messages based on the HTTP status code if ( ! is_array ( $ response [ 'data' ] ) || ! isset ( $ response [ 'data' ] [ 'exceptionId' ] ) ) { if ( $ response [ 'statusCode' ] == 503 ) { throw new PostcodeNl_Api_RestClient_ServiceException ( 'Postcode.nl API returned no valid JSON data. HTTP status code `' . $ response [ 'statusCode' ] . '`: Service Unavailable. You might be rate-limited if you are sending too many requests.' ) ; } throw new PostcodeNl_Api_RestClient_ServiceException ( 'Postcode.nl API returned no valid JSON data. HTTP status code `' . $ response [ 'statusCode' ] . '`.' ) ; } // Some specific exceptionIds we clarify within the context of our client. if ( $ response [ 'statusCode' ] == 401 ) { if ( $ response [ 'data' ] [ 'exceptionId' ] === 'PostcodeNl_Controller_Plugin_HttpBasicAuthentication_PasswordNotCorrectException' ) throw new PostcodeNl_Api_RestClient_AuthenticationException ( '`Secret` specified in HTTP authentication password is incorrect. ("' . $ response [ 'data' ] [ 'exception' ] . '")' , $ response [ 'data' ] [ 'exceptionId' ] ) ; if ( $ response [ 'data' ] [ 'exceptionId' ] === 'PostcodeNl_Controller_Plugin_HttpBasicAuthentication_NotAuthorizedException' ) throw new PostcodeNl_Api_RestClient_AuthenticationException ( '`Key` specified in HTTP authentication is incorrect. ("' . $ response [ 'data' ] [ 'exception' ] . '")' , $ response [ 'data' ] [ 'exceptionId' ] ) ; } // Specific exception for the Address API when input is correct, but no address is found if ( $ response [ 'statusCode' ] == 404 ) { if ( $ response [ 'data' ] [ 'exceptionId' ] === 'PostcodeNl_Service_PostcodeAddress_AddressNotFoundException' ) throw new PostcodeNl_Api_RestClient_AddressNotFoundException ( $ response [ 'data' ] [ 'exception' ] , $ response [ 'data' ] [ 'exceptionId' ] ) ; } // Our exception types are based on the HTTP status of the response if ( $ response [ 'statusCode' ] == 401 || $ response [ 'statusCode' ] == 403 ) { throw new PostcodeNl_Api_RestClient_AuthenticationException ( $ response [ 'data' ] [ 'exception' ] , $ response [ 'data' ] [ 'exceptionId' ] ) ; } else if ( $ response [ 'statusCodeClass' ] == 400 ) { throw new PostcodeNl_Api_RestClient_InputInvalidException ( $ response [ 'data' ] [ 'exception' ] , $ response [ 'data' ] [ 'exceptionId' ] ) ; } throw new PostcodeNl_Api_RestClient_ServiceException ( $ response [ 'data' ] [ 'exception' ] , $ response [ 'data' ] [ 'exceptionId' ] ) ; }
Check the JSON response of the Address API result data.
Will throw an exception if there is an exception or other not expected response.

@param array $response Response data
@throws PostcodeNl_Api_RestClient_AddressNotFoundException
@throws PostcodeNl_Api_RestClient_AuthenticationException
@throws PostcodeNl_Api_RestClient_InputInvalidException
@throws PostcodeNl_Api_RestClient_ServiceException
Check the JSON response of the Address API result data . Will throw an exception if there is an exception or other not expected response .