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 |    superfaktura | ||||||
|    installation |    installation | ||||||
|  |    examples | ||||||
|   | |||||||
| @@ -36,7 +36,10 @@ from superfaktura.invoice import ( | |||||||
| from superfaktura.utils.data_types import Date | 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() |     invoice = Invoice() | ||||||
|     bank = BankAccount() |     bank = BankAccount() | ||||||
|     resp = invoice.add( |     resp = invoice.add( | ||||||
| @@ -70,3 +73,7 @@ if __name__ == "__main__": | |||||||
|     _pdf = invoice.get_pdf(invoice=resp, language=Language.English) |     _pdf = invoice.get_pdf(invoice=resp, language=Language.English) | ||||||
|  |  | ||||||
|     save_file_as_pdf(_pdf, "invoice.pdf") |     save_file_as_pdf(_pdf, "invoice.pdf") | ||||||
|  |  | ||||||
|  |  | ||||||
|  | if __name__ == "__main__": | ||||||
|  |     main() | ||||||
|   | |||||||
| @@ -2,6 +2,8 @@ | |||||||
| This module contains tools for working with these examples. | 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: | 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: |     :param output_path: | ||||||
|     :return: |     :return: | ||||||
|     """ |     """ | ||||||
|     with open(output_path, "wb") as f: |     p = Path(output_path) | ||||||
|         f.write(input_data) |     p.write_bytes(input_data) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user