src/HttpClientFactory.php
public static function create(
        $url,
        TokenService $tokenService,
        CertificateStorage $certificateStorage,
        InstallationService $installationService,
        TokenStorage $tokenStorage
    ) {
        $sessionToken    = $tokenService->sessionToken();
        $publicServerKey = $certificateStorage->load(CertificateType::BUNQ_SERVER_KEY());

        $handlerStack = HandlerStack::create();
        $handlerStack->push(
            Middleware::mapRequest(new RequestIdMiddleware())
        );
        $handlerStack->push(
            Middleware::mapRequest(new RequestAuthenticationMiddleware($sessionToken))
        );
        $handlerStack->push(
            Middleware::mapRequest(new RequestSignatureMiddleware($certificateStorage->load(CertificateType::PRIVATE_KEY())))
        );
        $handlerStack->push(
            Middleware::mapResponse(new ResponseSignatureMiddleware($publicServerKey))
        );
        $handlerStack->push(
            Middleware::mapResponse(new RefreshSessionMiddleware($installationService, $tokenStorage))
        );

        $httpClient = self::createBaseClient($url, $handlerStack);

        return $httpClient;
    }
public static function create(
        $url,
        TokenService $tokenService,
        CertificateStorage $certificateStorage,
        InstallationService $installationService,
        TokenStorage $tokenStorage
    ) {
        $sessionToken    = $tokenService->sessionToken();
        $publicServerKey = $certificateStorage->load(CertificateType::BUNQ_SERVER_KEY());

        $handlerStack = HandlerStack::create();
        $handlerStack->push(
            Middleware::mapRequest(new RequestIdMiddleware())
        );
        $handlerStack->push(
            Middleware::mapRequest(new RequestAuthenticationMiddleware($sessionToken))
        );
        $handlerStack->push(
            Middleware::mapRequest(new RequestSignatureMiddleware($certificateStorage->load(CertificateType::PRIVATE_KEY())))
        );
        $handlerStack->push(
            Middleware::mapResponse(new ResponseSignatureMiddleware($publicServerKey))
        );
        $handlerStack->push(
            Middleware::mapResponse(new RefreshSessionMiddleware($installationService, $tokenStorage))
        );

        $httpClient = self::createBaseClient($url, $handlerStack);

        return $httpClient;
    }
public static function create ( $ url , TokenService $ tokenService , CertificateStorage $ certificateStorage , InstallationService $ installationService , TokenStorage $ tokenStorage ) { $ sessionToken = $ tokenService -> sessionToken ( ) ; $ publicServerKey = $ certificateStorage -> load ( CertificateType :: BUNQ_SERVER_KEY ( ) ) ; $ handlerStack = HandlerStack :: create ( ) ; $ handlerStack -> push ( Middleware :: mapRequest ( new RequestIdMiddleware ( ) ) ) ; $ handlerStack -> push ( Middleware :: mapRequest ( new RequestAuthenticationMiddleware ( $ sessionToken ) ) ) ; $ handlerStack -> push ( Middleware :: mapRequest ( new RequestSignatureMiddleware ( $ certificateStorage -> load ( CertificateType :: PRIVATE_KEY ( ) ) ) ) ) ; $ handlerStack -> push ( Middleware :: mapResponse ( new ResponseSignatureMiddleware ( $ publicServerKey ) ) ) ; $ handlerStack -> push ( Middleware :: mapResponse ( new RefreshSessionMiddleware ( $ installationService , $ tokenStorage ) ) ) ; $ httpClient = self :: createBaseClient ( $ url , $ handlerStack ) ; return $ httpClient ; }
Creates the HttpClient with all handlers

@param string              $url
@param TokenService        $tokenService
@param CertificateStorage  $certificateStorage
@param InstallationService $installationService
@param TokenStorage        $tokenStorage

@return ClientInterface
Creates the HttpClient with all handlers