Skip to content

Commit

Permalink
🏷️ Add type hints to sbp_qr module (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteApfel committed Oct 22, 2021
1 parent ab9bf98 commit 5b16202
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions raiffather/modules/sbp_qr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typing import Union

from raiffather.exceptions.base import RaifErrorResponse
from raiffather.models.products import Account
from raiffather.models.sbp_qr import SbpQRData, SbpQRInit, SbpQrInfo
from raiffather.modules.base import RaiffatherBase

Expand All @@ -13,7 +16,7 @@ async def sbp_qr_pay_prepare(self):
return True
raise RaifErrorResponse(r)

async def sbp_qr_pay_init(self, amount, src, qr_data: SbpQRData):
async def sbp_qr_pay_init(self, amount: Union[float, int], src: Account, qr_data: SbpQRData):
data = {
"amount": float(amount),
"bankId": qr_data.bank_id,
Expand All @@ -33,7 +36,7 @@ async def sbp_qr_pay_init(self, amount, src, qr_data: SbpQRData):
return SbpQRInit(**r.json())
raise RaifErrorResponse(r)

async def sbp_qr_send_push(self, request_id) -> str:
async def sbp_qr_send_push(self, request_id: Union[str, int]) -> str:
"""
Отправляет пуш-уведомление для подтверждение и ждёт, когда пуш-сервер его получит
Expand All @@ -53,7 +56,7 @@ async def sbp_qr_send_push(self, request_id) -> str:
return otp
raise RaifErrorResponse(send_code_response)

async def sbp_qr_push_verify(self, request_id, code) -> bool:
async def sbp_qr_push_verify(self, request_id: Union[str, int], code: Union[str, int]) -> bool:
"""
Проверяет код подтверждения
Expand All @@ -64,13 +67,13 @@ async def sbp_qr_push_verify(self, request_id, code) -> bool:
verify_response = await self._client.put(
f"https://amobile.raiffeisen.ru/dailybanking/ro/v1.0/c2b/process/transfer/{request_id}/push",
headers=await self.authorized_headers,
json={"code": code},
json={"code": str(code)},
)
if verify_response.status_code == 204:
return True
raise RaifErrorResponse(verify_response)

async def sbp_qr_decode_url(self, url):
async def sbp_qr_decode_url(self, url: str):
data = {"scanCodeType": 3, "scanString": url}
r = await self._client.post(
"https://amobile.raiffeisen.ru/rest/1/qr",
Expand Down

0 comments on commit 5b16202

Please sign in to comment.