@param        $action
@param null   $data
@param string $method

@return \Guzzle\Http\Message\Response
491535
public function sendRequest($action, $data = null, $method = RequestInterface::POST)
    {
        // don't throw exceptions for 4xx errors, need the data for error messages
        $this->httpClient->getEventDispatcher()->addListener(
            'request.error',
            function ($event) {
                if ($event['response']->isClientError()) {
                    $event->stopPropagation();
                }
            }
        );

        $username = $this->getKeyId();
        $password = $this->getKeyPassword();
        $base64 = base64_encode($username.':'.$password);

        $url = $this->getEndpoint().$action;

        $headers = array(
            'Authorization' => 'Basic '.$base64,
            'Content-Type'  => 'application/json'
        );

        // For some reason the native json encoder built into Guzzle 3 is not encoding the nested data correctly,
        // breaking the http request. We need to do it manually.
        $data = json_encode($data);

        // Return the response we get back
        return $this->httpClient->createRequest($method, $url, $headers, $data)->send();
    }
353253
public function sendRequest($action, $data)
    {
        if (!$this->connected) {
            $this->connect();
        }
        try {
            $result = $this->client->__soapCall($action, $data);
        } catch (SoapFault $fault) {
            $this->handleError($fault->faultstring);
        }

        return $result;
    }
793112
public function execute($method, $url, array $data = [])
    {
        $client = new Client(['handler' => $this->handler]);

        return json_decode($client->request($method, $url, array_merge($data, self::$OPTIONS))->getBody());
    }
877543
public function action(String $action = NULL)
    {
        $time = $this->redirect['time'];
        $data = $this->redirect['data'];

        $this->redirect = [];

        if( strstr(get_called_class() , 'Refresh') )
        {
            $exit = false;
            $type = 'refresh';
        }
        
        $this->location($action, $time, $data, $exit ?? true, $type ?? 'location');
    }
1089165
public function request($method, $scope = null, $data = null)
    {
        if (is_array($scope)) {
            $data = $scope;
            $scope = null;
        }
        $url = $scope ? $this->url.'/'.ltrim($scope, '/') : $this->url;
        $result = self::$client->request($method, $url, $data);
        if (!$scope && $result instanceof Resource) {
            // TODO: how should POST be handled here?
            foreach ($result->data() as $key => $value) {
                self::offsetSet($key, $value);
            }
        }
        return $scope ? $result : $this;
    }
578137
public function callAction(string $action, ?DataMap $params = null): void
    {
        list ($moduleName, $controllerName, $actionName) = $this->getFullAction($action);
        $this->routeInfo->moduleName = $moduleName;
        $this->routeInfo->controllerName = $controllerName;
        $this->routeInfo->actionName = $actionName;
        if ($params != null) {
            $this->routeInfo->params = $params;
        }
        $this->invokeRoute();
    }
1087492
protected function call($eventName, $method, $data = null)
    {
        if (method_exists($this, $method)) {
            $result = call_user_func_array([$this, $method], $data);
            return $result;
        }

        return null;
    }
906283
private function exec($url, $data = '', $method = 'post', $header = [])
    {
        $res = false;
        $this->try = 0;
        $this->result = '';
        $this->action('start');

        while ($this->try < $this->tryMax) {
            $this->try++;
            $res = $this->realExec($url, $data, $method, $header);
            if ($res) {
                break;
            }
        }

        $this->action('stop');
        return $res;
    }
88997
public function get($method, $data = array())
    {
        //set cURL transfer option for get request
        // and get ouput
        return $this->createEndPoint($method, $data)
                    ->setOpt(CURLOPT_CUSTOMREQUEST, 'GET')
                    ->setopt(CURLOPT_HTTPGET, true)
                    ->exec();
    }
1169358
public static function run($url = null, $data = null, $method = 'GET') {
        if ($url) {
            if (is_string($data)) {
                $method = $data;
                $data   = null;
            }
            $method                 = strtoupper($method);
            $_SERVER['REQUEST_URI'] = $url;
            $query                  = @parse_url($url, PHP_URL_QUERY);
            if ($query) {
                $args = [];
                parse_str($query, $args);
                if ($args) {
                    if ($data) {
                        $data = array_merge($data, $args);
                    } else {
                        $data = $args;
                    }
                }
            }
            $_SERVER['REQUEST_METHOD'] = $method;
            if ($data) {
                if ($method == 'GET') {
                    $_SERVER['QUERY_STRING'] = http_build_query($data);
                }
                Request::getInstance()->addUserData($data);
            }

            $_SERVER['REQUEST_TIME'] = time();
        }
        if (!isset ($_SERVER ['REQUEST_URI'])) {
            Response::respond(500, 'Your web server did not provide REQUEST_URI, stop route request.');
        }

        if (!self::$app->router) {
            self::$app->router = Router::getRouter();
        }
        try {
            return self::$app->router->route();
        } catch (\Exception $e) {
            if (defined('DEBUG') && DEBUG < DEBUG_ERROR) {
                show_exception_page($e);
            } else {
                Response::respond(500, $e->getMessage());
            }
        }

        return false;
    }
377299
public function addAction($controller, $action = null)
    {
        if ($action === null) {
            list($controller, $action) = explode('.', $controller);
        }
        $this->actions[] = array(
            'controller' => null,
            'controller_name' => $controller,
            'action' => $action,
            'result' => null,
        );
        $this->action_names[] = "{$controller}.{$action}";
    }
821794
public function post($action, $queryParams = [], $data = [])
    {
        return \GuzzleHttp\json_decode($this->getGuzzle()->post($this->getApiUrl($action, $queryParams), [
            'json' => $data
        ])->getBody(), true);
    }
895354
public function modelForm($model, $method = 'POST', $action = null): Form
    {
        $this->model($model);

        return $this->form($method, $action);
    }
566243
public function callAction($method, $parameters)
    {
        $response = null;
        $this->method = $method;

        $result = parent::callAction($method, $parameters);

        if ($this->returnsArray) {
            if (!is_array($result)) {
                abort(500, 'Bad API response data.');
            }

            // Return JSON for AJAX and GET requests
            if (request()->ajax() || 'index' === $method || 'show' === $method) {
                $response = response()->json($result);

            // Return redirect-back and flash data for normal requests.
            } else {
                $response = empty($this->redirectUrl) ? back() : redirect($this->redirectUrl);
                foreach ($result as $key => $value) {
                    $response->with($key, $value);
                }
                if ('store' !== $method || isset($result['error'])) {
                    $response->withInput();
                }
            }
        } else {
            $response = $result;
        }

        return $response;
    }
388830
protected function processRequest($data, $method = self::POST)
    {
        $this->_headers['Content-Type'] = 'application/json';
        try {
            $client = new Client();

            // create a log channel
            $log = new Logger(get_class($this));
            $log->pushHandler(new StreamHandler('service_call.log', Logger::DEBUG));

            $subscriber = new LogSubscriber($log);
            $client->getEmitter()->attach($subscriber);

            $response = $client->$method($this->uri, [
                'auth' => [$this->username, $this->password],
                'headers' => $this->_headers,
                'body' => $data
            ]);

            return json_decode($response->getBody());
        } catch (BadResponseException $e) {
            $this->output->error($e->getRequest());
            if ($e->hasResponse()) {
                $this->output->error($e->getResponse());
            }
        }
    }
261801
public function request($method, $data = [])
    {
        $path = '_template/'.$this->getName();

        return $this->getClient()->request($path, $method, $data);
    }
777458
public function post($path, $action = null)
    {
        return $this->match($path, HttpMethodRule::HTTP_METHOD_POST, $action);
    }