mirror of
				https://github.com/Eledio/superfaktura-client.git
				synced 2025-10-31 16:11:20 +01:00 
			
		
		
		
	superfaktura_api: raise exception when some credentials are not set
This commit is contained in:
		
							
								
								
									
										2
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								setup.py
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages | |||||||
|  |  | ||||||
| setup( | setup( | ||||||
|     name='superfaktura_client', |     name='superfaktura_client', | ||||||
|     version='0.0.1', |     version='0.0.2', | ||||||
|     packages=find_namespace_packages(), |     packages=find_namespace_packages(), | ||||||
|     url='https://github.com/eledio-helpers/superfaktura-client', |     url='https://github.com/eledio-helpers/superfaktura-client', | ||||||
|     license='', |     license='', | ||||||
|   | |||||||
| @@ -8,6 +8,9 @@ from dotenv import load_dotenv  # type: ignore | |||||||
| class SuperFakturaAPIException(Exception): | class SuperFakturaAPIException(Exception): | ||||||
|     pass |     pass | ||||||
|  |  | ||||||
|  | class SuperFakturaAPIMissingCredentialsException(Exception): | ||||||
|  |     pass | ||||||
|  |  | ||||||
|  |  | ||||||
| class SuperFakturaAPI: | class SuperFakturaAPI: | ||||||
|     def __init__(self) -> None: |     def __init__(self) -> None: | ||||||
| @@ -16,6 +19,9 @@ class SuperFakturaAPI: | |||||||
|         self._api_url = os.getenv("SUPERFAKTURA_API_URL") |         self._api_url = os.getenv("SUPERFAKTURA_API_URL") | ||||||
|         _api_mail = os.getenv("SUPERFAKTURA_API_EMAIL") |         _api_mail = os.getenv("SUPERFAKTURA_API_EMAIL") | ||||||
|         _api_company_id = os.getenv("SUPERFAKTURA_API_COMPANY_ID") |         _api_company_id = os.getenv("SUPERFAKTURA_API_COMPANY_ID") | ||||||
|  |         if not _api_key or not self._api_url or not _api_mail or not _api_company_id: | ||||||
|  |             raise SuperFakturaAPIMissingCredentialsException('Please ensure, that necessary credentials are set. Please see README.md') | ||||||
|  |  | ||||||
|         self._auth_header = { |         self._auth_header = { | ||||||
|             "Authorization": f"SFAPI email={_api_mail}&apikey={_api_key}&company_id={_api_company_id}" |             "Authorization": f"SFAPI email={_api_mail}&apikey={_api_key}&company_id={_api_company_id}" | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user