examples: add examples to the docs

This commit is contained in:
Richard Kubíček
2025-02-28 19:17:41 +01:00
parent fa3d2ddf32
commit a20ae3fad0
4 changed files with 32 additions and 3 deletions

19
docs/source/examples.rst Normal file
View 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:

View File

@@ -6,3 +6,4 @@ Welcome to SuperFaktura Client's documentation
superfaktura
installation
examples

View File

@@ -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()

View File

@@ -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)