mirror of
				https://github.com/Eledio/superfaktura-client.git
				synced 2025-10-31 08:22:32 +01:00 
			
		
		
		
	fixes after rebase
This commit is contained in:
		| @@ -1,6 +1,32 @@ | ||||
| """ | ||||
| Data Format Enumeration. | ||||
|  | ||||
| This module provides an enumeration of data formats that can be used in the SuperFaktura API. | ||||
|  | ||||
| Classes: | ||||
|     - DataFormat: Enumeration of data formats. | ||||
|  | ||||
| Usage: | ||||
|     from superfaktura.enumerations.data_format import DataFormat | ||||
|     data_format = DataFormat.JSON | ||||
| """ | ||||
|  | ||||
| import enum | ||||
|  | ||||
|  | ||||
| class DataFormat(enum.Enum): | ||||
|     """ | ||||
|     Data Format Enumeration. | ||||
|  | ||||
|     This enumeration represents the different data formats that can be used in the SuperFaktura API. | ||||
|  | ||||
|     Values: | ||||
|         - JSON: JSON format | ||||
|         - PDF: PDF format | ||||
|  | ||||
|     Usage: | ||||
|         data_format = DataFormat.JSON | ||||
|     """ | ||||
|  | ||||
|     JSON = enum.auto() | ||||
|     PDF = enum.auto() | ||||
|   | ||||
| @@ -1,4 +1,43 @@ | ||||
| """ | ||||
| Language Enumeration. | ||||
|  | ||||
| This module provides an enumeration of languages that can be used in the SuperFaktura API. | ||||
|  | ||||
| Classes: | ||||
|     - Language: Enumeration of languages. | ||||
|  | ||||
| Usage: | ||||
|     from superfaktura.enumerations.language import Language | ||||
|     language = Language.Czech | ||||
| """ | ||||
|  | ||||
|  | ||||
| class Language: | ||||
|     """ | ||||
|     Language Enumeration. | ||||
|  | ||||
|     This enumeration represents the different languages that can be used in the SuperFaktura API. | ||||
|  | ||||
|     Values: | ||||
|         - Czech: Czech | ||||
|         - German: German | ||||
|         - English: English | ||||
|         - Croatian: Croatian | ||||
|         - Hungarian: Hungarian | ||||
|         - Italian: Italian | ||||
|         - Dutch: Dutch | ||||
|         - Polish: Polish | ||||
|         - Romanian: Romanian | ||||
|         - Russian: Russian | ||||
|         - Slovak: Slovak | ||||
|         - Slovene: Slovene | ||||
|         - Spanish: Spanish | ||||
|         - Ukrainian: Ukrainian | ||||
|  | ||||
|     Usage: | ||||
|         language = Language.Czech | ||||
|     """ | ||||
|  | ||||
|     Czech = "cze" | ||||
|     German = "deu" | ||||
|     English = "eng" | ||||
|   | ||||
| @@ -52,6 +52,7 @@ Usage: | ||||
|     ) | ||||
| """ | ||||
|  | ||||
| import tempfile | ||||
| from dataclasses import dataclass, asdict | ||||
| from typing import Optional, List, IO | ||||
| import json | ||||
| @@ -152,6 +153,16 @@ class InvoiceItem: | ||||
|  | ||||
| @dataclass | ||||
| class InvoiceRespModel: | ||||
|     """ | ||||
|     This dataclass represents the response model for an invoice in the SuperFaktura API. | ||||
|  | ||||
|     Attributes: | ||||
|         - error (int): The error code. | ||||
|         - error_message (str): The error message. | ||||
|         - invoice_id (Optional[int]): The ID of the invoice. | ||||
|         - invoice_token (Optional[str]): The token of | ||||
|     """ | ||||
|  | ||||
|     error: int | ||||
|     error_message: str | ||||
|     invoice_id: Optional[int] = None | ||||
| @@ -159,7 +170,7 @@ class InvoiceRespModel: | ||||
|  | ||||
|  | ||||
| class InvoiceType: | ||||
|     """ " | ||||
|     """ | ||||
|     Invoice Type Enumeration. | ||||
|  | ||||
|     This enumeration represents the different types of invoices that can be created. | ||||
| @@ -228,12 +239,15 @@ class Invoice(SuperFakturaAPI): | ||||
|         Adds a new invoice. | ||||
|  | ||||
|         Args: | ||||
|             invoice (InvoiceModel): The invoice model. | ||||
|             invoice_model (InvoiceModel): The invoice model. | ||||
|             items (List[InvoiceItem]): List of invoice items. | ||||
|             contact (ClientContactModel): The client contact model. | ||||
|  | ||||
|         Returns: | ||||
|             InvoiceRespModel: The response model for the invoice. | ||||
|             :param contact: | ||||
|             :param items: | ||||
|             :param invoice_model: | ||||
|         """ | ||||
|         data = { | ||||
|             "Invoice": invoice_model.as_dict(), | ||||
| @@ -278,8 +292,8 @@ if __name__ == "__main__": | ||||
|     resp = invoice.add( | ||||
|         invoice_model=InvoiceModel( | ||||
|             type=InvoiceType.PROFORMA, | ||||
|             name="Invoice 5", | ||||
|             due=Date("2025-02-01"), | ||||
|             name="Invoice 8", | ||||
|             due=Date("2025-04-01"), | ||||
|             invoice_currency=Currencies.CZK, | ||||
|             header_comment="We invoice you for services", | ||||
|             bank_accounts=[bank.default().as_dict()], | ||||
|   | ||||
| @@ -39,7 +39,6 @@ class SuperFakturaAPIException(Exception): | ||||
|     """Exception for errors when working with the SuperFaktura API.""" | ||||
|  | ||||
|  | ||||
|  | ||||
| class SuperFakturaAPIMissingCredentialsException(Exception): | ||||
|     """Exception for missing login credentials.""" | ||||
|  | ||||
| @@ -65,7 +64,9 @@ class SuperFakturaAPI: | ||||
|             f"{_api_company_id}" | ||||
|         } | ||||
|  | ||||
|     def get(self, endpoint: str, data_format: DataFormat = DataFormat.JSON, timeout: int = 5) -> Dict: | ||||
|     def get( | ||||
|         self, endpoint: str, data_format: DataFormat = DataFormat.JSON, timeout: int = 5 | ||||
|     ) -> Dict: | ||||
|         """ | ||||
|         Retrieves data from the SuperFaktura API. | ||||
|  | ||||
| @@ -97,10 +98,11 @@ class SuperFakturaAPI: | ||||
|                 return req.json() | ||||
|             elif data_format == DataFormat.PDF: | ||||
|                 return {"pdf": req.content}  # returns a dict with the PDF content | ||||
|         else: | ||||
| 	        raise SuperFakturaAPIException( | ||||
| 	            f"Get status code: {req.status_code}; {req.json()}" | ||||
| 	        ) | ||||
|             else: | ||||
|                 raise SuperFakturaAPIException("Invalid data format") | ||||
|         raise SuperFakturaAPIException( | ||||
|             f"Get status code: {req.status_code}; {req.json()}" | ||||
|         ) | ||||
|  | ||||
|     def post(self, endpoint: str, data: str, timeout: int = 5) -> Dict: | ||||
|         """ | ||||
| @@ -137,7 +139,6 @@ class SuperFakturaAPI: | ||||
|         ) | ||||
|         if req.status_code == 200: | ||||
|             return req.json() | ||||
|         else: | ||||
|             raise SuperFakturaAPIException( | ||||
|                 f"Post status code: {req.status_code}; {req.json()}" | ||||
|             ) | ||||
|         raise SuperFakturaAPIException( | ||||
|             f"Post status code: {req.status_code}; {req.json()}" | ||||
|         ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user