77
88
99class 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
1921class 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