Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: promptpay method descriptions #5

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading