Returns the javascript needed for a remote function.

@param string $url Request Url
@param array $options Options. See JqueryHelper::jQueryLinkToRemote
@see JqueryHelper:jQueryLinkToRemote
@return string
558147
public function jQueryRemoteFunction($url, $options)
    {
        $resolver = new OptionsResolver();
        $resolver->setDefaults(
            array(
                'update' => null,
                'position' => 'replace',
                'loading' => null, //Callback
                'complete' => null, //Callback
                'success' => null, //Callback
                'script' => true,
                'dataType' => null,
                'method' => 'POST',
                'type' => true,
                'form' => false,
                'submit' => null,
                'with' => null,
                'cache' => false,
                'before' => null,
                'after' => null,
                'condition' => null,
                'confirm' => null,
                'cancel' => null,
            )
        );
        $resolver->setAllowedTypes('update', array('array', 'string', 'null'));
        $resolver->setAllowedValues('position', array('before', 'after', 'top', 'bottom', 'replace'));
        $resolver->setAllowedTypes('script', array('bool'));
        $resolver->setAllowedValues('method', array('POST', 'GET', 'PUT', 'DELETE'));
        $resolver->setAllowedTypes('type', array('bool'));
        $resolver->setAllowedTypes('form', array('bool'));
        $resolver->setAllowedTypes('cache', array('bool'));
        $options = $resolver->resolve($options);

        // Defining elements to update
        if ($options['update'] && is_array($options['update'])) {
            // On success, update the element with returned data
            if (isset($options['update']['success'])) {
                $updateSuccess = "#" . $options['update']['success'];
            }

            // On failure, execute a client-side function
            if (isset($options['update']['failure'])) {
                $updateFailure = $options['update']['failure'];
            }
        } elseif ($options['update']) {
            $updateSuccess = "#" . $options['update'];
        }

        // Update method
        $updateMethod = 'html';
        switch ($options['position']) {
            case 'before':
                $updateMethod = 'before';
                break;
            case 'after':
                $updateMethod = 'after';
                break;
            case 'top':
                $updateMethod = 'prepend';
                break;
            case 'bottom':
                $updateMethod = 'append';
                break;
        }

        // Data Type
        if ($options['dataType']) {
            $dataType = $options['dataType'];
        } elseif ($options['script']) {
            $dataType = 'html';
        } else {
            $dataType = 'text';
        }

        // Is it a form submitting
        if ($options['form']) {
            $formData = 'jQuery(this).serialize()';
        } elseif ($options['submit']) {
            $formData = '{\'#' . $options['submit'] . '\'}.serialize()';
        } elseif ($options['with']) {
            $formData = $options['with'];
        }

        //Cache
        $cache = 'false';
        if ($options['cache']) {
            $cache = 'true';
        }

        // build the function
        $function = "jQuery.ajax({";
        $function .= 'type:\'' . $options['method'] . '\'';
        $function .= ',dataType:\'' . $dataType . '\'';
        $function .= ',cache: ' . $cache;
        if (!$options['type']) {
            $function .= ',async: false';
        }
        if (isset($formData)) {
            $function .= ',data:' . $formData;
        }
        if (isset($updateSuccess) && !$options['success']) {
            $function .= ',success:function(data, textStatus){jQuery(\'' . $updateSuccess . '\').' . $updateMethod . '(data);}';
        }
        if (isset($updateFailure)) {
            $function .= ',error:function(XMLHttpRequest, textStatus, errorThrown){' . $updateFailure . '}';
        }
        if ($options['loading']) {
            $function .= ',beforeSend:function(XMLHttpRequest){' . $options['loading'] . '}';
        }
        if ($options['complete']) {
            $function .= ',complete:function(XMLHttpRequest, textStatus){' . $options['complete'] . '}';
        }
        if ($options['success']) {
            $function .= ',success:function(data, textStatus){' . $options['success'] . '}';
        }
        $function .= ',url:\'' . $url . '\'';
        $function .= '})';

        if ($options['before']) {
            $function = $options['before'] . '; ' . $function;
        }
        if ($options['after']) {
            $function = $function . '; ' . $options['after'];
        }
        if ($options['condition']) {
            $function = 'if (' . $options['condition'] . ') { ' . $function . '; }';
        }
        if ($options['confirm']) {
            $function = "if (confirm('" . $this->util->escapeJavascript($options['confirm']) . "')) { $function; }";
            if ($options['cancel']) {
                $function = $function . ' else { ' . $options['cancel'] . ' }';
            }
        }

        return $function;
    }
410522
private function requestAPI($method, $url, array $options = [])
    {
        try {
            return $this->sendRequest((string)$method, (string)$url, $options);
        } catch (SessionWasExpiredException $e) {
            return $this->sendRequest((string)$method, (string)$url, $options);
        } catch (ClientException $e) {
            throw new BunqException($e);
        }
    }
960953
public function request($method, $url, $options)
    {
        $request = $this->authClient->getAuthenticatedRequest($method, $url, $this->getAccessToken());

        return $this->httpClient->send($request, $options);
    }
50219
public function script($url, $attributes = [], $secure = null)
    {
        $attributes['src'] = $this->url->asset($url, $secure);

        return $this->toHtmlString('<script' . $this->attributes($attributes) . '></script>');
    }
581025
public function addScript($url, $options = [], $attribs = [])
    {
        // B/C
        if (!is_array($options)) {
            $options = ['version' => $options];
        }

        $options = array_merge([
            'version' => null,
        ], $options);

        $alias = $this->resolveRawAlias($url);

        $file = [
            'url' => $this->handleUri($url),
            'attribs' => array_merge($attribs, $alias['attrs'] ?? []),
            'options' => array_merge($options, $alias['options'] ?? []),
        ];

        $this->scripts[$url] = $file;

        return $this;
    }
1025859
protected function exec(Url $url, array $options)
    {
        $connection = curl_init((string) $url);
        curl_setopt_array($connection, $options);

        $curl = new CurlResult($connection);

        //Get only text responses
        $curl->onHeader(function ($name, $value, $data) {
            if ($name === 'content-type') {
                $data->isBinary = !preg_match('/(text|html|json)/', strtolower($value));
            }
        });

        $curl->onBody(function ($string, stdClass $data) {
            return empty($data->isBinary);
        });

        curl_exec($connection);

        $result = $curl->getResult();

        curl_close($connection);

        return $this->responses[] = new Response(
            $url,
            Url::create($result['url']),
            $result['statusCode'],
            $result['contentType'],
            $result['content'],
            $result['headers'],
            $result['info']
        );
    }
846341
public function fetch($url, $options)
    {
        $this->init();

        $request_type = $this->config->http_post === true ?
            'form_params' : 'query';
        $options = [$request_type => $options];

        try {
            $response = $this->client->request(
                $this->config->http_post === true ? 'POST' : 'GET',
                $url,
                $options
            );
        } catch (GuzzleException $exception) {
            throw new ConnectionException(
                $exception->getMessage(),
                $exception->getCode()
            );
        }

        if ($response->getStatusCode() >= 400) {
            // ccp is using error codes even if they send a valid application
            // error response now, so we have to use the content as result
            // for some of the errors. This will actually break if CCP ever uses
            // the HTTP Status for an actual transport related error.
            switch ($response->getStatusCode()) {
                case 400:
                case 403:
                case 500:
                case 503:
                    return $response->getBody()->getContents();
                    break;
            }

            throw new HTTPException(
                $response->getStatusCode(),
                $url
            );
        }

        return $response->getBody()->getContents();
    }
358373
public static function createFromUri($url, array $options = [])
    {
        return extension_loaded('curl') ?
            self::createViaHttpClient($url, $options) : self::createViaStreamWrapper($url, $options);
    }
177178
public static function post(string $url, array $options = []) : array {
		$result = [
			'success' => false,
			'error' => [],
			'data' => null
		];
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query2($options['params']));
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$result['data'] = curl_exec($ch);
		if (!empty($options['json'])) {
			$result['data'] = json_decode($result['data'], true);
		}
		curl_close($ch);
		$result['success'] = true;
		return $result;
	}
1301300
public function options($url, $data = [], array $options = [])
    {
        $options = $this->_mergeOptions($options);
        $url = $this->buildUrl($url, [], $options);

        return $this->_doRequest(Request::METHOD_OPTIONS, $url, $data, $options);
    }
331371
protected function appendUrlOptions($url, $options)
    {
        $options = array_only($options, [
            'welcome_msg',
            'timezone',
            'anonymous',
            'minimal'
        ]);

        $boolean_keys = ['minimal', 'anonymous'];
        foreach ($boolean_keys as $key) {
            if (isset($options[$key])) {
                $options[$key] = $this->booleanToString($options[$key]);
            } else {
                $options[$key] = 'true';
            }
        }

        return $url . '?' . http_build_query($options);
    }
150866
public function post($url, $params = array(), $options = array())
    {
        return $this->request($url, self::POST, $params, $options);
    }
266284
public function get($uri, array $options = null)
    {
        return $this->request(self::REQUEST_METHOD_GET, $uri, null, $options);
    }
191413
public static function simpleClient($url, $options = null, $transport = null) 
	{
		$options['version'] = 'simple';
		return self::client($url, $options, $transport);
	}
943257
public function build_url( $url, $options = array() ) {

		$url = (array) $url;

		$allow_port = (int) pods_v( static::$type . '_allow_port', $options, 0 );

		// If port is not allowed, always set to empty
		if ( 0 === $allow_port ) {
			$url['port'] = '';
		}

		if ( function_exists( 'http_build_url' ) ) {
			return http_build_url( $url );
		}

		$defaults = array(
			'scheme'   => 'http',
			'host'     => '',
			'port'     => '',
			'path'     => '/',
			'query'    => '',
			'fragment' => '',
		);

		$url = array_merge( $defaults, $url );

		$new_url = array();

		$new_url[] = trim( $url['scheme'] . '://', ':' );
		$new_url[] = $url['host'];

		if ( ! empty( $url['port'] ) ) {
			$new_url[] = ':' . $url['port'];
		}

		$new_url[] = '/' . ltrim( $url['path'], '/' );

		if ( ! empty( $url['query'] ) ) {
			$new_url[] = '?' . ltrim( $url['query'], '?' );
		}

		if ( ! empty( $url['fragment'] ) ) {
			$new_url[] = '#' . ltrim( $url['fragment'], '#' );
		}

		// Pull all of the parts back together
		$new_url = implode( '', $new_url );

		return $new_url;

	}
240303
public function get($url, $headers = [], $options = [])
    {
        return $this->request('GET', $url, null, $headers, $options);
    }
993820
public function script($url, $attributes = [], $secure = null)
    {
        $attributes['src'] = $this->url->asset($url, $secure);
        return '<script' . $this->attributes($attributes) . '></script>' . PHP_EOL;
    }