private function makeResponse($result, $key = null, $cast = null)
    {
        if (array_key_exists('faultCode', $result->toArray()))
            return $result['faultCode'];

        if (!is_null($key) && array_key_exists($key, $result->toArray()))
            $result = $result->get($key);

        if ($cast) settype($result, $cast);

        return $result;
    }
private function makeResponse($result, $key = null, $cast = null)
    {
        if (array_key_exists('faultCode', $result->toArray()))
            return $result['faultCode'];

        if (!is_null($key) && array_key_exists($key, $result->toArray()))
            $result = $result->get($key);

        if ($cast) settype($result, $cast);

        return $result;
    }
private function makeResponse ( $ result , $ key = null , $ cast = null ) { if ( array_key_exists ( 'faultCode' , $ result -> toArray ( ) ) ) return $ result [ 'faultCode' ] ; if ( ! is_null ( $ key ) && array_key_exists ( $ key , $ result -> toArray ( ) ) ) $ result = $ result -> get ( $ key ) ; if ( $ cast ) settype ( $ result , $ cast ) ; return $ result ; }
Prepare the api response.
If there is a faultCode then return its value.
If key passed, returns the value of that key.
Otherwise return the provided data.

@param Collection $result
@param string $key
@param null $cast Cast returned data based on this param.
@return mixed
Prepare the api response . If there is a faultCode then return its value . If key passed returns the value of that key . Otherwise return the provided data .