public function handleResponse($response)
    {
        // recursion for batch
        if (is_array($response)) {
            $response_arr = array();
            foreach ($response as $res) {
                $response_arr[$res->id] = $this->handleResponse($res);
            }
            return $response_arr;
        }

        // return error response
        if (property_exists($response, 'error')) {
            return new Response(null, $response->id, $response->error->code, $response->error->message);
        }

        // return successful response
        return new Response($response->result, $response->id);
    }
public function handleResponse($response)
    {
        // recursion for batch
        if (is_array($response)) {
            $response_arr = array();
            foreach ($response as $res) {
                $response_arr[$res->id] = $this->handleResponse($res);
            }
            return $response_arr;
        }

        // return error response
        if (property_exists($response, 'error')) {
            return new Response(null, $response->id, $response->error->code, $response->error->message);
        }

        // return successful response
        return new Response($response->result, $response->id);
    }
public function handleResponse ( $ response ) { // recursion for batch if ( is_array ( $ response ) ) { $ response_arr = array ( ) ; foreach ( $ response as $ res ) { $ response_arr [ $ res -> id ] = $ this -> handleResponse ( $ res ) ; } return $ response_arr ; } // return error response if ( property_exists ( $ response , 'error' ) ) { return new Response ( null , $ response -> id , $ response -> error -> code , $ response -> error -> message ) ; } // return successful response return new Response ( $ response -> result , $ response -> id ) ; }
handle the response and return a result or an error
handle the response and return a result or an error