4747use Aternos \ModrinthApi \Model \UserPayoutHistory ;
4848use Aternos \ModrinthApi \Model \Version as VersionModel ;
4949use Aternos \ModrinthApi \Model \Thread as ThreadModel ;
50+ use Psr \Http \Client \ClientInterface ;
5051
5152
5253/**
5758 */
5859class ModrinthAPIClient
5960{
61+ protected ?ClientInterface $ httpClient ;
62+
6063 protected Configuration $ configuration ;
6164
6265 protected ?string $ apiToken = null ;
@@ -83,9 +86,11 @@ class ModrinthAPIClient
8386 * ModrinthAPIClient constructor.
8487 * @param string|null $apiToken API token used for authentication
8588 * @param Configuration|null $configuration
89+ * @param ClientInterface|null $httpClient
8690 */
87- public function __construct (?string $ apiToken = null , ?Configuration $ configuration = null )
91+ public function __construct (?string $ apiToken = null , ?Configuration $ configuration = null , ClientInterface $ httpClient = null )
8892 {
93+ $ this ->httpClient = $ httpClient ;
8994 $ this ->configuration = $ configuration ?? (Configuration::getDefaultConfiguration ())
9095 ->setUserAgent ("php-modrinth-api/1.0.0 " );
9196 $ this ->setApiToken ($ apiToken );
@@ -100,15 +105,15 @@ public function setConfiguration(Configuration $configuration): static
100105 $ this ->configuration = $ configuration ;
101106 $ this ->configuration ->setBooleanFormatForQueryString (Configuration::BOOLEAN_FORMAT_STRING );
102107
103- $ this ->projects = new ProjectsApi (null , $ this ->configuration );
104- $ this ->versions = new VersionsApi (null , $ this ->configuration );
105- $ this ->versionFiles = new VersionFilesApi (null , $ this ->configuration );
106- $ this ->users = new UsersApi (null , $ this ->configuration );
107- $ this ->teams = new TeamsApi (null , $ this ->configuration );
108- $ this ->tags = new TagsApi (null , $ this ->configuration );
109- $ this ->misc = new MiscApi (null , $ this ->configuration );
110- $ this ->notifications = new NotificationsApi (null , $ this ->configuration );
111- $ this ->threads = new ThreadsApi (null , $ this ->configuration );
108+ $ this ->projects = new ProjectsApi ($ this -> httpClient , $ this ->configuration );
109+ $ this ->versions = new VersionsApi ($ this -> httpClient , $ this ->configuration );
110+ $ this ->versionFiles = new VersionFilesApi ($ this -> httpClient , $ this ->configuration );
111+ $ this ->users = new UsersApi ($ this -> httpClient , $ this ->configuration );
112+ $ this ->teams = new TeamsApi ($ this -> httpClient , $ this ->configuration );
113+ $ this ->tags = new TagsApi ($ this -> httpClient , $ this ->configuration );
114+ $ this ->misc = new MiscApi ($ this -> httpClient , $ this ->configuration );
115+ $ this ->notifications = new NotificationsApi ($ this -> httpClient , $ this ->configuration );
116+ $ this ->threads = new ThreadsApi ($ this -> httpClient , $ this ->configuration );
112117
113118 return $ this ;
114119 }
0 commit comments