Skip to content

Commit

Permalink
Merge pull request #28 from route4me/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
r4m-juan authored Jun 10, 2024
2 parents ad2be75 + de31000 commit 4f3ed03
Show file tree
Hide file tree
Showing 53 changed files with 2,003 additions and 1,030 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Route4Me_SDK.egg-info/
.venv
docs/html/*
.tox
.DS_Store
20 changes: 10 additions & 10 deletions VERSION.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
# VERSION.py - MAINTAINER's. Don't edit, if you don't know what are you doing
# ==============================================================================

VERSION = (0, 1, 5, 1)
RELEASE_SUFFIX = ''
VERSION = (0, 1, 6, 0)
RELEASE_SUFFIX = ""

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

PROJECT = 'Route4Me Python SDK'
COPYRIGHT = '2016-2021 © Route4Me Python Team'
AUTHOR = 'Route4Me Python Team (SDK)'
AUTHOR_EMAIL = '[email protected]'
TITLE = 'route4me'
LICENSE = 'ISC'
BUILD = None # TRAVIS_COMMIT
PROJECT = "Route4Me Python SDK"
COPYRIGHT = "2016-2021 © Route4Me Python Team"
AUTHOR = "Route4Me Python Team (SDK)"
AUTHOR_EMAIL = "[email protected]"
TITLE = "route4me"
LICENSE = "ISC"
BUILD = None # TRAVIS_COMMIT
COMMIT = None # TRAVIS_BUILD_NUMBER
14 changes: 9 additions & 5 deletions examples/addresses/add_route_destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@ def main(api_key):
print('Inserting addresses in Route: {}'.format(route_id))

response = r4m.route.insert_address_into_route(addresses, route_id)
print('Addresses after insert')
for i, address in enumerate(response['addresses']):
print('Number {}:'.format(i))
print('\taddress: {}'.format(address['address']))
print('\t')

if isinstance(response, dict) and 'errors' in response.keys():
print('. '.join(response['errors']))
else:
print('Addresses after insert')
for i, address in enumerate(response['addresses']):
print('Number {}:'.format(i))
print('\taddress: {}'.format(address['address']))
print('\t')


# codebeat:enable[LOC, ABC]
Expand Down
73 changes: 40 additions & 33 deletions examples/addresses/add_route_destinations_into_specific_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,42 +83,49 @@ def main(api_key):

response = r4m.run_optimization()

print('Current Addresses')
for i, address in enumerate(response['addresses']):
print('Number {}:'.format(i))
print('\taddress: {}'.format(address['address']))
print('\t')
addresses = {
'addresses': [
{
'address': '555 W 57th St New York, NY 10019',
'lat': 40.7718005,
'lng': -73.9897716,
'alias': 'BMW of Manhattan',
'sequence_no': 2,
'time': 300,
},
{
'address': '57 W 57th St New York, NY 10019',
'lat': 40.7558695,
'lng': -73.9862019,
'alias': 'Verizon Wireless',
'sequence_no': 5,
'time': 300,
}
]
}
if isinstance(response, dict) and 'errors' in response.keys():
print('. '.join(response['errors']))
else:
print('Current Addresses')
for i, address in enumerate(response['addresses']):
print('Number {}:'.format(i))
print('\taddress: {}'.format(address['address']))
print('\t')
addresses = {
'addresses': [
{
'address': '555 W 57th St New York, NY 10019',
'lat': 40.7718005,
'lng': -73.9897716,
'alias': 'BMW of Manhattan',
'sequence_no': 2,
'time': 300,
},
{
'address': '57 W 57th St New York, NY 10019',
'lat': 40.7558695,
'lng': -73.9862019,
'alias': 'Verizon Wireless',
'sequence_no': 5,
'time': 300,
}
]
}

route_id = response['addresses'][1]['route_id']
route_id = response['addresses'][1]['route_id']

print('Inserting addresses in Route: {}'.format(route_id))
print('Inserting addresses in Route: {}'.format(route_id))

response = r4m.route.insert_address_into_route(addresses, route_id)
print('Addresses after insert')
for i, address in enumerate(response['addresses']):
print('Number {}:'.format(i))
print('\taddress: {}'.format(address['address']))
print('\t')
response = r4m.route.insert_address_into_route(addresses, route_id)

if isinstance(response, dict) and 'errors' in response.keys():
print('. '.join(response['errors']))
else:
print('Addresses after insert')
for i, address in enumerate(response['addresses']):
print('Number {}:'.format(i))
print('\taddress: {}'.format(address['address']))
print('\t')


# codebeat:enable[LOC, ABC]
Expand Down
15 changes: 9 additions & 6 deletions examples/addresses/move_destination_to_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,15 @@ def main(api_key):
response = r4m.route.move_addresses_from_route(addresses, route_id)
print('Addresses after move')

for i, address in enumerate(response['addresses']):
print('Number {}:'.format(i))
if address['is_depot']:
print('\t This is a Depot')
print('\taddress: {}'.format(address['address']))
print('\t')
if isinstance(response, dict) and 'errors' in response.keys():
print('. '.join(response['errors']))
else:
for i, address in enumerate(response['addresses']):
print('Number {}:'.format(i))
if address['is_depot']:
print('\t This is a Depot')
print('\taddress: {}'.format(address['address']))
print('\t')


# codebeat:enable[LOC, ABC]
Expand Down
48 changes: 22 additions & 26 deletions examples/advanced_constraints/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Route4Me Java SDK

[![Build Status](https://travis-ci.org/route4me/route4me-java-sdk.svg?branch=master)](https://travis-ci.org/route4me/route4me-java-sdk)
[![codebeat badge](https://codebeat.co/badges/088f1145-147e-438e-aa03-9fc5323ff235)](https://codebeat.co/projects/github-com-route4me-route4me-java-sdk)

# Route4Me Python SDK

## Examples Description:

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

### AdvancedConstraints3

TEST CASE: Driver's Shift
TEST CASE: Driver's Shift

### AdvancedConstraints4

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

TEST CASE: Drivers Schedules with Territories

- 10 Drivers
- 3 Schedules
- 3 Territories
- 10 Drivers
- 3 Schedules
- 3 Territories

### AdvancedConstraints6

TEST CASE: Drivers Schedules with Territories

- 2000 stops
- 30 Schedules
- 3 Territories
- 2000 stops
- 30 Schedules
- 3 Territories

### AdvancedConstraints7

TEST CASE: Drivers Schedules with Territories
TEST CASE: Drivers Schedules with Territories

- 2000 stops
- 30 Schedules
- 5 Territories
- 2000 stops
- 30 Schedules
- 5 Territories

### AdvancedConstraints8

TEST CASE: Drivers Schedules with Territories

- 2000 Stops
- 50 Drivers
- 50 Schedules
- 2000 Stops
- 50 Drivers
- 50 Schedules

### AdvancedConstraints9

TEST CASE: Retail Location based of address position id

- Depots Section
- Depots Section

### AdvancedConstraints10

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

TEST CASE: Drivers Schedules with Territories and Retail Location

- 2000 Stops
- 30 Schedules
- 3 Territories
- Retail Location
- 2000 Stops
- 30 Schedules
- 3 Territories
- Retail Location

### AdvancedConstraints13

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

- 3 Territories
- 3 Schedules
- 3 Territories
- 3 Schedules
53 changes: 26 additions & 27 deletions examples/order/create_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,35 @@ def main(api_key):
order = route4me.order
url = "http://www.bk.com/restaurants/ny/new-york/106-fulton-st-17871.html"
data = {
'address_1': '106 Fulton St, Farmingdale, NY 11735, USA',
'cached_lat': 40.730730,
'cached_lng': -73.459283,
'address_alias': 'BK Restaurant #: 17871',
'EXT_FIELD_phone': '(212) 566-5132',
'day_scheduled_for_YYMMDD': '2016-07-01',
'EXT_FIELD_custom_data': {
'url': url
}
"address_1": "106 Fulton St, Farmingdale, NY 11735, USA",
"cached_lat": 40.730730,
"cached_lng": -73.459283,
"address_alias": "BK Restaurant #: 17871",
"EXT_FIELD_phone": "(212) 566-5132",
"day_scheduled_for_YYMMDD": "2016-07-01",
"EXT_FIELD_custom_data": {"url": url},
}
response = order.create_order(**data)
if isinstance(response, dict) and 'errors' in response.keys():
print('. '.join(response['errors']))
if isinstance(response, dict) and "errors" in response.keys():
print(". ".join(response["errors"]))
else:
print('Member ID:\t{0}'.format(response.get('member_id')))
print('Order ID:\t{0}'.format(response.get('order_id')))
print('Order Status ID:\t{0}'.format(response.get('order_status_id')))
print('In Route Count:\t{0}'.format(response.get('in_route_count')))
print('Day Added:\t{0}'.format(response.get('day_added_YYMMDD')))
print('Is Pending:\t{0}'.format(response.get('is_pending')))
print('Is Accepted:\t{0}'.format(response.get('is_accepted')))
print('Is Started:\t{0}'.format(response.get('is_started')))
print('Is Validated:\t{0}'.format(response.get('is_validated')))
print('Is Completed:\t{0}'.format(response.get('is_completed')))


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Create an Order')
parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY',
type=str, required=True)
print("Member ID:\t{0}".format(response.get("member_id")))
print("Order ID:\t{0}".format(response.get("order_id")))
print("Order Status ID:\t{0}".format(response.get("order_status_id")))
print("In Route Count:\t{0}".format(response.get("in_route_count")))
print("Day Added:\t{0}".format(response.get("day_added_YYMMDD")))
print("Is Pending:\t{0}".format(response.get("is_pending")))
print("Is Accepted:\t{0}".format(response.get("is_accepted")))
print("Is Started:\t{0}".format(response.get("is_started")))
print("Is Validated:\t{0}".format(response.get("is_validated")))
print("Is Completed:\t{0}".format(response.get("is_completed")))


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Create an Order")
parser.add_argument(
"--api_key", dest="api_key", help="Route4Me API KEY", type=str, required=True
)
args = parser.parse_args()
main(args.api_key)

Expand Down
27 changes: 27 additions & 0 deletions examples/orders_group/assign_optimization_profile_to_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# codebeat:disable[ABC]

import argparse

from route4me import Route4Me


def main(api_key):
r4m = Route4Me(api_key)
orders_groups = r4m.orders_group

group_id = "ACE8FFFFFFFFFFFFFCCCCCCCCCCCCC"
optimization_profile_id = "00000000-1111-1111-1111-000000000000"
data = orders_groups.assign_optimization_profile(optimization_profile_id, group_id)
print(data)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Assign Optimization Profile")
parser.add_argument(
"--api_key", dest="api_key", help="Route4Me API KEY", type=str, required=True
)
args = parser.parse_args()
main(args.api_key)

# codebeat:enable[ABC]
36 changes: 36 additions & 0 deletions examples/orders_group/get_optimization_profiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# codebeat:disable[ABC]

import argparse

from route4me import Route4Me


def main(api_key):
r4m = Route4Me(api_key)
optimization_profiles = r4m.optimization_profiles

print("\nGetting Optimization Profiles:\n")
profiles = optimization_profiles.get_optimization_profiles()

for profile in profiles.get("items", []):
print(
" - ".join(
[
f"ID: {profile['optimization_profile_id']}",
f"ProfileName: {profile['profile_name']}",
f"isDefault: {profile['is_default']}",
]
)
)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Get Optimizations Profile")
parser.add_argument(
"--api_key", dest="api_key", help="Route4Me API KEY", type=str, required=True
)
args = parser.parse_args()
main(args.api_key)

# codebeat:enable[ABC]
Loading

0 comments on commit 4f3ed03

Please sign in to comment.