mirror of
https://github.com/yawaflua/python-qiwi.git
synced 2025-12-09 20:09:27 +02:00
added docstrings
This commit is contained in:
@@ -8,11 +8,30 @@ import string
|
|||||||
class QiwiWаllet():
|
class QiwiWаllet():
|
||||||
|
|
||||||
def __init__(self, phone, api_token):
|
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 = requests.Session()
|
||||||
self.s.headers['authorization'] = 'Bearer ' + api_token
|
self.s.headers['authorization'] = 'Bearer ' + api_token
|
||||||
self.phone = phone
|
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'
|
sum_p2p = str(int(sum_p2p)) + '.00'
|
||||||
self.s.headers = {
|
self.s.headers = {
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
@@ -31,6 +50,15 @@ class QiwiWаllet():
|
|||||||
return res.json()
|
return res.json()
|
||||||
|
|
||||||
def payment_history(self, rows_num=5):
|
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(
|
parameters = {'rows': str(
|
||||||
rows_num), 'nextTxnId': '', 'nextTxnDate': ''}
|
rows_num), 'nextTxnId': '', 'nextTxnDate': ''}
|
||||||
h = self.s.get('https://edge.qiwi.com/payment-history/v2/persons/' +
|
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))
|
return ''.join(random.choice(letters) for i in range(12))
|
||||||
|
|
||||||
def check(self, comment):
|
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)
|
lastPayments = self.payment_history(40)
|
||||||
for payment in lastPayments:
|
for payment in lastPayments:
|
||||||
qcomment = payment['comment']
|
qcomment = payment['comment']
|
||||||
@@ -50,6 +87,11 @@ class QiwiWаllet():
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def full_balance(self):
|
def full_balance(self):
|
||||||
|
"""get full balance
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
json: complete information about your accounts
|
||||||
|
"""
|
||||||
|
|
||||||
self.s.headers['Accept'] = 'application/json'
|
self.s.headers['Accept'] = 'application/json'
|
||||||
|
|
||||||
@@ -59,6 +101,11 @@ class QiwiWаllet():
|
|||||||
return b.json()
|
return b.json()
|
||||||
|
|
||||||
def balance(self):
|
def balance(self):
|
||||||
|
"""get balance
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
json: balance of your first account
|
||||||
|
"""
|
||||||
self.s.headers['Accept'] = 'application/json'
|
self.s.headers['Accept'] = 'application/json'
|
||||||
|
|
||||||
b = self.s.get(
|
b = self.s.get(
|
||||||
@@ -77,6 +124,14 @@ class QiwiWаllet():
|
|||||||
return p.json()
|
return p.json()
|
||||||
|
|
||||||
def get_payment(self, comment):
|
def get_payment(self, comment):
|
||||||
|
"""get payment
|
||||||
|
|
||||||
|
Args:
|
||||||
|
comment (str): special combination of characters
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
json: payment info
|
||||||
|
"""
|
||||||
lastPayments = self.payment_history(30)
|
lastPayments = self.payment_history(30)
|
||||||
for payment in lastPayments:
|
for payment in lastPayments:
|
||||||
qcomment = payment['comment']
|
qcomment = payment['comment']
|
||||||
|
|||||||
Reference in New Issue
Block a user