Skip to content

Commit c18e91b

Browse files
style & pr fixes
1 parent 53daec5 commit c18e91b

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

examples/call.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@
3131

3232
# Print the object information.
3333
print('\nThe following information was returned as a', str(call.__class__), 'object:\n')
34-
print(' '.join(str(call).splitlines(True)))
34+
print(' id : %s' % call.data.id)
35+
print(' status : %s' % call.data.status)
36+
print(' source : %s' % call.data.source)
37+
print(' destination : %s' % call.data.destination)
38+
print(' createdAt : %s' % call.data.createdAt)
39+
print(' updatedAt : %s' % call.data.updatedAt)
40+
print(' endedAt : %s' % call.data.endedAt)
3541

3642
except messagebird.client.ErrorException as e:
3743
print('\nAn error occurred while requesting a Message object:\n')

examples/call_create.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@
2727
# arguments to parse as json
2828
jsonArgs = ['callFlow', 'webhook']
2929

30-
print()
3130
for jsonArg in jsonArgs:
3231
try:
3332
args[jsonArg] = json.loads(str(args[jsonArg]).strip('\''))
3433
except json.decoder.JSONDecodeError as e:
3534
parser.print_usage()
36-
print('Invalid json provided for', jsonArg, ':', e)
37-
print('Provided', jsonArg, 'json:', args[jsonArg])
35+
print('Invalid json provided for %s: %s' % (jsonArg, e))
36+
print('Provided %s json: %s' % (jsonArg, args[jsonArg]))
3837
exit(1)
3938

4039
try:
@@ -47,6 +46,14 @@
4746

4847
# Print the object information.
4948
print('\nThe following information was returned as a', str(call.__class__), 'object:\n')
49+
print(' id : %s' % call.data.id)
50+
print(' status : %s' % call.data.status)
51+
print(' source : %s' % call.data.source)
52+
print(' destination : %s' % call.data.destination)
53+
print(' webhook : %s' % call.data.webhook)
54+
print(' createdAt : %s' % call.data.createdAt)
55+
print(' updatedAt : %s' % call.data.updatedAt)
56+
print(' endedAt : %s' % call.data.endedAt)
5057

5158
except messagebird.client.ErrorException as e:
5259
print('\nAn error occurred while creating a call:\n')

messagebird/call_data.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ def webhook(self, value):
4949
def __str__(self):
5050
return "\n".join([
5151
'id : %s' % self.id,
52+
'status : %s' % self.status,
53+
'source : %s' % self.source,
54+
'destination : %s' % self.destination,
55+
'webhook : %s' % self.webhook,
5256
'updatedAt : %s' % self.updatedAt,
5357
'createdAt : %s' % self.createdAt,
5458
'endedAt : %s' % self.endedAt,
55-
'webhook : %s' % self.webhook,
5659
])

messagebird/webhook.py

+6
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ class Webhook(Base):
66
def __init__(self):
77
self.url = None
88
self.token = None
9+
10+
def __str__(self):
11+
return "\n".join([
12+
'url : %s' % self.url,
13+
'token : %s' % self.token,
14+
])

tests/test_call.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,20 @@ def test_call_create(self):
9797
# check all api response data is outputted
9898
expected_data = self.create_expected_call_data_based_on_api_response(api_response)
9999
response_data = call_creation_response.data.__dict__
100-
self.assertEqual(expected_data, response_data, 'Check client response contains the api response data.')
100+
self.assertEqual(expected_data, response_data, 'Check client response contains the API response data.')
101101

102102
# check it can be formatted as string
103103
expected_call_string = 'id : None\n' + \
104104
'data.id : 21025ed1-cc1d-4554-ac05-043fa6c84e00\n' + \
105+
'data.status : queued\n' + \
106+
'data.source : 31644556677\n' + \
107+
'data.destination : 31612345678\n' + \
108+
'data.webhook : None\n' + \
105109
'data.updatedAt : 2017-08-30 07:35:37+00:00\n' + \
106110
'data.createdAt : 2017-08-30 07:35:37+00:00\n' + \
107-
'data.endedAt : None\n' + \
108-
'data.webhook : None'
111+
'data.endedAt : None'
109112
self.assertEqual(expected_call_string, str(call_creation_response), 'Check returned call can be formatted as' +
110-
'string')
113+
' string')
111114

112115
@staticmethod
113116
def create_expected_call_data_based_on_api_response(api_response):

0 commit comments

Comments
 (0)