forked from zerobounce/zero-bounce-python-sdk-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample.py
103 lines (77 loc) · 2.95 KB
/
Sample.py
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
103
from datetime import date
from zerobouncesdk import zerobouncesdk, ZBApiException, \
ZBMissingApiKeyException
def test_validate():
try:
response = zerobouncesdk.validate(email="<EMAIL_TO_TEST>")
print("validate success response: " + str(response))
except ZBApiException as e:
print("validate error message: " + str(e))
except ZBMissingApiKeyException as e:
print("get_credits error message: " + str(e))
def test_get_credits():
try:
response = zerobouncesdk.get_credits()
print("get_credits success response: " + str(response))
except ZBApiException as e:
print("get_credits error message: " + str(e))
except ZBMissingApiKeyException as e:
print("get_credits error message: " + str(e))
def test_send_file():
try:
response = zerobouncesdk.send_file(
file_path='./email_file.csv',
email_address_column=1,
return_url=None,
first_name_column=2,
last_name_column=3,
has_header_row=True)
print("sendfile success response: " + str(response))
except ZBApiException as e:
print("sendfile error message: " + str(e))
except ZBMissingApiKeyException as e:
print("get_credits error message: " + str(e))
def test_file_status():
try:
response = zerobouncesdk.file_status("<YOUR_FILE_ID>")
print("file_status success response: " + str(response))
except ZBApiException as e:
print("file_status error message: " + str(e))
except ZBMissingApiKeyException as e:
print("file_status error message: " + str(e))
def test_delete_file():
try:
response = zerobouncesdk.delete_file("<YOUR_FILE_ID>")
print("delete_file success response: " + str(response))
except ZBApiException as e:
print("delete_file error message: " + str(e))
except ZBMissingApiKeyException as e:
print("delete_file error message: " + str(e))
def test_get_api_usage():
try:
start_date = date(2019, 7, 5)
end_date = date(2019, 7, 15)
response = zerobouncesdk.get_api_usage(start_date, end_date)
print("get_api_usage success response: " + str(response))
except ZBApiException as e:
print("get_api_usage error message: " + str(e))
except ZBMissingApiKeyException as e:
print("get_api_usage error message: " + str(e))
def test_get_file():
try:
response = zerobouncesdk.get_file("<YOUR_FILE_ID>", "./downloads/emails.csv")
print("get_file success response: " + str(response))
except ZBApiException as e:
print("get_file error message: " + str(e))
except ZBMissingApiKeyException as e:
print("get_file error message: " + str(e))
def test():
zerobouncesdk.initialize("<YOUR_API_KEY>")
# test_validate()
# test_send_file()
# test_get_credits()
# test_file_status()
# test_delete_file()
# test_get_api_usage()
test_get_file()
test()