# get_tests.py # @author: Donald Chinhuru # @created: 09 Dec 2019 # @updated: Mar 2021 import hotrecharge import pprint # use config helper class config = hotrecharge.HRAuthConfig( access_code='', access_password='', reference='' ) api = hotrecharge.HotRecharge(config=config) try: # get wallet balance wallet_bal_response = api.walletBalance() # get data bundles data_bundles_resp = api.getDataBundles() print("Wallet Balance: ") pprint.pprint(wallet_bal_response) print("Data Bundles Balance: ") pprint.pprint(data_bundles_resp) except Exception as ex:
# recharge_databundle.py # @author: Donald Chinhuru # @created: 09 Dec 2019 # @updated: 09 Mar 2020 import hotrecharge from pprint import pprint credentials = { 'code': '<your-code>', 'pswd': '<your-password', 'ref': '<agent-reference>' } api = hotrecharge.HotRecharge(headers=credentials) try: # to see other product-codes and more info, use api.getDataBundles() response = api.dataBundleRecharge(product_code="DWB15", number="077xxxxxxx") pprint(response) except Exception as ex: print(f"There was a problem: {ex}")
import hotrecharge # create config class config = hotrecharge.HRAuthConfig( access_code="acc-email", access_password="******", reference="random-ref", # (optional) ) # pass config object to api constructor # flag return_model -> True in order to return model, (Munch object) api = hotrecharge.HotRecharge(config, return_model=True) wb_model = api.walletBalance() # if all goes well, this will return a model (see method DocStrings) # and we can now access data via model attributes like working with classes balance = wb_model.WalletBalance print("Wallet Balance is: $", balance)
# @created: 09 Dec 2019 # @updated: 09 Dec 2019 import hotrecharge import pprint # TODO:: Add Config module # change dict values only credentials = { 'code': '<your-code>', 'pswd': '<your-password', 'ref': '<agent-reference>' } # to use random code generated references, flag it to True, True by default, <<reccommended>> api = hotrecharge.HotRecharge(headers=credentials, use_random_ref=True) try: # get wallet balance wallet_bal_response = api.walletBalance() # get end user balance end_user_bal_resp = api.endUserBalance('077xxxxxxx') # get data bundles data_bundles_resp = api.getDataBundles() print("Wallet Balance: ") pprint.pprint(wallet_bal_response) print("End User Balance: ")