Skip to content

Commit bb53bab

Browse files
committed
Format code properly
1 parent bdc3e3f commit bb53bab

17 files changed

+394
-397
lines changed
Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
#!/usr/bin/env python
2-
import sys
32
import argparse
43
import messagebird
54
from messagebird.conversation_message import MESSAGE_TYPE_TEXT
65

76
parser = argparse.ArgumentParser()
87
parser.add_argument('--accessKey', help='access key for MessageBird API', type=str, required=True)
9-
parser.add_argument('--conversationId', help='conversation ID that you want to create a message for', type=str, required=True)
8+
parser.add_argument('--conversationId', help='conversation ID that you want to create a message for', type=str,
9+
required=True)
1010
parser.add_argument('--channelId', help='channel ID that you want to create a message for', type=str, required=True)
1111
parser.add_argument('--message', help='message that you want to send', type=str, required=True)
1212
args = vars(parser.parse_args())
1313

1414
try:
15-
client = messagebird.Client(args['accessKey'])
15+
client = messagebird.Client(args['accessKey'])
1616

17-
msg = client.conversation_create_message(args['conversationId'], { 'channelId': args['channelId'], 'type': MESSAGE_TYPE_TEXT, 'content': { 'text': args['message'] } })
17+
msg = client.conversation_create_message(args['conversationId'],
18+
{'channelId': args['channelId'], 'type': MESSAGE_TYPE_TEXT,
19+
'content': {'text': args['message']}})
1820

19-
# Print the object information.
20-
print('\nThe following information was returned as a Conversation List object:\n')
21-
print(' message id : %s' % msg.id)
22-
print(' channel id : %s' % msg.channelId)
23-
print(' direction : %s' % msg.direction)
24-
print(' content : %s' % msg.content)
25-
print(' content : %s' % msg.content)
26-
print(' status : %s' % msg.status)
27-
print(' type : %s' % msg.type)
28-
print(' created date : %s' % msg.createdDatetime)
29-
print(' updated date : %s' % msg.updatedDatetime)
21+
# Print the object information.
22+
print('\nThe following information was returned as a Conversation List object:\n')
23+
print(' message id : %s' % msg.id)
24+
print(' channel id : %s' % msg.channelId)
25+
print(' direction : %s' % msg.direction)
26+
print(' content : %s' % msg.content)
27+
print(' content : %s' % msg.content)
28+
print(' status : %s' % msg.status)
29+
print(' type : %s' % msg.type)
30+
print(' created date : %s' % msg.createdDatetime)
31+
print(' updated date : %s' % msg.updatedDatetime)
3032

3133
except messagebird.client.ErrorException as e:
32-
print('\nAn error occured while requesting a Message object:\n')
34+
print('\nAn error occured while requesting a Message object:\n')
3335

34-
for error in e.errors:
35-
print(' code : %d' % error.code)
36-
print(' description : %s' % error.description)
37-
print(' parameter : %s\n' % error.parameter)
36+
for error in e.errors:
37+
print(' code : %d' % error.code)
38+
print(' description : %s' % error.description)
39+
print(' parameter : %s\n' % error.parameter)
Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env python
2-
import sys
32
import argparse
43
import messagebird
54
from messagebird.conversation_webhook import \
6-
CONVERSATION_WEBHOOK_EVENT_CONVERSATION_CREATED,\
5+
CONVERSATION_WEBHOOK_EVENT_CONVERSATION_CREATED, \
76
CONVERSATION_WEBHOOK_EVENT_CONVERSATION_UPDATED
87

98
parser = argparse.ArgumentParser()
@@ -13,26 +12,26 @@
1312
args = vars(parser.parse_args())
1413

1514
try:
16-
client = messagebird.Client(args['accessKey'])
15+
client = messagebird.Client(args['accessKey'])
1716

18-
webhook = client.conversation_create_webhook({
19-
'channelId': args['channelId'],
20-
'events': [CONVERSATION_WEBHOOK_EVENT_CONVERSATION_CREATED, CONVERSATION_WEBHOOK_EVENT_CONVERSATION_UPDATED],
21-
'url': args['url']
22-
})
17+
webhook = client.conversation_create_webhook({
18+
'channelId': args['channelId'],
19+
'events': [CONVERSATION_WEBHOOK_EVENT_CONVERSATION_CREATED, CONVERSATION_WEBHOOK_EVENT_CONVERSATION_UPDATED],
20+
'url': args['url']
21+
})
2322

24-
# Print the object information.
25-
print('\nThe following information was returned as a Webhook object:\n')
26-
print(' id : %s' % webhook.id)
27-
print(' events : %s' % webhook.events)
28-
print(' channel id : %s' % webhook.channelId)
29-
print(' created date : %s' % webhook.createdDatetime)
30-
print(' updated date : %s' % webhook.updatedDatetime)
23+
# Print the object information.
24+
print('\nThe following information was returned as a Webhook object:\n')
25+
print(' id : %s' % webhook.id)
26+
print(' events : %s' % webhook.events)
27+
print(' channel id : %s' % webhook.channelId)
28+
print(' created date : %s' % webhook.createdDatetime)
29+
print(' updated date : %s' % webhook.updatedDatetime)
3130

3231
except messagebird.client.ErrorException as e:
33-
print('\nAn error occured while requesting a Webhook object:\n')
32+
print('\nAn error occured while requesting a Webhook object:\n')
3433

35-
for error in e.errors:
36-
print(' code : %d' % error.code)
37-
print(' description : %s' % error.description)
38-
print(' parameter : %s\n' % error.parameter)
34+
for error in e.errors:
35+
print(' code : %d' % error.code)
36+
print(' description : %s' % error.description)
37+
print(' parameter : %s\n' % error.parameter)
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
import sys
32
import argparse
43
import messagebird
54

@@ -9,17 +8,17 @@
98
args = vars(parser.parse_args())
109

1110
try:
12-
client = messagebird.Client(args['accessKey'])
11+
client = messagebird.Client(args['accessKey'])
1312

14-
client.conversation_delete_webhook(args['webhookId'])
13+
client.conversation_delete_webhook(args['webhookId'])
1514

16-
# Print the object information.
17-
print('\nWebhook has been deleted:\n')
15+
# Print the object information.
16+
print('\nWebhook has been deleted:\n')
1817

1918
except messagebird.client.ErrorException as e:
20-
print('\nAn error occured while requesting a Webhook object:\n')
19+
print('\nAn error occured while requesting a Webhook object:\n')
2120

22-
for error in e.errors:
23-
print(' code : %d' % error.code)
24-
print(' description : %s' % error.description)
25-
print(' parameter : %s\n' % error.parameter)
21+
for error in e.errors:
22+
print(' code : %d' % error.code)
23+
print(' description : %s' % error.description)
24+
print(' parameter : %s\n' % error.parameter)

examples/conversation_list.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
#!/usr/bin/env python
22
import messagebird
33
import argparse
4-
import sys
54

65
parser = argparse.ArgumentParser()
76
parser.add_argument('--accessKey', help='access key for MessageBird API', type=str, required=True)
87
args = vars(parser.parse_args())
98

109
try:
11-
client = messagebird.Client(args['accessKey'])
10+
client = messagebird.Client(args['accessKey'])
1211

13-
conversationList = client.conversation_list()
12+
conversationList = client.conversation_list()
1413

15-
itemIds = []
16-
for msgItem in conversationList.items:
17-
itemIds.append(msgItem.id)
14+
itemIds = []
15+
for msgItem in conversationList.items:
16+
itemIds.append(msgItem.id)
1817

19-
# Print the object information.
20-
print('\nThe following information was returned as a Conversation List object:\n')
21-
print(' conversation ids : %s' % itemIds)
22-
print(' offset : %s' % conversationList.offset)
23-
print(' limit : %s' % conversationList.limit)
24-
print(' totalCount : %s' % conversationList.totalCount)
18+
# Print the object information.
19+
print('\nThe following information was returned as a Conversation List object:\n')
20+
print(' conversation ids : %s' % itemIds)
21+
print(' offset : %s' % conversationList.offset)
22+
print(' limit : %s' % conversationList.limit)
23+
print(' totalCount : %s' % conversationList.totalCount)
2524

2625
except messagebird.client.ErrorException as e:
27-
print('\nAn error occured while requesting a Message object:\n')
26+
print('\nAn error occured while requesting a Message object:\n')
2827

29-
for error in e.errors:
30-
print(' code : %d' % error.code)
31-
print(' description : %s' % error.description)
32-
print(' parameter : %s\n' % error.parameter)
28+
for error in e.errors:
29+
print(' code : %d' % error.code)
30+
print(' description : %s' % error.description)
31+
print(' parameter : %s\n' % error.parameter)
Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
import sys
32
import argparse
43
import messagebird
54

@@ -9,25 +8,25 @@
98
args = vars(parser.parse_args())
109

1110
try:
12-
client = messagebird.Client(args['accessKey'])
11+
client = messagebird.Client(args['accessKey'])
1312

14-
msg = client.conversation_list_messages(args['conversationId'])
13+
msg = client.conversation_list_messages(args['conversationId'])
1514

16-
itemIds = []
17-
for msgItem in msg.items:
18-
itemIds.append(msgItem.id)
15+
itemIds = []
16+
for msgItem in msg.items:
17+
itemIds.append(msgItem.id)
1918

20-
# Print the object information.
21-
print('\nThe following information was returned as a Conversation Message List object:\n')
22-
print(' message ids : %s' % itemIds)
23-
print(' offset : %s' % msg.offset)
24-
print(' limit : %s' % msg.limit)
25-
print(' totalCount : %s' % msg.totalCount)
19+
# Print the object information.
20+
print('\nThe following information was returned as a Conversation Message List object:\n')
21+
print(' message ids : %s' % itemIds)
22+
print(' offset : %s' % msg.offset)
23+
print(' limit : %s' % msg.limit)
24+
print(' totalCount : %s' % msg.totalCount)
2625

2726
except messagebird.client.ErrorException as e:
28-
print('\nAn error occured while requesting a Conversation Message List object:\n')
27+
print('\nAn error occured while requesting a Conversation Message List object:\n')
2928

30-
for error in e.errors:
31-
print(' code : %d' % error.code)
32-
print(' description : %s' % error.description)
33-
print(' parameter : %s\n' % error.parameter)
29+
for error in e.errors:
30+
print(' code : %d' % error.code)
31+
print(' description : %s' % error.description)
32+
print(' parameter : %s\n' % error.parameter)
Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
import sys
32
import argparse
43
import messagebird
54

@@ -8,25 +7,25 @@
87
args = vars(parser.parse_args())
98

109
try:
11-
client = messagebird.Client(args['accessKey'])
10+
client = messagebird.Client(args['accessKey'])
1211

13-
webhookList = client.conversation_list_webhooks()
12+
webhookList = client.conversation_list_webhooks()
1413

15-
itemIds = []
16-
for msgItem in webhookList.items:
17-
itemIds.append(msgItem.id)
14+
itemIds = []
15+
for msgItem in webhookList.items:
16+
itemIds.append(msgItem.id)
1817

19-
# Print the object information.
20-
print('\nThe following information was returned as a Conversation Webhook List object:\n')
21-
print(' conversation ids : %s' % itemIds)
22-
print(' offset : %s' % webhookList.offset)
23-
print(' limit : %s' % webhookList.limit)
24-
print(' totalCount : %s' % webhookList.totalCount)
18+
# Print the object information.
19+
print('\nThe following information was returned as a Conversation Webhook List object:\n')
20+
print(' conversation ids : %s' % itemIds)
21+
print(' offset : %s' % webhookList.offset)
22+
print(' limit : %s' % webhookList.limit)
23+
print(' totalCount : %s' % webhookList.totalCount)
2524

2625
except messagebird.client.ErrorException as e:
27-
print('\nAn error occured while requesting a Conversation Webhook List object:\n')
26+
print('\nAn error occured while requesting a Conversation Webhook List object:\n')
2827

29-
for error in e.errors:
30-
print(' code : %d' % error.code)
31-
print(' description : %s' % error.description)
32-
print(' parameter : %s\n' % error.parameter)
28+
for error in e.errors:
29+
print(' code : %d' % error.code)
30+
print(' description : %s' % error.description)
31+
print(' parameter : %s\n' % error.parameter)

examples/conversation_read.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
#!/usr/bin/env python
22
import messagebird
33
import argparse
4-
import sys
54

65
parser = argparse.ArgumentParser()
76
parser.add_argument('--accessKey', help='access key for MessageBird API', type=str, required=True)
87
parser.add_argument('--conversationId', help='conversation that you want the message list', type=str, required=True)
98
args = vars(parser.parse_args())
109

1110
try:
12-
client = messagebird.Client(args['accessKey'])
11+
client = messagebird.Client(args['accessKey'])
1312

14-
conversation = client.conversation_read(args['conversationId'])
13+
conversation = client.conversation_read(args['conversationId'])
1514

16-
# Print the object information.
17-
print('\nThe following information was returned as a Conversation object:\n')
18-
print(' conversation id : %s' % conversation.id)
19-
print(' contact id : %s' % conversation.contactId)
20-
print(' messages total count : %s' % conversation.messages.totalCount)
21-
print(' status : %s' % conversation.status)
22-
print(' created date time : %s' % conversation.createdDatetime)
23-
print(' updated date time : %s' % conversation.updatedDatetime)
24-
print(' last received date time : %s' % conversation.lastReceivedDatetime)
15+
# Print the object information.
16+
print('\nThe following information was returned as a Conversation object:\n')
17+
print(' conversation id : %s' % conversation.id)
18+
print(' contact id : %s' % conversation.contactId)
19+
print(' messages total count : %s' % conversation.messages.totalCount)
20+
print(' status : %s' % conversation.status)
21+
print(' created date time : %s' % conversation.createdDatetime)
22+
print(' updated date time : %s' % conversation.updatedDatetime)
23+
print(' last received date time : %s' % conversation.lastReceivedDatetime)
2524

2625
except messagebird.client.ErrorException as e:
27-
print('\nAn error occured while requesting a Conversation object:\n')
26+
print('\nAn error occured while requesting a Conversation object:\n')
2827

29-
for error in e.errors:
30-
print(' code : %d' % error.code)
31-
print(' description : %s' % error.description)
32-
print(' parameter : %s\n' % error.parameter)
28+
for error in e.errors:
29+
print(' code : %d' % error.code)
30+
print(' description : %s' % error.description)
31+
print(' parameter : %s\n' % error.parameter)
Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
import sys
32
import argparse
43
import messagebird
54

@@ -9,26 +8,26 @@
98
args = vars(parser.parse_args())
109

1110
try:
12-
client = messagebird.Client(args['accessKey'])
11+
client = messagebird.Client(args['accessKey'])
1312

14-
msg = client.conversation_read_message(args['messageId'])
13+
msg = client.conversation_read_message(args['messageId'])
1514

16-
# Print the object information.
17-
print('\nThe following information was returned as a Conversation List object:\n')
18-
print(' message id : %s' % msg.id)
19-
print(' channel id : %s' % msg.channelId)
20-
print(' direction : %s' % msg.direction)
21-
print(' content : %s' % msg.content)
22-
print(' content : %s' % msg.content)
23-
print(' status : %s' % msg.status)
24-
print(' type : %s' % msg.type)
25-
print(' created date : %s' % msg.createdDatetime)
26-
print(' updated date : %s' % msg.updatedDatetime)
15+
# Print the object information.
16+
print('\nThe following information was returned as a Conversation List object:\n')
17+
print(' message id : %s' % msg.id)
18+
print(' channel id : %s' % msg.channelId)
19+
print(' direction : %s' % msg.direction)
20+
print(' content : %s' % msg.content)
21+
print(' content : %s' % msg.content)
22+
print(' status : %s' % msg.status)
23+
print(' type : %s' % msg.type)
24+
print(' created date : %s' % msg.createdDatetime)
25+
print(' updated date : %s' % msg.updatedDatetime)
2726

2827
except messagebird.client.ErrorException as e:
29-
print('\nAn error occured while requesting a Message object:\n')
28+
print('\nAn error occured while requesting a Message object:\n')
3029

31-
for error in e.errors:
32-
print(' code : %d' % error.code)
33-
print(' description : %s' % error.description)
34-
print(' parameter : %s\n' % error.parameter)
30+
for error in e.errors:
31+
print(' code : %d' % error.code)
32+
print(' description : %s' % error.description)
33+
print(' parameter : %s\n' % error.parameter)

0 commit comments

Comments
 (0)