src/Factory/ApiClientFactory.php
public function createV4Client($username, $password)
    {
        if (!$this->userbaseUrl) {
            throw new RuntimeException(
                'In order to createV4Client you need to have previsously called ApiClientFactory::setUserbaseJwtAuthenticatorUrl'
            );
        }
        $authenticator = new UserbaseJwtAuthenticatorClient(
            $this->userbaseUrl,
            $this->tlsCertVerification
        );
        try {
            $token = $authenticator->authenticate($username, $password);
        } catch (AuthenticationFailureException $e) {
            throw new ClientCreationException(
                'Failed to create a v4 API client because of a failure during authentication with UserBase.',
                null,
                $e
            );
        }
        $httpClient = new GuzzleClient(
            [
                'base_uri' => $this->hubUrl,
                'verify' => $this->tlsCertVerification,
                'headers' => array_replace(
                    ['User-Agent' => 'HubV4Client (Guzzle)'],
                    $this->requestHeaders,
                    ['X-Authorization' => "Bearer {$token}"]
                ),
            ]
        );
        return new HubV4Client($httpClient);
    }
public function createV4Client($username, $password)
    {
        if (!$this->userbaseUrl) {
            throw new RuntimeException(
                'In order to createV4Client you need to have previsously called ApiClientFactory::setUserbaseJwtAuthenticatorUrl'
            );
        }
        $authenticator = new UserbaseJwtAuthenticatorClient(
            $this->userbaseUrl,
            $this->tlsCertVerification
        );
        try {
            $token = $authenticator->authenticate($username, $password);
        } catch (AuthenticationFailureException $e) {
            throw new ClientCreationException(
                'Failed to create a v4 API client because of a failure during authentication with UserBase.',
                null,
                $e
            );
        }
        $httpClient = new GuzzleClient(
            [
                'base_uri' => $this->hubUrl,
                'verify' => $this->tlsCertVerification,
                'headers' => array_replace(
                    ['User-Agent' => 'HubV4Client (Guzzle)'],
                    $this->requestHeaders,
                    ['X-Authorization' => "Bearer {$token}"]
                ),
            ]
        );
        return new HubV4Client($httpClient);
    }
public function createV4Client ( $ username , $ password ) { if ( ! $ this -> userbaseUrl ) { throw new RuntimeException ( 'In order to createV4Client you need to have previsously called ApiClientFactory::setUserbaseJwtAuthenticatorUrl' ) ; } $ authenticator = new UserbaseJwtAuthenticatorClient ( $ this -> userbaseUrl , $ this -> tlsCertVerification ) ; try { $ token = $ authenticator -> authenticate ( $ username , $ password ) ; } catch ( AuthenticationFailureException $ e ) { throw new ClientCreationException ( 'Failed to create a v4 API client because of a failure during authentication with UserBase.' , null , $ e ) ; } $ httpClient = new GuzzleClient ( [ 'base_uri' => $ this -> hubUrl , 'verify' => $ this -> tlsCertVerification , 'headers' => array_replace ( [ 'User-Agent' => 'HubV4Client (Guzzle)' ] , $ this -> requestHeaders , [ 'X-Authorization' => "Bearer {$token}" ] ) , ] ) ; return new HubV4Client ( $ httpClient ) ; }
Get a client for the v4 Hub API.

@param string $username
@param string $password

@throws \RuntimeException if setUserbaseJwtAuthenticatorUrl was not called
@throws \Hub\Client\Exception\ClientCreationException
Get a client for the v4 Hub API .