options
This commit is contained in:
		
							parent
							
								
									c7cd2fbbca
								
							
						
					
					
						commit
						4b11b32cbc
					
				| @ -7,9 +7,9 @@ class MultiDownloaderClient | |||||||
|     private string $apiUrl = 'https://multi-dl.kub.nwb.fr'; |     private string $apiUrl = 'https://multi-dl.kub.nwb.fr'; | ||||||
|     private string $apiKey; |     private string $apiKey; | ||||||
| 
 | 
 | ||||||
|     public function __construct(string $apiKey = null) |     public function __construct(array $options = []) | ||||||
|     { |     { | ||||||
|         $apiKey = $apiKey ?? getenv('MULTI_DOWNLOADER_API_KEY'); |         $apiKey = $options['apiKey'] ?? getenv('MULTI_DOWNLOADER_API_KEY'); | ||||||
| 
 | 
 | ||||||
|         if (!$apiKey) { |         if (!$apiKey) { | ||||||
|             throw new \InvalidArgumentException('API key is required'); |             throw new \InvalidArgumentException('API key is required'); | ||||||
|  | |||||||
| @ -63,7 +63,9 @@ class MultiDownloaderClientTest extends TestCase | |||||||
| 
 | 
 | ||||||
|     public function testApiKeyParam() |     public function testApiKeyParam() | ||||||
|     { |     { | ||||||
|         $client = new MultiDownloaderClient('test_key'); |         $client = new MultiDownloaderClient([ | ||||||
|  |             'apiKey' => 'test_key' | ||||||
|  |         ]); | ||||||
| 
 | 
 | ||||||
|         $apiKey = self::getProperty($client, 'apiKey'); |         $apiKey = self::getProperty($client, 'apiKey'); | ||||||
|         $this->assertEquals('test_key', $apiKey); |         $this->assertEquals('test_key', $apiKey); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user