@param $apiMethod            вызываемый метод, список приведен далее, пример /rs/suggest/address
@param array $params         параметры соответствующие методу запроса пример ['query' => 'Хабар', 'count' => 10]

@return ApiResponse
16912
public function send($apiMethod, array $params = [], $requestMethod = "POST")
    {
        $requestMethod = strtoupper($requestMethod);

        $httpRequest        = $this->_createHttpRequest($apiMethod, $params, $requestMethod);
        $httpResponse       = $httpRequest->send();

        $apiResponse = new ApiResponse([
            'api'                   => $this,
            'httpClientRequest'     => $httpRequest,
            'httpClientResponse'    => $httpResponse,
            'apiMethod'             => $apiMethod,
        ]);

        return $apiResponse;
    }
353240
protected function generateMethod($apiName, $operation = [], $api = [])
    {

        $filterParams = compact('apiName', 'operation', 'api');
        $method = [' * @method', 'array'];

        $data = "";
        $request = $api['request'];
        $description = $this->sanitizeDescription($request['description'], ['noMarkdown' => true, 'shorten' => true]);
        $description = $this->applyFilter('DocMethodDescription', $description, $filterParams);
        $params = $this->applyFilter('DocMethodParams', $operation['parameters'], $filterParams);
        $filterParams['params'] = $params;
        if (!empty($params)) {
            $data = $this->applyFilter('DocMethodData', 'array $parameters', $filterParams);
        }

        $method[] = $this->applyFilter('DocMethodSignature', "$apiName($data)", $filterParams);
        $method[] = $description;

        return implode("\t", $method);

    }
301050
protected function request($api, array $params, $method = 'post', array $options = [], $returnResponse = false)
    {
        $params = array_merge($params, $this->merchant->only(['sub_appid', 'sub_mch_id']));

        $params['appid'] = $this->merchant->app_id;
        $params['mch_id'] = $this->merchant->merchant_id;
        $params['device_info'] = $this->merchant->device_info;
        $params['nonce_str'] = uniqid();
        $params = array_filter($params);
        $params['sign'] = generate_sign($params, $this->merchant->key, 'md5');

        $options = array_merge([
            'body' => XML::build($params),
        ], $options);

        $response = $this->getHttp()->request($api, $method, $options);

        return $returnResponse ? $response : $this->parseResponse($response);
    }
517613
protected function sendRequest($url, array $params, $method)
    {
        $method = strtolower($method);
        $options = [
            CURLOPT_RETURNTRANSFER => true,
        ];

        if (self::REQUEST_METHOD_GET === $method) {
            $url .= '?' . http_build_query($params);
        } else {
            $options[CURLOPT_POST] = true;
            $options[CURLOPT_POSTFIELDS] = http_build_query($params);
        }

        $ch = curl_init($url);
        curl_setopt_array($ch, $options);
        $response = curl_exec($ch);

        if (!$response) {
            throw new \RuntimeException('cURL: ' . curl_error($ch), curl_errno($ch));
        }
        curl_close($ch);

        return $response;
    }
1333605
public static function create($params = null, $apiKey = null)
    {
        $urlMod = "";

        if ((isset($params['verify']) && is_array($params['verify'])) || (isset($params['verify_strict']) && is_array($params['verify_strict']))) {
            $verify = "";
            if (isset($params['verify'])) {
                $verify = $params['verify'];
                unset($params['verify']);
            }

            $verify_strict = "";
            if (isset($params['verify_strict'])) {
                $verify_strict = $params['verify_strict'];
                unset($params['verify_strict']);
            }

            $urlMod = "?";

            if (is_array($verify)) {
                foreach ($verify as $verification) {
                    $urlMod .= "verify[]=" . $verification . "&";
                }
            }

            if (is_array($verify_strict)) {
                foreach ($verify_strict as $verification_strict) {
                    $urlMod .= "verify_strict[]=" . $verification_strict . "&";
                }
            }
        }

        if (!isset($params['address']) || !is_array($params['address'])) {
            $clone = $params;
            unset($params);
            $params['address'] = $clone;
        }

        return self::_create(get_class(), $params, $apiKey, $urlMod);
    }
591412
public function get($methodName, array $params = array())
    {
        $options = array_merge($this->defaultApiOptions, $this->createConfigByMethodName($methodName));
        $options['http'] = 'get';
        return $this->internalCall($methodName, $options, $params);
    }
148799
public function buildUrl($method = '', $params = '', $append = true)
    {
        return $this->bbbServerBaseUrl . 'api/' . $method . ($append ? '?' . $this->buildQs($method, $params) : '');
    }
1238857
private function callMethod($method, $params)
    {
        $params['chat_id'] = Conversation::get('lead_id');

        return giga_remote_post($this->getResource($method), $params);
    }
808153
protected static function staticRequest($method, $url, $params)
    {
        $requestor = new ApiRequestor();
        list($response, $code) = $requestor->request($method, $url, $params);
        return array($response, $code);
    }
437060
public function arrayMap($callback, array $params)
    {
        if ($params[0] === $this) {
            $addThis = true;
            array_shift($params);
        }
        if ((is_array($params[0]) || ($params[0] instanceof Iterator && $params[0] instanceof ArrayAccess))) {
            if (empty($params[0])) {
                return $params[0];
            }

            // array map
            $out = array();
            $cnt = count($params);

            if (isset($addThis)) {
                array_unshift($params, $this);
                $items = $params[1];
                $keys  = array_keys($items);

                if (is_string($callback) === false) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = call_user_func_array($callback, array(1 => $items[$i]) + $params);
                    }
                } elseif ($cnt === 1) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($this, $items[$i]);
                    }
                } elseif ($cnt === 2) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($this, $items[$i], $params[2]);
                    }
                } elseif ($cnt === 3) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($this, $items[$i], $params[2], $params[3]);
                    }
                } else {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = call_user_func_array($callback, array(1 => $items[$i]) + $params);
                    }
                }
            } else {
                $items = $params[0];
                $keys  = array_keys($items);

                if (is_string($callback) === false) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = call_user_func_array($callback, array($items[$i]) + $params);
                    }
                } elseif ($cnt === 1) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($items[$i]);
                    }
                } elseif ($cnt === 2) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($items[$i], $params[1]);
                    }
                } elseif ($cnt === 3) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($items[$i], $params[1], $params[2]);
                    }
                } elseif ($cnt === 4) {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = $callback($items[$i], $params[1], $params[2], $params[3]);
                    }
                } else {
                    while (($i = array_shift($keys)) !== null) {
                        $out[] = call_user_func_array($callback, array($items[$i]) + $params);
                    }
                }
            }

            return $out;
        } else {
            return $params[0];
        }
    }
1070637
public function send(array $params)
    {
        $params['mchid'] = $this->merchant->merchant_id;
        $params['mch_appid'] = $this->merchant->app_id;

        return $this->request(self::API_SEND, $params);
    }
1244851
public function request($method, $params = [])
    {
        $response = $this->client->post($this->getUrl($method), ['query' => $params]);

        if ($response->getStatusCode() === 200) {
            return (string)$response->getBody();
        } else {
            throw new Exception(sprintf('Sms.ru problem. Status code is %s', $response->getStatusCode()), $response->getStatusCode());
        }
    }
742818
public function multipartRequest($apiMethod, array $options = [], array $files = [], $httpMethod = 'POST')
    {
        $config = [RequestOptions::MULTIPART => []];
        $options = $this->prepareRequestOptions($options, $apiMethod);

        foreach ($options as $key => $value) {
            $config[RequestOptions::MULTIPART][] = ['name' => $key, 'contents' => (string) $value];
        }

        foreach ($files as $key => $file) {
            $config[RequestOptions::MULTIPART][] = ['name' => $key, 'contents' => fopen($file->getRealPath(), 'r')];
        }

        return $this->apiRequest($httpMethod, $this->getApiUrl($apiMethod), $config);
    }
989541
private function request($url, $params = [], $method = 'GET')
    {
        // Set URL & Header
        curl_setopt($this->curl, CURLOPT_URL, $this->url . $url);
        curl_setopt($this->curl, CURLOPT_HTTPHEADER, array());

        //Add post vars
        if($method == 'POST')
        {
            curl_setopt($this->curl, CURLOPT_POST, count($params));
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, $params);
        }

        //Get result
        $result = curl_exec($this->curl);
        if($result === false)
            throw new \Exception('CURL error: ' . curl_error($this->curl));

        // decode results
        $result = json_decode($result, true);

        if(!is_array($result) || json_last_error())
            throw new \Exception('JSON decode error');

        return $result;

    }
1059858
private function api($method, $params) 
	{
    
		$basic = array(
		  'method'      => $method,
		  'appid'       => $this->appid,
		  'key'         => $this->key,
		  'path'        => $this->path,
		  'user_ip'     => $_SERVER['REMOTE_ADDR'],
		  'language'    => $this->language,
		  'platform'    => 'php'
		);

		return $this->call(array_merge(isset($params[0]) ? $params[0] : $params, $basic));
	}
1161654
public function api($method, $parameters = array(), $format = 'array', $requestMethod = 'get')
    {
        $parameters['timestamp'] = time();
        $parameters['api_id'] = $this->app_id;
        $parameters['random'] = rand(0, 10000);

        if (!array_key_exists('access_token', $parameters) && !is_null($this->access_token)) {
            $parameters['access_token'] = $this->access_token;
        }

        if (!array_key_exists('v', $parameters) && !is_null($this->api_version)) {
            $parameters['v'] = $this->api_version;
        }

        ksort($parameters);

        $sig = '';
        foreach ($parameters as $key => $value) {
            $sig .= $key . '=' . $value;
        }
        $sig .= $this->api_secret;

        $parameters['sig'] = md5($sig);

        if ($method == 'execute' || $requestMethod == 'post') {
            $rs = $this->request(
                $this->getApiUrl($method, $format == 'array' ? 'json' : $format), "POST", $parameters);
        } else {
            $rs = $this->request($this->createUrl(
                $this->getApiUrl($method, $format == 'array' ? 'json' : $format), $parameters));
        }
        return $format == 'array' ? json_decode($rs, true) : $rs;
    }
883063
private function _parseUrl(string $method, array $params = [])
    {
        $params = [
                'module' => 'API',
                'method' => $method,
                'token_auth' => $this->_token,
                'idSite' => $this->_siteId,
                'period' => $this->_period,
                'format' => $this->_format,
                'language' => $this->_language,
                'filter_limit' => $this->_filter_limit
            ] + $params;

        foreach ($params as $key => $value) {
            $params[$key] = urlencode($value);
        }

        if (!empty($this->_rangeStart) && !empty($this->_rangeEnd)) {
            $params = $params + [
                    'date' => $this->_rangeStart . ',' . $this->_rangeEnd,
                ];
        } elseif (!empty($this->_date)) {
            $params = $params + [
                    'date' => $this->_date,
                ];
        } else {
            throw new InvalidArgumentException('Specify a date or a date range!');
        }

        $url = $this->_site;

        $i = 0;
        foreach ($params as $param => $val) {
            if (!empty($val)) {
                $i++;
                if ($i > 1) {
                    $url .= '&';
                } else {
                    $url .= '?';
                }

                if (is_array($val)) {
                    $val = implode(',', $val);
                }
                $url .= $param . '=' . $val;
            }
        }

        return $url;
    }