Skip to content

Commit

Permalink
Add documentation with sphinx (#4)
Browse files Browse the repository at this point in the history
Resolves #3
  • Loading branch information
gmargaritis authored Feb 2, 2024
1 parent eb0d610 commit 18a302d
Show file tree
Hide file tree
Showing 11 changed files with 705 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__/
*.py[cod]
*.env
.DS_Store
docs/build/
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
31 changes: 31 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "ergani-python-sdk"
copyright = "MIT"
author = "George Margaritis <[email protected]>"
release = "1.0.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
]

templates_path = ["_templates"]
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "furo"
html_static_path = ["_static"]
39 changes: 39 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.. ergani-python-sdk documentation master file, created by
sphinx-quickstart on Fri Feb 2 13:07:54 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to ergani-python-sdk's documentation!
=============================================

.. toctree::
:maxdepth: 2
:caption: Contents:

ergani.client
--------------------

.. automodule:: ergani.client
:members:
:show-inheritance:

ergani.exceptions
------------------------

.. automodule:: ergani.exceptions
:members:
:show-inheritance:

ergani.models
--------------------

.. automodule:: ergani.models
:members:
:show-inheritance:

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
2 changes: 1 addition & 1 deletion ergani/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class ErganiAuthentication(AuthBase):
"""
Authentication handler for the Ergani API.
Authentication handler for the Ergani API
"""

def __init__(
Expand Down
51 changes: 50 additions & 1 deletion ergani/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@


class ErganiClient:
"""
A client for interacting with the Ergani API
Args:
username str: The username for authentication with Ergani
password str: The password for authentication with Ergani
base_url str: The base URL of the Ergani API. Defaults to "https://trialeservices.yeka.gr/WebServicesAPI/api".
"""

def __init__(
self,
username: str,
Expand Down Expand Up @@ -61,7 +70,17 @@ def submit_work_card(
self, company_work_cards: List[CompanyWorkCard]
) -> Optional[Response]:
"""
Submits work cards records (check-in, check-out) for employees to the Ergani API
Submits work card records (check-in, check-out) for employees to the Ergani API
Args:
company_work_cards List[CompanyWorkCard]: A list of CompanyWorkCard instances to be submitted
Returns:
An optional Response object from the Ergani API
Raises:
APIError: An error occurred while communicating with the Ergani API
AuthenticationError: Raised if there is an authentication error with the Ergani API
"""

endpoint = "/Documents/WRKCardSE"
Expand All @@ -83,6 +102,16 @@ def submit_overtime(
) -> Optional[Response]:
"""
Submits overtime records for employees to the Ergani API
Args:
company_overtimes List[CompanyOvertime]: A list of CompanyOvertime instances to be submitted
Returns:
An optional Response object from the Ergani API
Raises:
APIError: An error occurred while communicating with the Ergani API
AuthenticationError: Raised if there is an authentication error with the Ergani API
"""

endpoint = "/Documents/OvTime"
Expand All @@ -105,6 +134,16 @@ def submit_daily_schedule(
) -> Optional[Response]:
"""
Submits schedule records that are updated on a daily basis for employees to the Ergani API
Args:
company_daily_schedules List[CompanyDailySchedule]: A list of CompanyDailySchedule instances to be submitted
Returns:
An optional Response object from the Ergani API
Raises:
APIError: An error occurred while communicating with the Ergani API
AuthenticationError: Raised if there is an authentication error with the Ergani API
"""

endpoint = "/Documents/WTODaily"
Expand All @@ -124,6 +163,16 @@ def submit_weekly_schedule(
) -> Optional[Response]:
"""
Submits weekly schedule records for employees to the Ergani API
Args:
company_weekly_schedules List[CompanyWeeklySchedule]: A list of CompanyWeeklySchedule instances to be submitted
Returns:
An optional Response object from the Ergani API
Raises:
APIError: An error occurred while communicating with the Ergani API
AuthenticationError: Raised if there is an authentication error with the Ergani API
"""

endpoint = "/Documents/WTOWeek"
Expand Down
6 changes: 3 additions & 3 deletions ergani/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Error(Exception):
"""
Base class for all API errors.
Base class for all API errors
"""

def __init__(
Expand Down Expand Up @@ -33,15 +33,15 @@ def __str__(self) -> str:

class AuthenticationError(Error):
"""
Raised when an API request fails due to an authentication error.
Raised when an API request fails due to an authentication error
"""

pass


class APIError(Error):
"""
Raised when an API request fails due to an unknown error.
Raised when an API request fails due to an unknown error
"""

pass
Loading

0 comments on commit 18a302d

Please sign in to comment.