def init_transfer(request): """Initializes transfer to the given account.""" if not is_authenticated(request): return JsonResponse({"user": "******", "status": "failed"}) if request.user.is_authenticated: user = request.user else: user = extract_user(request) try: token = 100000 # randint(100000, 999999) body = { "to": f"+{request.POST['phone'] or user.profile.phone}", "from": "Ebank Transfer", "message": f"Use {token} as token to complete the transaction." } print(Sms(HEADER).SendSms(body)) TempTransfer.objects.create(user=user, amount=request.POST['amount'], account=request.POST['account'], token=token) return JsonResponse({"initialized": True}) except (MultiValueDictKeyError, AttributeError, ConnectionError): return JsonResponse({"invalid_details": True, "status": "failed"}) return JsonResponse({"message": "Unkonwn error", "status": "failed"})
from atlabs.sms import Sms header = { "base_url": "https://sandboxapi.fsi.ng", "Sandbox-Key": "your-sandbox-key-here", "Content-Type": "application/json" } body = {"to": "+2348123456789", "from": "FSI", "message": "Hello world!"} result = Sms(header).SendMessage(body) print(result)
from atlabs.sms import Sms header = { "base_url": "https://sandboxapi.fsi.ng", "Sandbox-Key": "your-sandbox-key-here", "Content-Type": "application/json" } body = { "lastReceivedId": "0" } result = Sms(header).FetchMessage(body) print(result)
def test_send_premium_message(mock_post): data = responses['SendPremiumMessage'] mock_post.return_value = R(data) assert Sms(header).SendPremiumMessage( body["SendPremiumMessage"]) == data, "should return an object"
def test_fetch_premium_subscription(mock_post): data = responses['FetchPremiumSubscription'] mock_post.return_value = R(data) assert Sms(header).FetchPremiumSubscription( body["FetchPremiumSubscription"]) == data, "should return an object"
def test_fetch_message(mock_post): data = responses['FetchMessage'] mock_post.return_value = R(data) assert Sms(header).FetchMessage( body["FetchMessage"]) == data, "should return an object"
def test_delete_premium_subscription(mock_post): data = responses['DeletePremiumSubscription'] mock_post.return_value = R(data) assert Sms(header).DeletePremiumSubscription( body["DeletePremiumSubscription"]) == data, "should return an object"
from atlabs.sms import Sms header = { "base_url": "https://sandboxapi.fsi.ng", "Sandbox-Key": "your-sandbox-key-here", "Content-Type": "application/json" } body = { "shortCode": "19171", "keyword": "innovation-sandbox", "lastReceivedId": "0" } result = Sms(header).FetchPremiumSubscription(body) print(result)
from atlabs.sms import Sms header = { "base_url": "https://sandboxapi.fsi.ng", "Sandbox-Key": "your-sandbox-key-here", "Content-Type": "application/json" } body = { "to": "+2348123456789", "from": "FSI", "message": "Hello world!", "keyword": "innovation-sandbox", "linkId": "d", "retryDurationInHours": 1 } result = Sms(header).SendPremiumMessage(body) print(result)
from atlabs.sms import Sms header = { "base_url": "https://sandboxapi.fsi.ng", "Sandbox-Key": "your-sandbox-key-here", "Content-Type": "application/json" } body = { "shortCode": "19171", "keyword": "innovation-sandbox", "phoneNumber": "+2348123456789" } result = Sms(header).DeletePremiumSubscription(body) print(result)
from atlabs.sms import Sms header = { "base_url": "https://sandboxapi.fsi.ng", "Sandbox-Key": "your-sandbox-key-here", "Content-Type": "application/json" } body = { "shortCode": "19171", "keyword": "innovation-sandbox", "phoneNumber": "+2348123456789", "checkoutToken": "CkTkn_65faa63e-cc95-41bb-812e-1c1d921df70b" } result = Sms(header).CreatePremiumSubscription(body) print(result)