Skip to content

Commit 4f3ed03

Browse files
authored
Merge pull request #28 from route4me/development
Development
2 parents ad2be75 + de31000 commit 4f3ed03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2003
-1030
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Route4Me_SDK.egg-info/
1212
.venv
1313
docs/html/*
1414
.tox
15+
.DS_Store

VERSION.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
# VERSION.py - MAINTAINER's. Don't edit, if you don't know what are you doing
77
# ==============================================================================
88

9-
VERSION = (0, 1, 5, 1)
10-
RELEASE_SUFFIX = ''
9+
VERSION = (0, 1, 6, 0)
10+
RELEASE_SUFFIX = ""
1111

12-
VERSION_STRING = '.'.join([str(x) for x in VERSION])
12+
VERSION_STRING = ".".join([str(x) for x in VERSION])
1313
RELEASE_STRING = "v{}{}".format(VERSION_STRING, RELEASE_SUFFIX)
1414

15-
PROJECT = 'Route4Me Python SDK'
16-
COPYRIGHT = '2016-2021 © Route4Me Python Team'
17-
AUTHOR = 'Route4Me Python Team (SDK)'
18-
AUTHOR_EMAIL = '[email protected]'
19-
TITLE = 'route4me'
20-
LICENSE = 'ISC'
21-
BUILD = None # TRAVIS_COMMIT
15+
PROJECT = "Route4Me Python SDK"
16+
COPYRIGHT = "2016-2021 © Route4Me Python Team"
17+
AUTHOR = "Route4Me Python Team (SDK)"
18+
AUTHOR_EMAIL = "[email protected]"
19+
TITLE = "route4me"
20+
LICENSE = "ISC"
21+
BUILD = None # TRAVIS_COMMIT
2222
COMMIT = None # TRAVIS_BUILD_NUMBER

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]
Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# Route4Me Java SDK
2-
3-
[![Build Status](https://travis-ci.org/route4me/route4me-java-sdk.svg?branch=master)](https://travis-ci.org/route4me/route4me-java-sdk)
4-
[![codebeat badge](https://codebeat.co/badges/088f1145-147e-438e-aa03-9fc5323ff235)](https://codebeat.co/projects/github-com-route4me-route4me-java-sdk)
5-
1+
# Route4Me Python SDK
62

73
## Examples Description:
84

@@ -16,7 +12,7 @@ TEST CASE: Some addresses without Tags
1612

1713
### AdvancedConstraints3
1814

19-
TEST CASE: Driver's Shift
15+
TEST CASE: Driver's Shift
2016

2117
### AdvancedConstraints4
2218

@@ -26,39 +22,39 @@ TEST CASE: Driver's Skills
2622

2723
TEST CASE: Drivers Schedules with Territories
2824

29-
- 10 Drivers
30-
- 3 Schedules
31-
- 3 Territories
25+
- 10 Drivers
26+
- 3 Schedules
27+
- 3 Territories
3228

3329
### AdvancedConstraints6
3430

3531
TEST CASE: Drivers Schedules with Territories
3632

37-
- 2000 stops
38-
- 30 Schedules
39-
- 3 Territories
33+
- 2000 stops
34+
- 30 Schedules
35+
- 3 Territories
4036

4137
### AdvancedConstraints7
4238

43-
TEST CASE: Drivers Schedules with Territories
39+
TEST CASE: Drivers Schedules with Territories
4440

45-
- 2000 stops
46-
- 30 Schedules
47-
- 5 Territories
41+
- 2000 stops
42+
- 30 Schedules
43+
- 5 Territories
4844

4945
### AdvancedConstraints8
5046

5147
TEST CASE: Drivers Schedules with Territories
5248

53-
- 2000 Stops
54-
- 50 Drivers
55-
- 50 Schedules
49+
- 2000 Stops
50+
- 50 Drivers
51+
- 50 Schedules
5652

5753
### AdvancedConstraints9
5854

5955
TEST CASE: Retail Location based of address position id
6056

61-
- Depots Section
57+
- Depots Section
6258

6359
### AdvancedConstraints10
6460

@@ -72,14 +68,14 @@ TEST CASE: Retail Location - setting the address in the advanced constraints
7268

7369
TEST CASE: Drivers Schedules with Territories and Retail Location
7470

75-
- 2000 Stops
76-
- 30 Schedules
77-
- 3 Territories
78-
- Retail Location
71+
- 2000 Stops
72+
- 30 Schedules
73+
- 3 Territories
74+
- Retail Location
7975

8076
### AdvancedConstraints13
8177

8278
TEST CASE: Drivers Schedules with Address from Territories created in Route4Me
8379

84-
- 3 Territories
85-
- 3 Schedules
80+
- 3 Territories
81+
- 3 Schedules

examples/order/create_order.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,35 @@ def main(api_key):
1212
order = route4me.order
1313
url = "http://www.bk.com/restaurants/ny/new-york/106-fulton-st-17871.html"
1414
data = {
15-
'address_1': '106 Fulton St, Farmingdale, NY 11735, USA',
16-
'cached_lat': 40.730730,
17-
'cached_lng': -73.459283,
18-
'address_alias': 'BK Restaurant #: 17871',
19-
'EXT_FIELD_phone': '(212) 566-5132',
20-
'day_scheduled_for_YYMMDD': '2016-07-01',
21-
'EXT_FIELD_custom_data': {
22-
'url': url
23-
}
15+
"address_1": "106 Fulton St, Farmingdale, NY 11735, USA",
16+
"cached_lat": 40.730730,
17+
"cached_lng": -73.459283,
18+
"address_alias": "BK Restaurant #: 17871",
19+
"EXT_FIELD_phone": "(212) 566-5132",
20+
"day_scheduled_for_YYMMDD": "2016-07-01",
21+
"EXT_FIELD_custom_data": {"url": url},
2422
}
2523
response = order.create_order(**data)
26-
if isinstance(response, dict) and 'errors' in response.keys():
27-
print('. '.join(response['errors']))
24+
if isinstance(response, dict) and "errors" in response.keys():
25+
print(". ".join(response["errors"]))
2826
else:
29-
print('Member ID:\t{0}'.format(response.get('member_id')))
30-
print('Order ID:\t{0}'.format(response.get('order_id')))
31-
print('Order Status ID:\t{0}'.format(response.get('order_status_id')))
32-
print('In Route Count:\t{0}'.format(response.get('in_route_count')))
33-
print('Day Added:\t{0}'.format(response.get('day_added_YYMMDD')))
34-
print('Is Pending:\t{0}'.format(response.get('is_pending')))
35-
print('Is Accepted:\t{0}'.format(response.get('is_accepted')))
36-
print('Is Started:\t{0}'.format(response.get('is_started')))
37-
print('Is Validated:\t{0}'.format(response.get('is_validated')))
38-
print('Is Completed:\t{0}'.format(response.get('is_completed')))
39-
40-
41-
if __name__ == '__main__':
42-
parser = argparse.ArgumentParser(description='Create an Order')
43-
parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY',
44-
type=str, required=True)
27+
print("Member ID:\t{0}".format(response.get("member_id")))
28+
print("Order ID:\t{0}".format(response.get("order_id")))
29+
print("Order Status ID:\t{0}".format(response.get("order_status_id")))
30+
print("In Route Count:\t{0}".format(response.get("in_route_count")))
31+
print("Day Added:\t{0}".format(response.get("day_added_YYMMDD")))
32+
print("Is Pending:\t{0}".format(response.get("is_pending")))
33+
print("Is Accepted:\t{0}".format(response.get("is_accepted")))
34+
print("Is Started:\t{0}".format(response.get("is_started")))
35+
print("Is Validated:\t{0}".format(response.get("is_validated")))
36+
print("Is Completed:\t{0}".format(response.get("is_completed")))
37+
38+
39+
if __name__ == "__main__":
40+
parser = argparse.ArgumentParser(description="Create an Order")
41+
parser.add_argument(
42+
"--api_key", dest="api_key", help="Route4Me API KEY", type=str, required=True
43+
)
4544
args = parser.parse_args()
4645
main(args.api_key)
4746

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# codebeat:disable[ABC]
3+
4+
import argparse
5+
6+
from route4me import Route4Me
7+
8+
9+
def main(api_key):
10+
r4m = Route4Me(api_key)
11+
orders_groups = r4m.orders_group
12+
13+
group_id = "ACE8FFFFFFFFFFFFFCCCCCCCCCCCCC"
14+
optimization_profile_id = "00000000-1111-1111-1111-000000000000"
15+
data = orders_groups.assign_optimization_profile(optimization_profile_id, group_id)
16+
print(data)
17+
18+
19+
if __name__ == "__main__":
20+
parser = argparse.ArgumentParser(description="Assign Optimization Profile")
21+
parser.add_argument(
22+
"--api_key", dest="api_key", help="Route4Me API KEY", type=str, required=True
23+
)
24+
args = parser.parse_args()
25+
main(args.api_key)
26+
27+
# codebeat:enable[ABC]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
# codebeat:disable[ABC]
3+
4+
import argparse
5+
6+
from route4me import Route4Me
7+
8+
9+
def main(api_key):
10+
r4m = Route4Me(api_key)
11+
optimization_profiles = r4m.optimization_profiles
12+
13+
print("\nGetting Optimization Profiles:\n")
14+
profiles = optimization_profiles.get_optimization_profiles()
15+
16+
for profile in profiles.get("items", []):
17+
print(
18+
" - ".join(
19+
[
20+
f"ID: {profile['optimization_profile_id']}",
21+
f"ProfileName: {profile['profile_name']}",
22+
f"isDefault: {profile['is_default']}",
23+
]
24+
)
25+
)
26+
27+
28+
if __name__ == "__main__":
29+
parser = argparse.ArgumentParser(description="Get Optimizations Profile")
30+
parser.add_argument(
31+
"--api_key", dest="api_key", help="Route4Me API KEY", type=str, required=True
32+
)
33+
args = parser.parse_args()
34+
main(args.api_key)
35+
36+
# codebeat:enable[ABC]

0 commit comments

Comments
 (0)