Skip to content

Commit

Permalink
fix: promptpay method descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwenty228 committed Oct 3, 2023
1 parent 3269efd commit c33aef8
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions utils/promptpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

class PromptPay:
def __init__(self, phone_number):
self._phone_number = phone_number
self._phone_number = phone_number # unsanitized phonenumber

@property
def phone_number(self):
return re.sub(r'\D', '', self._phone_number)
return re.sub(r'\D', '', self._phone_number)


@property
Expand Down Expand Up @@ -125,18 +125,53 @@ def to_byte_QR(cls, phone_number: str, amount: float = 0) -> io.BytesIO:

@classmethod
def to_QR(cls, phone_number: str, path: str, amount: float = 0) -> None:
"""save QR code to path"""
"""Save QR code to path
Parameters
----------
phone_number : str
phone number
path : str
filename
amount : float, optional
amount, by default 0
Returns
None
"""
cls(phone_number).__to_QR(path, amount)

@staticmethod
def token2QR(token: str, path: str) -> None:
"""save QR code to path"""
"""Save QR code to path
Parameters
----------
token : str
promptpay payload
path : str
filename
Returns
None
"""
file = qrcode.make(token)
file.save(path)

@staticmethod
def token2byte_QR(token: str) -> io.BytesIO:
"""return QR code as byte"""
"""Generate QR code as byte from phone number and amount
Parameters
----------
token : str
promptpay payload
Returns
-------
io.BytesIO
QR code as byte
"""
file = qrcode.make(token)
byte_io = io.BytesIO()
file.save(byte_io)
Expand Down

0 comments on commit c33aef8

Please sign in to comment.