public function __call($method, $params)
{
if (!isset($this->_methods[$method])) {
if (method_exists($this->connection, $method)) {
return $this->connection->invokeMethod($method, $params);
}
$this->_methods[$method] = array('path' => "/{$method}");
}
$params += array(array(), array());
if (!is_object($params[0])) {
$config = (array) $params[0];
if (count($config) === count($config, COUNT_RECURSIVE)) {
$config = array('data' => $config);
}
$params[0] = new Query($this->_methods[$method] + $config);
}
$params[0] = new Query($params[0]->export($this) + $this->_methods[$method]);
return $this->_filter(__CLASS__ . "::" . $method, $params, function ($self, $params) {
list($query, $options) = $params;
return $self->send($query, $options);
});
}