forked from messagebird/python-rest-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoice_list_webhook.py
More file actions
37 lines (29 loc) · 1.34 KB
/
Copy pathvoice_list_webhook.py
File metadata and controls
37 lines (29 loc) · 1.34 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
#!/usr/bin/env python
import argparse
import messagebird
from messagebird.voice_webhook import VoiceCreateWebhookRequest
parser = argparse.ArgumentParser()
parser.add_argument('--accessKey', help='access key for MessageBird API', type=str, required=True)
args = vars(parser.parse_args())
try:
client = messagebird.Client(args['accessKey'])
webhooks_list = client.voice_list_webhooks(limit=5, offset=0)
if webhooks_list is None or webhooks_list.data is None:
print("\nNo webhooks\n")
exit(0)
# Print the object information.
print('\nThe following information was returned as a Voice Webhook objects:\n')
for webhook in webhooks_list.data:
print('{')
print(' id : {}'.format(webhook.id))
print(' token : {}'.format(webhook.token))
print(' url : {}'.format(webhook.url))
print(' createdAt : {}'.format(webhook.createdAt))
print(' updatedAt : {}'.format(webhook.updatedAt))
print('}\n')
except messagebird.client.ErrorException as e:
print('An error occured while reading a Voice Webhook object:')
for error in e.errors:
print(' code : {}'.format(error.code))
print(' description : {}'.format(error.description))
print(' parameter : {}\n'.format(error.parameter))