|
14 | 14 | args = vars(parser.parse_args()) |
15 | 15 |
|
16 | 16 | try: |
17 | | - # Create a MessageBird client with the specified accessKey. |
18 | | - client = messagebird.Client(args['accessKey']) |
19 | | - |
20 | | - # Fetch the NumberList object with specified params, limit, offset. |
21 | | - params = {'features': ['sms', 'voice'], 'number': 319} |
22 | | - numbers = client.available_numbers_list('NL', params, 2, 0) |
23 | | - |
24 | | - # Print the object information. |
25 | | - print('\nThe following information was returned as a %s object:\n' % numbers.__class__) |
26 | | - if numbers.items is not None: |
27 | | - print(' Containing the the following items:') |
28 | | - for item in numbers.items: |
29 | | - print(' {') |
30 | | - print(' number : %s' % item.number) |
31 | | - print(' country : %s' % item.country) |
32 | | - print(' region : %s' % item.region) |
33 | | - print(' locality : %s' % item.locality) |
34 | | - print(' features : %s' % item.features) |
35 | | - print(' tags : %s' % item.tags) |
36 | | - print(' type : %s' % item.type) |
37 | | - print(' status : %s' % item.status) |
38 | | - print(' },') |
39 | | - else: |
40 | | - print(' With an empty response.') |
| 17 | + # Create a MessageBird client with the specified accessKey. |
| 18 | + client = messagebird.Client(args['accessKey']) |
| 19 | + |
| 20 | + # Fetch the NumberList object with specified params, limit, offset. |
| 21 | + params = {'features': ['sms', 'voice'], 'number': 319} |
| 22 | + numbers = client.available_numbers_list('NL', params, 2, 0) |
| 23 | + |
| 24 | + # Print the object information. |
| 25 | + print('\nThe following information was returned as a %s object:\n' % numbers.__class__) |
| 26 | + if numbers.items is not None: |
| 27 | + print(' Containing the the following items:') |
| 28 | + for item in numbers.items: |
| 29 | + print(' {') |
| 30 | + print(' number : %s' % item.number) |
| 31 | + print(' country : %s' % item.country) |
| 32 | + print(' region : %s' % item.region) |
| 33 | + print(' locality : %s' % item.locality) |
| 34 | + print(' features : %s' % item.features) |
| 35 | + print(' tags : %s' % item.tags) |
| 36 | + print(' type : %s' % item.type) |
| 37 | + print(' status : %s' % item.status) |
| 38 | + print(' },') |
| 39 | + else: |
| 40 | + print(' With an empty response.') |
41 | 41 |
|
42 | 42 | except messagebird.client.ErrorException as e: |
43 | | - print('\nAn error occured while requesting a NumberList object:\n') |
| 43 | + print('\nAn error occured while requesting a NumberList object:\n') |
44 | 44 |
|
45 | | - for error in e.errors: |
46 | | - print(' code : %d' % error.code) |
47 | | - print(' description : %s' % error.description) |
48 | | - print(' parameter : %s\n' % error.parameter) |
| 45 | + for error in e.errors: |
| 46 | + print(' code : %d' % error.code) |
| 47 | + print(' description : %s' % error.description) |
| 48 | + print(' parameter : %s\n' % error.parameter) |
49 | 49 |
|
50 | 50 | except requests.exceptions.HTTPError as e: |
51 | 51 | print('\nAn HTTP exception occurred while fetching all purchased phone numbers:') |
|
0 commit comments