Skip to content

Commit f532fca

Browse files
committed
Use str to represent object as string
1 parent bb53bab commit f532fca

14 files changed

+96
-90
lines changed

examples/conversation_create_message.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,8 @@
1919
'content': {'text': args['message']}})
2020

2121
# 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)
22+
print('The following information was returned as a Conversation List object:\n')
23+
print(msg)
3224

3325
except messagebird.client.ErrorException as e:
3426
print('\nAn error occured while requesting a Message object:\n')

examples/conversation_create_webhook.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@
2121
})
2222

2323
# 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)
24+
print('The following information was returned as a Webhook object:')
25+
print(webhook)
3026

3127
except messagebird.client.ErrorException as e:
3228
print('\nAn error occured while requesting a Webhook object:\n')

examples/conversation_delete_webhook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
client.conversation_delete_webhook(args['webhookId'])
1414

1515
# Print the object information.
16-
print('\nWebhook has been deleted:\n')
16+
print('Webhook has been deleted')
1717

1818
except messagebird.client.ErrorException as e:
1919
print('\nAn error occured while requesting a Webhook object:\n')

examples/conversation_list.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,12 @@
1111

1212
conversationList = client.conversation_list()
1313

14-
itemIds = []
15-
for msgItem in conversationList.items:
16-
itemIds.append(msgItem.id)
17-
1814
# 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)
15+
print('The following information was returned as a Conversation List object:')
16+
print(conversationList)
2417

2518
except messagebird.client.ErrorException as e:
26-
print('\nAn error occured while requesting a Message object:\n')
19+
print('An error occured while requesting a Message object:')
2720

2821
for error in e.errors:
2922
print(' code : %d' % error.code)

examples/conversation_list_messages.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,9 @@
1212

1313
msg = client.conversation_list_messages(args['conversationId'])
1414

15-
itemIds = []
16-
for msgItem in msg.items:
17-
itemIds.append(msgItem.id)
18-
1915
# 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)
16+
print('The following information was returned as a Conversation Message List object:')
17+
print(msg)
2518

2619
except messagebird.client.ErrorException as e:
2720
print('\nAn error occured while requesting a Conversation Message List object:\n')

examples/conversation_list_webhook.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,11 @@
99
try:
1010
client = messagebird.Client(args['accessKey'])
1111

12-
webhookList = client.conversation_list_webhooks()
13-
14-
itemIds = []
15-
for msgItem in webhookList.items:
16-
itemIds.append(msgItem.id)
12+
webhook_list = client.conversation_list_webhooks()
1713

1814
# 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)
15+
print('The following information was returned as a Conversation Webhook List object:')
16+
print(webhook_list)
2417

2518
except messagebird.client.ErrorException as e:
2619
print('\nAn error occured while requesting a Conversation Webhook List object:\n')

examples/conversation_read.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@
1313
conversation = client.conversation_read(args['conversationId'])
1414

1515
# 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)
16+
print('The following information was returned as a Conversation object:')
17+
print(conversation)
2418

2519
except messagebird.client.ErrorException as e:
2620
print('\nAn error occured while requesting a Conversation object:\n')

examples/conversation_read_message.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,8 @@
1313
msg = client.conversation_read_message(args['messageId'])
1414

1515
# 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)
16+
print('The following information was returned as a Conversation List object:')
17+
print(msg)
2618

2719
except messagebird.client.ErrorException as e:
2820
print('\nAn error occured while requesting a Message object:\n')

examples/conversation_read_webhook.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@
1313
webhook = client.conversation_read_webhook(args['webhookId'])
1414

1515
# Print the object information.
16-
print('\nThe following information was returned as a Webhook object:\n')
17-
print(' id : %s' % webhook.id)
18-
print(' events : %s' % webhook.events)
19-
print(' channel id : %s' % webhook.channelId)
20-
print(' created date : %s' % webhook.createdDatetime)
21-
print(' updated date : %s' % webhook.updatedDatetime)
16+
print('The following information was returned as a Webhook object:')
17+
print(webhook)
2218

2319
except messagebird.client.ErrorException as e:
2420
print('\nAn error occured while requesting a Webhook object:\n')

examples/conversation_start.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,8 @@
1818
'content': {'text': args['textMessage']}})
1919

2020
# Print the object information.
21-
print('\nThe following information was returned as a Conversation object:\n')
22-
print(' id : %s' % msg.id)
23-
print(' contact id : %s' % msg.contactId)
24-
print(' contact : %s' % msg.contact)
25-
print(' last used channel id : %s' % msg.lastUsedChannelId)
26-
print(' channels : %s' % msg.channels)
27-
print(' messages : %s' % msg.messages)
28-
print(' status : %s' % msg.status)
29-
print(' createdDateTime : %s' % msg.createdDateTime)
30-
print(' updatedDateTime : %s' % msg.updatedDateTime)
31-
print(' lastReceivedDateTime : %s' % msg.lastReceivedDateTime)
21+
print('The following information was returned as a Conversation object:')
22+
print(msg)
3223

3324
except messagebird.client.ErrorException as e:
3425
print('\nAn error occured while requesting a Message object:\n')

0 commit comments

Comments
 (0)