protected function createRequest(
        $method,
        array $headers,
        array $queryParams,
        array $postParameters,
        $path,
        $locationMode,
        $body = Resources::EMPTY_STRING
    ) {
        if ($locationMode == LocationMode::SECONDARY_ONLY ||
            $locationMode == LocationMode::SECONDARY_THEN_PRIMARY) {
            $uri = $this->psrSecondaryUri;
        } else {
            $uri = $this->psrPrimaryUri;
        }

        //Append the path, not replacing it.
        if ($path != null) {
            $exPath = $uri->getPath();
            if ($exPath != '') {
                //Remove the duplicated slash in the path.
                if ($path != '' && $path[0] == '/') {
                    $path = $exPath . substr($path, 1);
                } else {
                    $path = $exPath . $path;
                }
            }
            $uri = $uri->withPath($path);
        }

        // add query parameters into headers
        if ($queryParams != null) {
            $queryString = Psr7\build_query($queryParams);
            $uri = $uri->withQuery($queryString);
        }

        // add post parameters into bodys
        $actualBody = null;
        if (empty($body)) {
            if (empty($headers['content-type'])) {
                $headers['content-type'] = 'application/x-www-form-urlencoded';
                $actualBody = Psr7\build_query($postParameters);
            }
        } else {
            $actualBody = $body;
        }

        $request = new Request(
            $method,
            $uri,
            $headers,
            $actualBody
        );

        //add content-length to header
        $bodySize = $request->getBody()->getSize();
        if ($bodySize > 0) {
            $request = $request->withHeader('content-length', $bodySize);
        }
        return $request;
    }
protected function createRequest(
        $method,
        array $headers,
        array $queryParams,
        array $postParameters,
        $path,
        $locationMode,
        $body = Resources::EMPTY_STRING
    ) {
        if ($locationMode == LocationMode::SECONDARY_ONLY ||
            $locationMode == LocationMode::SECONDARY_THEN_PRIMARY) {
            $uri = $this->psrSecondaryUri;
        } else {
            $uri = $this->psrPrimaryUri;
        }

        //Append the path, not replacing it.
        if ($path != null) {
            $exPath = $uri->getPath();
            if ($exPath != '') {
                //Remove the duplicated slash in the path.
                if ($path != '' && $path[0] == '/') {
                    $path = $exPath . substr($path, 1);
                } else {
                    $path = $exPath . $path;
                }
            }
            $uri = $uri->withPath($path);
        }

        // add query parameters into headers
        if ($queryParams != null) {
            $queryString = Psr7\build_query($queryParams);
            $uri = $uri->withQuery($queryString);
        }

        // add post parameters into bodys
        $actualBody = null;
        if (empty($body)) {
            if (empty($headers['content-type'])) {
                $headers['content-type'] = 'application/x-www-form-urlencoded';
                $actualBody = Psr7\build_query($postParameters);
            }
        } else {
            $actualBody = $body;
        }

        $request = new Request(
            $method,
            $uri,
            $headers,
            $actualBody
        );

        //add content-length to header
        $bodySize = $request->getBody()->getSize();
        if ($bodySize > 0) {
            $request = $request->withHeader('content-length', $bodySize);
        }
        return $request;
    }
protected function createRequest ( $ method , array $ headers , array $ queryParams , array $ postParameters , $ path , $ locationMode , $ body = Resources :: EMPTY_STRING ) { if ( $ locationMode == LocationMode :: SECONDARY_ONLY || $ locationMode == LocationMode :: SECONDARY_THEN_PRIMARY ) { $ uri = $ this -> psrSecondaryUri ; } else { $ uri = $ this -> psrPrimaryUri ; } //Append the path, not replacing it. if ( $ path != null ) { $ exPath = $ uri -> getPath ( ) ; if ( $ exPath != '' ) { //Remove the duplicated slash in the path. if ( $ path != '' && $ path [ 0 ] == '/' ) { $ path = $ exPath . substr ( $ path , 1 ) ; } else { $ path = $ exPath . $ path ; } } $ uri = $ uri -> withPath ( $ path ) ; } // add query parameters into headers if ( $ queryParams != null ) { $ queryString = Psr7 \ build_query ( $ queryParams ) ; $ uri = $ uri -> withQuery ( $ queryString ) ; } // add post parameters into bodys $ actualBody = null ; if ( empty ( $ body ) ) { if ( empty ( $ headers [ 'content-type' ] ) ) { $ headers [ 'content-type' ] = 'application/x-www-form-urlencoded' ; $ actualBody = Psr7 \ build_query ( $ postParameters ) ; } } else { $ actualBody = $ body ; } $ request = new Request ( $ method , $ uri , $ headers , $ actualBody ) ; //add content-length to header $ bodySize = $ request -> getBody ( ) -> getSize ( ) ; if ( $ bodySize > 0 ) { $ request = $ request -> withHeader ( 'content-length' , $ bodySize ) ; } return $ request ; }
Create the request to be sent.

@param  string $method         The method of the HTTP request
@param  array  $headers        The header field of the request
@param  array  $queryParams    The query parameter of the request
@param  array  $postParameters The HTTP POST parameters
@param  string $path           URL path
@param  string $body           Request body

@return \GuzzleHttp\Psr7\Request
Create the request to be sent .