cybercog / youtrack-rest-php

JetBrains YouTrack REST API PHP Client
https://komarev.com/sources/php-youtrack-rest
MIT License
35 stars 25 forks source link

[Concept] Remove Authorization responsibility from YouTrackClient #46

Open antonkomarev opened 4 years ago

antonkomarev commented 4 years ago

I've started to overlook an API and I maybe it should be refactored.

antonkomarev commented 4 years ago

Solution №1

// Instantiate YouTrack API Cookie Authenticator
$authenticator = new Rest\Authenticator\CookieAuthenticator($apiUsername, $apiPassword);

// Instantiate YouTrack API Cookie Authorizer
$authorizer = new Rest\Authorizer\CookieAuthorizer($authenticator);

// Instantiate YouTrack API HTTP Client
$httpClient = new Rest\HttpClient\GuzzleHttpClient($psrHttpClient, $authorizer);

// Instantiate YouTrack API Client
$client = new Rest\Client\YouTrackClient($httpClient);