mirror of
				https://github.com/Eledio/superfaktura-client.git
				synced 2025-10-31 08:22:32 +01:00 
			
		
		
		
	examples: add examples to the docs
This commit is contained in:
		
							
								
								
									
										19
									
								
								docs/source/examples.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								docs/source/examples.rst
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| Examples of SuperFaktura API client usage | ||||
| ==================== | ||||
|  | ||||
|  | ||||
| Add Invoice | ||||
| --------------------------------- | ||||
|  | ||||
| .. automodule:: examples.add_invoice | ||||
|    :members: | ||||
|    :undoc-members: | ||||
|    :show-inheritance: | ||||
|  | ||||
| Get country list | ||||
| ------------------------------------ | ||||
|  | ||||
| .. automodule:: examples.get_country_list | ||||
|    :members: | ||||
|    :undoc-members: | ||||
|    :show-inheritance: | ||||
| @@ -6,3 +6,4 @@ Welcome to SuperFaktura Client's documentation | ||||
|  | ||||
|    superfaktura | ||||
|    installation | ||||
|    examples | ||||
|   | ||||
| @@ -36,7 +36,10 @@ from superfaktura.invoice import ( | ||||
| from superfaktura.utils.data_types import Date | ||||
|  | ||||
|  | ||||
| if __name__ == "__main__": | ||||
| def main(): | ||||
|     """ | ||||
|     Main function to add Invoice and save it as a pdf using the SuperFaktura API. | ||||
|     """ | ||||
|     invoice = Invoice() | ||||
|     bank = BankAccount() | ||||
|     resp = invoice.add( | ||||
| @@ -70,3 +73,7 @@ if __name__ == "__main__": | ||||
|     _pdf = invoice.get_pdf(invoice=resp, language=Language.English) | ||||
|  | ||||
|     save_file_as_pdf(_pdf, "invoice.pdf") | ||||
|  | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     main() | ||||
|   | ||||
| @@ -2,6 +2,8 @@ | ||||
| This module contains tools for working with these examples. | ||||
| """ | ||||
|  | ||||
| from pathlib import Path | ||||
|  | ||||
|  | ||||
| def save_file_as_pdf(input_data: bytes, output_path: str = "output.pdf") -> None: | ||||
|     """ | ||||
| @@ -10,5 +12,5 @@ def save_file_as_pdf(input_data: bytes, output_path: str = "output.pdf") -> None | ||||
|     :param output_path: | ||||
|     :return: | ||||
|     """ | ||||
|     with open(output_path, "wb") as f: | ||||
|         f.write(input_data) | ||||
|     p = Path(output_path) | ||||
|     p.write_bytes(input_data) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user