src/Context/ApiContext.php
protected function sendRequest() {
        if (!empty($this->requestOptions['form_params']) && !$this->forceHttpMethod) {
            $this->setRequestMethod('POST');
        }

        if (!empty($this->requestOptions['multipart']) && !empty($this->requestOptions['form_params'])) {
            // We have both multipart and form_params set in the request options. Take all
            // form_params and add them to the multipart part of the option array as it's not
            // allowed to have both.
            foreach ($this->requestOptions['form_params'] as $name => $contents) {
                if (is_array($contents)) {
                    // The contents is an array, so use array notation for the part name and store
                    // all values under this name
                    $name .= '[]';

                    foreach ($contents as $content) {
                        $this->requestOptions['multipart'][] = [
                            'name' => $name,
                            'contents' => $content,
                        ];
                    }
                } else {
                    $this->requestOptions['multipart'][] = [
                        'name' => $name,
                        'contents' => $contents
                    ];
                }
            }

            // Remove form_params from the options, otherwise Guzzle will throw an exception
            unset($this->requestOptions['form_params']);
        }

        try {
            $this->response = $this->client->send(
                $this->request,
                $this->requestOptions
            );
        } catch (RequestException $e) {
            $this->response = $e->getResponse();

            if (!$this->response) {
                throw $e;
            }
        }

        return $this;
    }
protected function sendRequest() {
        if (!empty($this->requestOptions['form_params']) && !$this->forceHttpMethod) {
            $this->setRequestMethod('POST');
        }

        if (!empty($this->requestOptions['multipart']) && !empty($this->requestOptions['form_params'])) {
            // We have both multipart and form_params set in the request options. Take all
            // form_params and add them to the multipart part of the option array as it's not
            // allowed to have both.
            foreach ($this->requestOptions['form_params'] as $name => $contents) {
                if (is_array($contents)) {
                    // The contents is an array, so use array notation for the part name and store
                    // all values under this name
                    $name .= '[]';

                    foreach ($contents as $content) {
                        $this->requestOptions['multipart'][] = [
                            'name' => $name,
                            'contents' => $content,
                        ];
                    }
                } else {
                    $this->requestOptions['multipart'][] = [
                        'name' => $name,
                        'contents' => $contents
                    ];
                }
            }

            // Remove form_params from the options, otherwise Guzzle will throw an exception
            unset($this->requestOptions['form_params']);
        }

        try {
            $this->response = $this->client->send(
                $this->request,
                $this->requestOptions
            );
        } catch (RequestException $e) {
            $this->response = $e->getResponse();

            if (!$this->response) {
                throw $e;
            }
        }

        return $this;
    }
protected function sendRequest ( ) { if ( ! empty ( $ this -> requestOptions [ 'form_params' ] ) && ! $ this -> forceHttpMethod ) { $ this -> setRequestMethod ( 'POST' ) ; } if ( ! empty ( $ this -> requestOptions [ 'multipart' ] ) && ! empty ( $ this -> requestOptions [ 'form_params' ] ) ) { // We have both multipart and form_params set in the request options. Take all // form_params and add them to the multipart part of the option array as it's not // allowed to have both. foreach ( $ this -> requestOptions [ 'form_params' ] as $ name => $ contents ) { if ( is_array ( $ contents ) ) { // The contents is an array, so use array notation for the part name and store // all values under this name $ name .= '[]' ; foreach ( $ contents as $ content ) { $ this -> requestOptions [ 'multipart' ] [ ] = [ 'name' => $ name , 'contents' => $ content , ] ; } } else { $ this -> requestOptions [ 'multipart' ] [ ] = [ 'name' => $ name , 'contents' => $ contents ] ; } } // Remove form_params from the options, otherwise Guzzle will throw an exception unset ( $ this -> requestOptions [ 'form_params' ] ) ; } try { $ this -> response = $ this -> client -> send ( $ this -> request , $ this -> requestOptions ) ; } catch ( RequestException $ e ) { $ this -> response = $ e -> getResponse ( ) ; if ( ! $ this -> response ) { throw $ e ; } } return $ this ; }
Send the current request and set the response instance

@throws RequestException
@return self
Send the current request and set the response instance