Skip to content

Commit

Permalink
twowaysms-get-balance
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalebu committed Apr 26, 2021
1 parent 866bb04 commit 45ead25
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions BeemAfrica/Bpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@
import requests
from BeemAfrica import secured, get_header

BPAY_BALANCE_URL = 'https://apitopup.beem.africa/v1/credit-balance?app_name={}'


class Bpay(object):
def __init__(self) -> None:
super().__init__()

@secured
def get_balance(self, app_name='USSD'):
try:
return requests.get(
BPAY_BALANCE_URL.format(app_name),
headers=get_header()
).json()

except (requests.ConnectionError, requests.ConnectTimeout):
raise ConnectionError(
'Connection to the USSD Get balance API Refused, Please check your internet connections')


sys.modules[__name__] = Bpay()
14 changes: 14 additions & 0 deletions BeemAfrica/TwowaySMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@
import requests
from BeemAfrica import secured, get_header

TWOWAYSMS_BALANCE_URL = 'https://www.blsmsgw.com/portal/api/userAccountBalance'


class TwowaySMS(object):
def __init__(self) -> None:
super().__init__()

@secured
def get_balance(self):
try:
return requests.get(
TWOWAYSMS_BALANCE_URL,
headers=get_header()
).json()

except (requests.ConnectionError, requests.ConnectTimeout):
raise ConnectionError(
'Connection to the USSD Get balance API Refused, Please check your internet connections')


sys.modules[__name__] = TwowaySMS()

0 comments on commit 45ead25

Please sign in to comment.