-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sdk.py
More file actions
102 lines (88 loc) · 3.27 KB
/
test_sdk.py
File metadata and controls
102 lines (88 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import os
import json
from dotenv import load_dotenv
from frog_sdk import FrogSDK
# Load credentials from .env
load_dotenv()
api_key = os.getenv('FROG_API_KEY')
username = os.getenv('FROG_USERNAME')
if not api_key or not username:
print("Error: FROG_API_KEY and FROG_USERNAME must be set in .env file.")
exit(1)
sdk = FrogSDK(api_key, username)
def main_menu():
while True:
print("\n--- Frog Python SDK Interactive Test ---")
print("1. SMS Methods")
print("2. Voice Methods")
print("0. Exit")
choice = input("Select a category: ")
if choice == '1':
sms_menu()
elif choice == '2':
voice_menu()
elif choice == '0':
break
def sms_menu():
print("\n--- SMS Methods ---")
print("1. Send General SMS")
print("2. Send Personalized SMS")
print("3. Generate SMS OTP")
print("4. Verify SMS OTP")
print("0. Back")
choice = input("Select an option: ")
try:
if choice == '1':
senderid = input("Sender ID [WIGAL]: ") or "WIGAL"
dest = input("Destination Number: ")
msg = input("Message: ")
res = sdk.send_sms(senderid, [{'destination': dest, 'msgid': 'PY-TEST-1'}], msg)
print("Response:", json.dumps(res, indent=2))
elif choice == '2':
dest = input("Destination 1: ")
msg = input("Message 1: ")
res = sdk.send_personalized_sms("WIGAL", [{'destination': dest, 'message': msg, 'msgid': 'P1'}])
print("Response:", json.dumps(res, indent=2))
elif choice == '3':
num = input("Number: ")
res = sdk.generate_sms_otp("WIGAL", num)
print("Response:", json.dumps(res, indent=2))
elif choice == '4':
num = input("Number: ")
code = input("OTP Code: ")
res = sdk.verify_sms_otp(num, code)
print("Response:", json.dumps(res, indent=2))
except Exception as e:
print("Error:", e)
def voice_menu():
print("\n--- Voice Methods ---")
print("1. Send Voice Message")
print("2. Send Interactive Voice")
print("3. Generate Voice OTP")
print("4. Verify Voice OTP")
print("0. Back")
choice = input("Select an option: ")
try:
if choice == '1':
url = input("Sound URL: ")
num = input("Number: ")
res = sdk.send_voice("WIGAL", url, [{'destination': num, 'msgid': 'V1'}])
print("Response:", json.dumps(res, indent=2))
elif choice == '2':
prompt = input("Prompt URL/Text: ")
num = input("Number: ")
res = sdk.send_interactive_voice("WIGAL", prompt, 1, [{'destination': num, 'msgid': 'IVR1'}])
print("Response:", json.dumps(res, indent=2))
elif choice == '3':
num = input("Number: ")
res = sdk.generate_voice_otp("WIGAL", num)
print("Response:", json.dumps(res, indent=2))
elif choice == '4':
num = input("Number: ")
code = input("OTP Code: ")
res = sdk.verify_voice_otp(num, code)
print("Response:", json.dumps(res, indent=2))
except Exception as e:
print("Error:", e)
if __name__ == "__main__":
main_menu()