Skip to content

Commit da0d9c2

Browse files
committed
Add sphinx docs and part of comments
1 parent d935066 commit da0d9c2

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
description='Python wrapper for Simpay API',
99
author='Rafał Więcek <kontakt@simpay.pl>',
1010
url='https://github.com/SimPaypl/SimPay-API-Python',
11-
python_requires=">3.0",
12-
packages=find_packages(exclude=["tests*", "examples*"]),
13-
test_suite="tests",
11+
python_requires='>3.0',
12+
packages=find_packages(exclude=['tests*', 'examples*']),
13+
test_suite='tests',
1414
include_package_data=True,
15-
install_requires=['requests'],
15+
install_requires=['requests>=2.26.0', 'pydantic>=1.10.7'],
16+
extras_require={'docs': ['sphinx>=7.0.1']},
1617
)

simpay/simpay.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88

99
class ClientException(Exception):
10+
"""Base exception of client requests"""
11+
1012
def __init__(self, code=200, message=None, details=None):
1113
self.code = code
1214
self.message = message
@@ -17,6 +19,8 @@ def __str__(self):
1719

1820

1921
class Client(object):
22+
"""Base client of SimPay"""
23+
2024
_version = VERSION
2125
_user_agent = 'simpay-python-api'
2226
_base_endpoint = 'https://api.simpay.pl/'
@@ -27,6 +31,15 @@ def __init__(
2731
api_password: str | None,
2832
timeout: int = 5
2933
) -> None:
34+
"""Base client of SimPay
35+
36+
:param api_key: str
37+
API key from account details
38+
:param api_password: str
39+
API password from account details
40+
:param timeout: int
41+
Timeout of HTTP request, default its 5 seconds
42+
"""
3043
self.api_key = api_key
3144
self.api_password = api_password
3245
self.timeout = timeout
@@ -42,11 +55,35 @@ def __init__(
4255
if self.api_password is not None:
4356
self._http_client.headers['X-SIM-PASSWORD'] = self.api_password
4457

58+
"""Instance of API interface SMS methods
59+
60+
:type: :class:`SMSClient <simpay.sms.client.SMSClient>`
61+
"""
4562
self.SMS: SMSClient = SMSClient(self)
63+
"""Instance of API interface SMS XML methods
64+
65+
:type: :class:`SMSXMLClient <simpay.sms_xml.client.SMSXMLClient>`
66+
"""
4667
self.SMS_XML: SMSXMLClient = SMSXMLClient(self)
68+
"""Instance of API interface DirectBilling methods
69+
70+
:type: :class:`DirectBillingClient <simpay.directbilling.client.DirectBillingClient>`
71+
"""
4772
self.DirectBilling: DirectBillingClient = DirectBillingClient(self)
4873

4974
def request(self, method: RequestMethod, uri: str, fields: dict[str, any] | None = None, headers: dict[str, any] | None = None, options: dict[str, any] | None = None) -> Response:
75+
"""Base client of SimPay
76+
77+
:param method: RequestMethod
78+
HTTP request method (GET, POST, ...)
79+
:param api_password: str
80+
API password from account details
81+
:param timeout: int
82+
Timeout of HTTP request, default its 5 seconds
83+
84+
:return Response body
85+
:rtype dict
86+
"""
5087
response = self._http_client.request(
5188
method.value, self._base_endpoint + uri, params=options, json=fields, headers=headers)
5289
if len(response.content) == 0:

0 commit comments

Comments
 (0)