/**
* Handle the response returned by the server
*
* Child classes could override this method to do something with the response.
* By default this class throws an exception when the response has han error
*
* @param \Httpful\Response $response
* @Param CRM_Civirules_TriggerData_TriggerData $triggerData
* @param \Httpful\Request $request
* @throws \Exception
*/
protected function handleResponse(\Httpful\Response $response, \Httpful\Request $request, CRM_Civirules_TriggerData_TriggerData $triggerData)
{
//by default throw an error if response is not a 200 response
if ($response->hasErrors()) {
throw new Exception('Invalid response. Got a HTTP ' . $response->code . "\r\n\r\n" . $response->raw_headers . "\r\n\r\n" . $response->raw_body . "\r\n\r\nRequest was: " . $request->method . ': ' . $request->uri . "\r\n" . $request->raw_headers . "\r\n\r\n" . $request->payload);
}
//do something with the response. You could override this method in a child class to do something with the response.
}