private function setHandler($authorization)
    {
        $stack = new HandlerStack();

        $stack->setHandler(new CurlHandler());

        // Set authorization headers
        $this->authorization = $authorization;
        $stack->push(Middleware::mapRequest(function (Request $request) {
                return $request->withHeader('Authorization', $this->authorization);
        }), 'set_authorization_header');
        
        // Set the request ui
        $stack->push(Middleware::mapRequest(function (Request $request) {
            $uri = $request->getUri()->withHost($this->host)->withScheme($this->scheme);

            return $request->withUri($uri);
        }), 'set_host');

        return $stack;
    }
private function setHandler($authorization)
    {
        $stack = new HandlerStack();

        $stack->setHandler(new CurlHandler());

        // Set authorization headers
        $this->authorization = $authorization;
        $stack->push(Middleware::mapRequest(function (Request $request) {
                return $request->withHeader('Authorization', $this->authorization);
        }), 'set_authorization_header');
        
        // Set the request ui
        $stack->push(Middleware::mapRequest(function (Request $request) {
            $uri = $request->getUri()->withHost($this->host)->withScheme($this->scheme);

            return $request->withUri($uri);
        }), 'set_host');

        return $stack;
    }
private function setHandler ( $ authorization ) { $ stack = new HandlerStack ( ) ; $ stack -> setHandler ( new CurlHandler ( ) ) ; // Set authorization headers $ this -> authorization = $ authorization ; $ stack -> push ( Middleware :: mapRequest ( function ( Request $ request ) { return $ request -> withHeader ( 'Authorization' , $ this -> authorization ) ; } ) , 'set_authorization_header' ) ; // Set the request ui $ stack -> push ( Middleware :: mapRequest ( function ( Request $ request ) { $ uri = $ request -> getUri ( ) -> withHost ( $ this -> host ) -> withScheme ( $ this -> scheme ) ; return $ request -> withUri ( $ uri ) ; } ) , 'set_host' ) ; return $ stack ; }
Generate a new handler that will manage the HTTP requests.

Some middleware are also configured to manage the authorization header and request URI

@param string $authorization Authorization code to pass in the header
@return \GuzzleHttp\HandlerStack
Generate a new handler that will manage the HTTP requests .