From d0eed823f44575a13617ca8e1698cbac5f65b853 Mon Sep 17 00:00:00 2001 From: ms lev Date: Wed, 1 Dec 2021 22:04:55 +0500 Subject: [PATCH] added docstrings --- python_qiwi/python_qiwi.py | 57 +++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/python_qiwi/python_qiwi.py b/python_qiwi/python_qiwi.py index b603181..67a6f19 100644 --- a/python_qiwi/python_qiwi.py +++ b/python_qiwi/python_qiwi.py @@ -8,11 +8,30 @@ import string class QiwiWаllet(): def __init__(self, phone, api_token): + """init + + Args: + phone (str): wallet phone number + api_token (str): qiwi.com/api token + """ + self.s = requests.Session() self.s.headers['authorization'] = 'Bearer ' + api_token self.phone = phone - def pay(self, to_qw, sum_p2p, comment='', currency=643): + def pay(self, to_qw: str, sum_p2p: int, comment='', currency=643): + """pay + + Args: + to_qw (str): wallet number for transfer + sum_p2p (int): transfer amount in int format + comment (str, optional): payment comment. Defaults to ''. + currency (int, optional): currency code (by default - ruble). Defaults to 643. + + Returns: + json: information about the success of the translation + """ + sum_p2p = str(int(sum_p2p)) + '.00' self.s.headers = { 'content-type': 'application/json', @@ -31,6 +50,15 @@ class QiwiWаllet(): return res.json() def payment_history(self, rows_num=5): + """payment_history + + Args: + rows_num (int, optional): the number of payments you want to receive. Defaults to 5. + + Returns: + json: payment_history + """ + parameters = {'rows': str( rows_num), 'nextTxnId': '', 'nextTxnDate': ''} h = self.s.get('https://edge.qiwi.com/payment-history/v2/persons/' + @@ -42,6 +70,15 @@ class QiwiWаllet(): return ''.join(random.choice(letters) for i in range(12)) def check(self, comment): + """check_payment + + Args: + comment (str): desthis is a special combination of characters specified during translationcription + + Returns: + bool: was the payment found + """ + lastPayments = self.payment_history(40) for payment in lastPayments: qcomment = payment['comment'] @@ -50,6 +87,11 @@ class QiwiWаllet(): return False def full_balance(self): + """get full balance + + Returns: + json: complete information about your accounts + """ self.s.headers['Accept'] = 'application/json' @@ -59,6 +101,11 @@ class QiwiWаllet(): return b.json() def balance(self): + """get balance + + Returns: + json: balance of your first account + """ self.s.headers['Accept'] = 'application/json' b = self.s.get( @@ -77,6 +124,14 @@ class QiwiWаllet(): return p.json() def get_payment(self, comment): + """get payment + + Args: + comment (str): special combination of characters + + Returns: + json: payment info + """ lastPayments = self.payment_history(30) for payment in lastPayments: qcomment = payment['comment']