Skip to content

Commit 7147c8f

Browse files
committed
Merge branch 'development' into feature/orders_group
2 parents 4991b6b + 38a1b16 commit 7147c8f

38 files changed

+1063
-486
lines changed

examples/.DS_Store

10 KB
Binary file not shown.

examples/addresses/add_route_destinations.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,15 @@ def main(api_key):
112112
print('Inserting addresses in Route: {}'.format(route_id))
113113

114114
response = r4m.route.insert_address_into_route(addresses, route_id)
115-
print('Addresses after insert')
116-
for i, address in enumerate(response['addresses']):
117-
print('Number {}:'.format(i))
118-
print('\taddress: {}'.format(address['address']))
119-
print('\t')
115+
116+
if isinstance(response, dict) and 'errors' in response.keys():
117+
print('. '.join(response['errors']))
118+
else:
119+
print('Addresses after insert')
120+
for i, address in enumerate(response['addresses']):
121+
print('Number {}:'.format(i))
122+
print('\taddress: {}'.format(address['address']))
123+
print('\t')
120124

121125

122126
# codebeat:enable[LOC, ABC]

examples/addresses/add_route_destinations_into_specific_position.py

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -83,42 +83,49 @@ def main(api_key):
8383

8484
response = r4m.run_optimization()
8585

86-
print('Current Addresses')
87-
for i, address in enumerate(response['addresses']):
88-
print('Number {}:'.format(i))
89-
print('\taddress: {}'.format(address['address']))
90-
print('\t')
91-
addresses = {
92-
'addresses': [
93-
{
94-
'address': '555 W 57th St New York, NY 10019',
95-
'lat': 40.7718005,
96-
'lng': -73.9897716,
97-
'alias': 'BMW of Manhattan',
98-
'sequence_no': 2,
99-
'time': 300,
100-
},
101-
{
102-
'address': '57 W 57th St New York, NY 10019',
103-
'lat': 40.7558695,
104-
'lng': -73.9862019,
105-
'alias': 'Verizon Wireless',
106-
'sequence_no': 5,
107-
'time': 300,
108-
}
109-
]
110-
}
86+
if isinstance(response, dict) and 'errors' in response.keys():
87+
print('. '.join(response['errors']))
88+
else:
89+
print('Current Addresses')
90+
for i, address in enumerate(response['addresses']):
91+
print('Number {}:'.format(i))
92+
print('\taddress: {}'.format(address['address']))
93+
print('\t')
94+
addresses = {
95+
'addresses': [
96+
{
97+
'address': '555 W 57th St New York, NY 10019',
98+
'lat': 40.7718005,
99+
'lng': -73.9897716,
100+
'alias': 'BMW of Manhattan',
101+
'sequence_no': 2,
102+
'time': 300,
103+
},
104+
{
105+
'address': '57 W 57th St New York, NY 10019',
106+
'lat': 40.7558695,
107+
'lng': -73.9862019,
108+
'alias': 'Verizon Wireless',
109+
'sequence_no': 5,
110+
'time': 300,
111+
}
112+
]
113+
}
111114

112-
route_id = response['addresses'][1]['route_id']
115+
route_id = response['addresses'][1]['route_id']
113116

114-
print('Inserting addresses in Route: {}'.format(route_id))
117+
print('Inserting addresses in Route: {}'.format(route_id))
115118

116-
response = r4m.route.insert_address_into_route(addresses, route_id)
117-
print('Addresses after insert')
118-
for i, address in enumerate(response['addresses']):
119-
print('Number {}:'.format(i))
120-
print('\taddress: {}'.format(address['address']))
121-
print('\t')
119+
response = r4m.route.insert_address_into_route(addresses, route_id)
120+
121+
if isinstance(response, dict) and 'errors' in response.keys():
122+
print('. '.join(response['errors']))
123+
else:
124+
print('Addresses after insert')
125+
for i, address in enumerate(response['addresses']):
126+
print('Number {}:'.format(i))
127+
print('\taddress: {}'.format(address['address']))
128+
print('\t')
122129

123130

124131
# codebeat:enable[LOC, ABC]

examples/addresses/move_destination_to_route.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,15 @@ def main(api_key):
127127
response = r4m.route.move_addresses_from_route(addresses, route_id)
128128
print('Addresses after move')
129129

130-
for i, address in enumerate(response['addresses']):
131-
print('Number {}:'.format(i))
132-
if address['is_depot']:
133-
print('\t This is a Depot')
134-
print('\taddress: {}'.format(address['address']))
135-
print('\t')
130+
if isinstance(response, dict) and 'errors' in response.keys():
131+
print('. '.join(response['errors']))
132+
else:
133+
for i, address in enumerate(response['addresses']):
134+
print('Number {}:'.format(i))
135+
if address['is_depot']:
136+
print('\t This is a Depot')
137+
print('\taddress: {}'.format(address['address']))
138+
print('\t')
136139

137140

138141
# codebeat:enable[LOC, ABC]

examples/rapid_address/get_street_data.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ def main(api_key):
1010

1111
rapid_address = route4me.rapid_address
1212
response = rapid_address.get_street_data()
13-
for street in response:
14-
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
15-
street.get('street_name'),
16-
street.get('zipcode')))
13+
if isinstance(response, dict) and 'errors' in response.keys():
14+
print('. '.join(response['errors']))
15+
elif not response:
16+
print("Unknown error occured")
17+
else:
18+
for street in response:
19+
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
20+
street.get('street_name'),
21+
street.get('zipcode')))
1722

1823

1924
if __name__ == '__main__':

examples/rapid_address/get_street_data_get_single.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ def main(api_key):
99

1010
rapid_address = route4me.rapid_address
1111
response = rapid_address.get_street_data(pk=33)
12-
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
13-
response.get('street_name'),
14-
response.get('zipcode')))
12+
if isinstance(response, dict) and 'errors' in response.keys():
13+
print('. '.join(response['errors']))
14+
else:
15+
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
16+
response.get('street_name'),
17+
response.get('zipcode')))
1518

1619

1720
if __name__ == '__main__':

examples/rapid_address/get_street_data_offset_limit.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ def main(api_key):
1010

1111
rapid_address = route4me.rapid_address
1212
response = rapid_address.get_street_data(offset=10, limit=10)
13-
for street in response:
14-
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
15-
street.get('street_name'),
16-
street.get('zipcode')))
13+
if isinstance(response, dict) and 'errors' in response.keys():
14+
print('. '.join(response['errors']))
15+
elif not response:
16+
print("Unknown error occured")
17+
else:
18+
for street in response:
19+
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
20+
street.get('street_name'),
21+
street.get('zipcode')))
1722

1823

1924
if __name__ == '__main__':

examples/rapid_address/get_street_data_service.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ def main(api_key):
1111
rapid_address = route4me.rapid_address
1212
response = rapid_address.get_street_data_service(housenumber=1800,
1313
zipcode=33166)
14-
for street in response:
15-
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
16-
street.get('street_name'),
17-
street.get('zipcode')))
14+
if isinstance(response, dict) and 'errors' in response.keys():
15+
print('. '.join(response['errors']))
16+
else:
17+
for street in response:
18+
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
19+
street.get('street_name'),
20+
street.get('zipcode')))
1821

1922

2023
if __name__ == '__main__':

examples/rapid_address/get_street_data_service_offset_limit.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ def main(api_key):
1313
zipcode=33166,
1414
offset=10,
1515
limit=5)
16-
for street in response:
17-
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
18-
street.get('street_name'),
19-
street.get('zipcode')))
16+
if isinstance(response, dict) and 'errors' in response.keys():
17+
print('. '.join(response['errors']))
18+
else:
19+
for street in response:
20+
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
21+
street.get('street_name'),
22+
street.get('zipcode')))
2023

2124

2225
if __name__ == '__main__':

examples/rapid_address/get_street_data_zip.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ def main(api_key):
99

1010
rapid_address = route4me.rapid_address
1111
response = rapid_address.get_street_data_zip(zipcode=33166)
12-
for street in response:
13-
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
14-
street.get('street_name'),
15-
street.get('zipcode')))
12+
if isinstance(response, dict) and 'errors' in response.keys():
13+
print('. '.join(response['errors']))
14+
else:
15+
for street in response:
16+
print('Street Name:\t{0}\t\tZip Code:\t{1}'.format(
17+
street.get('street_name'),
18+
street.get('zipcode')))
1619

1720

1821
if __name__ == '__main__':

0 commit comments

Comments
 (0)