Call the given soap method
@param $method
@param $params (optional, default: empty array)
541326
public function call($method, $params=[]) {
    $header = $this->generateWSSecurityHeader($this->user, $this->password);
    $response = $this->__soapCall($method, sizeof($params) > 0 ? [$params] : [], null, $header);
    // in document/literal style the "return" parameter holds the result
    return property_exists($response, 'return') ? $response->return : $response;
  }
847581
public function __soapCall(
        $function_name,
        $arguments,
        $options = null,
        $input_headers = null,
        &$output_headers = null
    ) {
        $class = get_class($this);


        $service = strtr(substr($class, strrpos($class, '\\') + 1), ['ServiceService' => 'Service']);
        $this->__setCookie('timestamp', $timestamp = time());
        $this->__setCookie('nonce', $nonce = uniqid('', true));
        $this->__setCookie('signature', $this->urlEncode($this->sign(array_merge($arguments, [
            '__method' => $function_name,
            '__service' => $service,
            '__hostname' => $this->endpoint,
            '__timestamp' => $timestamp,
            '__nonce' => $nonce,

        ]))));
        return parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
    }
752974
protected function _detectMethod($method, $params)
    {
        // multi-HTTP method endpoints
        switch($method) {
            case 'account/settings':
                $method = count($params) > 0 ? $method . '__post' : $method;
                break;
        }

        $apimethods = $this->getApiMethods();
        foreach ($apimethods as $httpmethod => $methods) {
            if (in_array($method, $methods)) {
                return $httpmethod;
            }
        }
        throw new \Exception('Can\'t find HTTP method to use for "' . $method . '".');
    }
602437
public function callAction($method, $parameters)
    {
        $route = app('router')->current();
        $request = app('request');
        $this->assignAfter($route, $request, $method);
        $response = $this->before($route, $request, $method);

        if (is_null($response)) {
            $response = call_user_func_array([$this, $method], $parameters);
        }

        return $response;
    }
548912
public function notify(string $method, $params): Promise
    {
        return $this->protocolWriter->write(
            new Message(
                new AdvancedJsonRpc\Notification($method, (object)$params)
            )
        );
    }
412928
public function callAction($method, $parameters)
    {
        $result = null;
        $this->setupLayout($method);

        // Call the action if $this->general() doesn't suggest otherwise
        if (method_exists($this, 'general'))
            $result = $this->general();
        if (!$result)
            $result = parent::callAction($method, $parameters);

        return isset($result) ? $result : $this->layout; // must use isset() for case of empty array in AJAX response
    }
800920
public function call($method, $params = [])
    {
        if (null === $this->client) {
            $this->client = new Client([
                'base_uri' => static::API_URL,
                'content-type' => 'application/json',
            ]);
        }

        $requestParams = array_merge($this->defaultParams, [
            $method => [$params],
        ]);

        if ($this->sandbox) {
            $requestParams['apikey'] = self::SANDBOX_KEY;
        }

        $response = $this->client->post(null, ['body' => json_encode($requestParams)]);
        if ($response->getStatusCode() != 200) {
            throw new \Exception('Api http error: ' . $response->getStatusCode(), $response->getStatusCode());
        }

        $result = json_decode($response->getBody(), true);
        if (isset($result['error'])) {
            throw new \BadMethodCallException('Api error: ' . $result['error']['description'],
                $result['error']['code']);
        }

        return $result;
    }
1096253
public function request($method, $params = [])
    {
        return $this->getClient()->request($method, array_merge($params, $this->getAuth()->getAuthParams()));
    }
823511
public function call($resource, $params = array(), $method = 'GET')
    {
        if (!empty($params) && is_array($params)) {
          $queryString = http_build_query($params);
        }
        else {
          $queryString = '';
        }

        $requestUrl = self::API_URL . $resource . ((strtolower($method) == 'get') ? '?' . $queryString : '');

        $curl = curl_init();

        $curl_options = array(
          CURLOPT_USERPWD => $this->getAuthenticationString(),
          CURLOPT_RETURNTRANSFER => 1,
          CURLOPT_URL => $requestUrl,
          CURLOPT_TIMEOUT => 30,
          CURLOPT_CONNECTTIMEOUT => 30,
          CURLOPT_HTTPHEADER => array('Accept: application/xml'),
        );

        if (strtolower($method) == 'post') {
          $curl_options[CURLOPT_POST] = 1;
          $curl_options[CURLOPT_POSTFIELDS] = $params;
        }

        curl_setopt_array($curl, $curl_options);
        $response = curl_exec($curl);
        $curl_info = curl_getinfo($curl);

        //@todo test for curl error
        if ($errno = curl_errno($curl)) {
          $error_message = $errno . ': ' . curl_strerror($errno);
          throw new Exception($error_message, $errno);
        }
        curl_close($curl);

        //@todo test for any non 200 response
        if ($curl_info['http_code'] != 200) {
            throw new Exception("Response: Bad response - HTTP Code:". $curl_info['http_code']);
        }

        $xmlObject = simplexml_load_string($response);

        if ($xmlObject === false) {
            throw new Exception("Response: Response was not valid XML");
        }

        return $xmlObject;
    }
1263521
public static function call($object, string $method, array $parameters)
    {
        $reflectionClass = new \ReflectionClass($object);
        $reflectionMethod = $reflectionClass->getMethod($method);
        $arguments = [];

        foreach ($reflectionMethod->getParameters() as $i => $reflectionParameter) {
            $argument = null;

            if (array_key_exists($reflectionParameter->name, $parameters) || array_key_exists($i, $parameters)) {
                $argument = $parameters[$reflectionParameter->name] ?? $parameters[$i] ?? null;
            } elseif ($reflectionParameter->isDefaultValueAvailable()) {
                $argument = $reflectionParameter->getDefaultValue();
            }

            if ($reflectionType = $reflectionParameter->getType()) {
                if ($reflectionType->isBuiltin()) {
                    if ($argument !== null || !$reflectionType->allowsNull()) {
                        settype($argument, $reflectionType->getName());
                    }
                } elseif ($argument === null && !$reflectionType->allowsNull()) {
                    return null;
                }
            }

            $arguments[] = $argument;
        }

        if ($reflectionMethod->isConstructor()) {
            return $reflectionClass->newInstanceArgs($arguments);
        }

        $reflectionMethod->setAccessible(true);

        return $reflectionMethod->invokeArgs($reflectionMethod->isStatic() ? null : $object, $arguments);
    }
85368
protected function callSoapMethod($method)
    {
        $args = func_get_args();
        array_shift($args);

        LogHandler::log($args, LoggerInterface::LEVEL_INFO, 'request_object');

        try {
            $response = call_user_func_array([$this->getSoapClient(), $method], $args);
            LogHandler::log($response, LoggerInterface::LEVEL_INFO, 'response_object');
        } catch (\SoapFault $e) {
            LogHandler::log(
                'SOAP ERROR (' . $e->faultcode . '): ' . $e->getMessage(),
                LoggerInterface::LEVEL_ERROR,
                'error'
            );
            throw new \SoapFault($e->faultcode, $e->faultstring);
        }

        $this->validateResponseCertificate();

        LogHandler::log(
            "Response certificate validated successfully",
            LoggerInterface::LEVEL_INFO,
            'response_certificate_validated'
        );

        return $response;
    }
248875
public function call($url, $method = 'GET', $params = [])
    {
        // Set call parameters
        $params = array_merge($this->params, is_array($params)? $params : []);

        // Setup parameters
        $content = '';
        $queryString = http_build_query($params);
        if ($method === 'GET') {
            $url = $url . '?' . $queryString;
        } else {
            $content = $queryString;
        }

        // Make call
        $result = @file_get_contents($url, false, stream_context_create([
            'http' => [
                'method'  => $method,
                'header'  => 'Content-type: application/x-www-form-urlencoded',
                'content' => $content
            ]
        ]));

        // Return result
        return $result;
    }
450658
public static function invokeSoap($wsdlURL, $method,
                                      array $params = array(),
                                      array $options = array())
    {
        try {
            $soapClient = new \SoapClient($wsdlURL, $options);
            $result     = $soapClient->$method($params);
        } catch (\SoapFault $ex) {
            $result = false;
        }
        return $result;
    }
1278902
private function _request($method, $params = array(), $url = self::API_ENDPOINT) {
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_USERAGENT, 'Elvanto_API-PHP/1.0.0');
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
		curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_HEADER, false);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
		curl_setopt($ch, CURLOPT_TIMEOUT, 10);
		// Exchange or refresh a token
		if ($method === 'oauth') {
			$headers = array('Content-Type: application/x-www-form-urlencoded');
			curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
		// Call an API method
		} else {
			$url = self::API_ENDPOINT . '/' . $method . '.json';
			$params['grant_type'] = 'client_credentials';
			$headers = array('Content-Type: application/json; charset=utf-8');
			if (isset($this->auth_details['access_token'])) { // Authenticating using OAuth
				$headers[] = 'Authorization: Bearer ' . $this->auth_details['access_token'];
			} else if (isset($this->auth_details['api_key'])) { // Authenticating using an API key
				curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
				curl_setopt($ch, CURLOPT_USERPWD, $this->auth_details['api_key'] . ':nopass');
			}
			curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
		}
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		$response = curl_exec($ch);
		if (curl_error($ch)) {
			trigger_error('API call to ' . $url . ' failed: ' . curl_error($ch), E_USER_ERROR);
			return false;
		}
		curl_close($ch);
		return $response ? json_decode($response) : false;
	}
371956
public function invokeArgs($method, array $params)
	{
		if (
			$this->logger !== null &&
			$this->logger->isHandling(\Monolog\Logger::DEBUG)
		) {
			$methodSynopsis = $method . '(';
			foreach (array_values($params) as $index => $param) {
				if ($index > 0) {
					$methodSynopsis .= ', ';
				}
				$methodSynopsis .= var_export($param, true);
			}
			$methodSynopsis .= ')';

			$this->logger->addDebug(
				'Invoke remote object method ' . $methodSynopsis,
				array(
					 'transport' => $this->transport,
					 'method'    => $method,
					 'params'    => $params
				)
			);
		}

		$request = $this->encoder->encodeMethod($method, $params);

		$response = $this->transport->request($request);

		$result = $this->encoder->decodeResult($response);

		if (
			$this->logger !== null &&
			$this->logger->isHandling(\Monolog\Logger::DEBUG)
		) {
			$this->logger->addDebug(
				'Receive methods ' . $methodSynopsis . ' result.',
				array(
					 'transport' => $this->transport,
					 'method'    => $method,
					 'params'    => $params
				)
			);
		}

		return $result;
	}
807917
public function callAction($method, array $parameters = [])
    {
        $isAjax = app()->make('request')->ajax();

        $method = $this->checkAjaxMethod($method, $isAjax);
        $parameters = $this->checkParametersResolving($method, $parameters);

        return parent::callAction($method, $parameters);
    }
409510
public function createCall($method, $params = array())
	{
		$params = array_values($params);

		if ($this->isAsync())
		{
			$output = "_gaq.push(['{$method}',";
			$output .= substr(json_encode($params), 1, -1);
			$output .= ']);';
		}
		else
		{
			$output = "pageTracker.{$method}(";
			$output .= substr(json_encode($params), 1, -1);
			$output .= ');';
		}

		return $output;
	}