From 4e2a8af3826703b554347926fa4e4e30004e9fcb Mon Sep 17 00:00:00 2001 From: Juan Pimentel Date: Mon, 18 Apr 2022 22:32:26 -0500 Subject: [PATCH] Removed API_KEY from Examples. Added Pickup/Dropoff and Insert Locations Examples --- examples/activities/get_activities.py | 12 +- examples/activity_feed/get_activities_feed.py | 14 +- .../get_activities_feed_by_type.py | 16 +- .../get_activity_feed_deleted.py | 12 +- .../get_activity_feed_inserted.py | 14 +- .../get_activity_feed_route_owner_changed.py | 14 +- .../activity_feed/log_specific_message.py | 13 +- .../addressbook/add_addressbook_contact.py | 13 +- .../addressbook/delete_addressbook_contact.py | 13 +- .../addressbook/get_addressbook_contact.py | 13 +- .../addressbook/get_addressbook_contacts.py | 13 +- ...specified_field_contains_specified_text.py | 12 +- .../addressbook/update_addressbook_contact.py | 12 +- .../addresses/add_address_to_optimization.py | 14 +- examples/addresses/add_route_destinations.py | 18 +- ...ute_destinations_into_specific_position.py | 131 ++++++++++++ examples/addresses/get_address.py | 13 +- ...ert_address_into_route_optimal_position.py | 12 +- .../addresses/move_destination_to_route.py | 16 +- .../addresses/remove_route_destination.py | 19 +- .../addresses/update_address_attributes.py | 18 +- .../advanced_constraint_test_case_1.py | 14 +- .../advanced_constraint_test_case_2.py | 14 +- .../advanced_constraint_test_case_3.py | 14 +- .../add_avoidance_zone_circular_shape.py | 14 +- .../add_avoidance_zone_polygon_shape.py | 14 +- .../add_avoidance_zone_rectangular_shape.py | 14 +- .../avoidance_zones/delete_avoidance_zone.py | 14 +- .../avoidance_zones/get_avoidance_zone.py | 14 +- .../avoidance_zones/get_avoidance_zones.py | 13 +- .../avoidance_zones/update_avoidance_zone.py | 14 +- examples/bundling/bundling_by_address.py | 15 +- examples/bundling/bundling_by_coordinates.py | 15 +- examples/file_uploading/get_file_preview.py | 14 +- examples/file_uploading/upload_file.py | 15 +- .../file_uploading/upload_file_geocode.py | 13 +- examples/file_uploading/upload_file_xlsx.py | 14 +- examples/generic_example.py | 14 +- examples/geocoding/forward_geocoding.py | 13 +- examples/geocoding/geocoding.py | 13 +- examples/geocoding/reverse_geocoding.py | 13 +- examples/members/app_purchase_user_license.py | 13 +- examples/members/get_users.py | 13 +- examples/members/member_authenticate.py | 13 +- examples/members/register_action.py | 13 +- examples/members/validate_session.py | 12 +- examples/members/verify_user_license.py | 12 +- examples/members/webinar_registration.py | 13 +- examples/multiple_depot_multiple_driver.py | 16 +- ...tiple_depot_multiple_driver_time_window.py | 16 +- ...ltiple_driver_with_24_stops_time_window.py | 15 +- examples/notes/add_address_notes.py | 13 +- examples/notes/get_address_notes.py | 12 +- examples/optimizations/create_optimization.py | 14 +- .../delete_address_from_optimization.py | 15 +- examples/optimizations/delete_optimization.py | 16 +- examples/optimizations/get_optimization.py | 13 +- examples/optimizations/get_optimizations.py | 13 +- examples/optimizations/optimized_callback.py | 17 +- examples/optimizations/re_optimization.py | 14 +- examples/order/create_order.py | 14 +- examples/order/delete_order.py | 14 +- examples/order/get_order.py | 14 +- examples/order/update_order.py | 14 +- examples/pickup_dropoff/pickup_dropoff.py | 128 ++++++++++++ .../pickup_dropoff_with_capacity.py | 196 ++++++++++++++++++ examples/rapid_address/get_street_data.py | 14 +- .../get_street_data_get_single.py | 13 +- .../get_street_data_offset_limit.py | 15 +- .../rapid_address/get_street_data_service.py | 15 +- .../get_street_data_service_offset_limit.py | 16 +- examples/rapid_address/get_street_data_zip.py | 14 +- .../get_street_data_zip_offset_limit.py | 15 +- examples/routes/delete_route.py | 12 +- examples/routes/delete_routes.py | 13 +- examples/routes/duplicate_route.py | 13 +- examples/routes/export_route_v5.py | 2 + examples/routes/get_route.py | 13 +- examples/routes/get_route_directions.py | 13 +- examples/routes/get_route_path_points.py | 13 +- examples/routes/get_route_tracking.py | 12 +- examples/routes/get_routes.py | 12 +- examples/routes/merge_routes.py | 12 +- examples/routes/resequence_multiple_stops.py | 3 +- examples/routes/resequence_route.py | 12 +- examples/routes/resequence_route_all.py | 12 +- examples/routes/routes_manifest.py | 13 +- examples/routes/share_route.py | 13 +- examples/routes/update_route.py | 16 +- .../update_route_destination_custom_data.py | 13 +- examples/routes/update_route_parameters.py | 14 +- examples/single_depot_multiple_driver.py | 14 +- ...ingle_depot_multiple_driver_time_window.py | 16 +- examples/single_driver_round_trip.py | 15 +- ...ingle_driver_round_trip_redirects_false.py | 16 +- ...single_driver_round_trip_reoptimization.py | 18 +- examples/single_driver_route_10_stops.py | 16 +- examples/telematics/compare_vendors.py | 2 + .../telematics/delete_vendor_connection.py | 1 + examples/telematics/get_connections.py | 2 + examples/telematics/get_vendor.py | 3 +- examples/telematics/get_vendor_connection.py | 1 + examples/telematics/get_vendors.py | 1 + .../telematics/get_vendors_connection_info.py | 2 + examples/telematics/register_member.py | 2 + .../telematics/register_vendor_connection.py | 3 + examples/telematics/search_vendor.py | 2 + .../telematics/update_vendor_connection.py | 2 + examples/territory/add_territory.py | 14 +- examples/territory/delete_territory.py | 14 +- examples/territory/get_territories.py | 14 +- examples/territory/get_territory.py | 14 +- examples/territory/update_territory.py | 14 +- examples/tracking/set_gps_example.py | 15 +- .../track_device_last_location_history.py | 12 +- examples/vehicles/get_vehicles.py | 12 +- route4me/address.py | 2 +- route4me/constants.py | 10 +- 118 files changed, 1444 insertions(+), 439 deletions(-) create mode 100644 examples/addresses/add_route_destinations_into_specific_position.py rename examples/{routes => addresses}/insert_address_into_route_optimal_position.py (83%) create mode 100644 examples/pickup_dropoff/pickup_dropoff.py create mode 100644 examples/pickup_dropoff/pickup_dropoff_with_capacity.py diff --git a/examples/activities/get_activities.py b/examples/activities/get_activities.py index bc6ebd7..fc76417 100644 --- a/examples/activities/get_activities.py +++ b/examples/activities/get_activities.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) route = route4me.route print('Getting Last Route') response = route.get_routes(limit=1, offset=0) @@ -35,4 +35,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Activities') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/activity_feed/get_activities_feed.py b/examples/activity_feed/get_activities_feed.py index 50d5452..a24fd84 100644 --- a/examples/activity_feed/get_activities_feed.py +++ b/examples/activity_feed/get_activities_feed.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) activity_feed = route4me.activity_feed response = activity_feed.get_activities_feed(limit=10, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -23,5 +24,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Activities Feed') + 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[SIMILARITY] diff --git a/examples/activity_feed/get_activities_feed_by_type.py b/examples/activity_feed/get_activities_feed_by_type.py index 4e74d91..a227ea4 100644 --- a/examples/activity_feed/get_activities_feed_by_type.py +++ b/examples/activity_feed/get_activities_feed_by_type.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] -from route4me import Route4Me +import argparse -API_KEY = "11111111111111111111111111111111" +from route4me import Route4Me ACTIVITY_TYPE = ( 'delete-destination', @@ -37,8 +37,9 @@ ) -def main(): - route4me = Route4Me(API_KEY) +def main(api_key): + route4me = Route4Me(api_key) + activity_feed = route4me.activity_feed for activity_type in ACTIVITY_TYPE: response = activity_feed.get_activities_feed_by_type( @@ -62,5 +63,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Activities Feed by Type') + 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[SIMILARITY] diff --git a/examples/activity_feed/get_activity_feed_deleted.py b/examples/activity_feed/get_activity_feed_deleted.py index 26acab3..9a5328a 100644 --- a/examples/activity_feed/get_activity_feed_deleted.py +++ b/examples/activity_feed/get_activity_feed_deleted.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) activity_feed = route4me.activity_feed route = route4me.route print('Getting Last Route') @@ -30,4 +30,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Deleted Destination Activities') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/activity_feed/get_activity_feed_inserted.py b/examples/activity_feed/get_activity_feed_inserted.py index 4cafc69..8c14517 100644 --- a/examples/activity_feed/get_activity_feed_inserted.py +++ b/examples/activity_feed/get_activity_feed_inserted.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) activity_feed = route4me.activity_feed route = route4me.route print('Getting Last Route') @@ -31,5 +32,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Inserted Destination Activities') + 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[SIMILARITY] diff --git a/examples/activity_feed/get_activity_feed_route_owner_changed.py b/examples/activity_feed/get_activity_feed_route_owner_changed.py index 3767b21..9e71752 100644 --- a/examples/activity_feed/get_activity_feed_route_owner_changed.py +++ b/examples/activity_feed/get_activity_feed_route_owner_changed.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) activity_feed = route4me.activity_feed route = route4me.route print('Getting Last Route') @@ -31,5 +32,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Route Owner Changed Activity') + 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[SIMILARITY] diff --git a/examples/activity_feed/log_specific_message.py b/examples/activity_feed/log_specific_message.py index eb14576..049ece8 100644 --- a/examples/activity_feed/log_specific_message.py +++ b/examples/activity_feed/log_specific_message.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) activity_feed = route4me.activity_feed route = route4me.route print('Getting Last Route') @@ -27,4 +28,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Log Specific Message') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addressbook/add_addressbook_contact.py b/examples/addressbook/add_addressbook_contact.py index 820f6f6..103d302 100644 --- a/examples/addressbook/add_addressbook_contact.py +++ b/examples/addressbook/add_addressbook_contact.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) address_book = route4me.address_book response = address_book.create_contact( first_name="Juan", @@ -22,4 +23,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Add AddressBook Contact') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addressbook/delete_addressbook_contact.py b/examples/addressbook/delete_addressbook_contact.py index f19c05c..27de2c3 100644 --- a/examples/addressbook/delete_addressbook_contact.py +++ b/examples/addressbook/delete_addressbook_contact.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) address_book = route4me.address_book response = address_book.create_contact( first_name="Juan", @@ -33,4 +34,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Delete Address Book Contact') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addressbook/get_addressbook_contact.py b/examples/addressbook/get_addressbook_contact.py index a2f763d..fbc665e 100644 --- a/examples/addressbook/get_addressbook_contact.py +++ b/examples/addressbook/get_addressbook_contact.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) address_book = route4me.address_book response = address_book.get_addressbook_contacts(limit=10, offset=5) if isinstance(response, dict) and 'errors' in response.keys(): @@ -27,4 +28,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Address Book Contact') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addressbook/get_addressbook_contacts.py b/examples/addressbook/get_addressbook_contacts.py index b76d106..4a72679 100644 --- a/examples/addressbook/get_addressbook_contacts.py +++ b/examples/addressbook/get_addressbook_contacts.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) address_book = route4me.address_book response = address_book.get_addressbook_contacts(limit=10, Offset=5) if 'errors' in response.keys(): @@ -22,4 +23,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Address Book Contacts') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addressbook/get_specified_field_contains_specified_text.py b/examples/addressbook/get_specified_field_contains_specified_text.py index f32a7c1..5eb3884 100644 --- a/examples/addressbook/get_specified_field_contains_specified_text.py +++ b/examples/addressbook/get_specified_field_contains_specified_text.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) address_book = route4me.address_book print('Searching "Juan" in Addressbook') response = address_book.get_addressbook_contacts( @@ -20,4 +20,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Search Contact by Field and Value') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addressbook/update_addressbook_contact.py b/examples/addressbook/update_addressbook_contact.py index 8ee2d37..0df3735 100644 --- a/examples/addressbook/update_addressbook_contact.py +++ b/examples/addressbook/update_addressbook_contact.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) address_book = route4me.address_book response = address_book.get_addressbook_contacts(limit=10, offset=5) if 'errors' in response.keys(): @@ -30,4 +30,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Update Address Book Contact') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addresses/add_address_to_optimization.py b/examples/addresses/add_address_to_optimization.py index 8079629..8000d09 100644 --- a/examples/addresses/add_address_to_optimization.py +++ b/examples/addresses/add_address_to_optimization.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[LOC, ABC, BLOCK_NESTING] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization response = optimization.get_optimizations(limit=10, offset=5) if isinstance(response, dict) and 'errors' in response.keys(): @@ -69,5 +70,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Add address to Optimization') + 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[LOC, ABC, BLOCK_NESTING] diff --git a/examples/addresses/add_route_destinations.py b/examples/addresses/add_route_destinations.py index c1ceffb..69d0337 100644 --- a/examples/addresses/add_route_destinations.py +++ b/examples/addresses/add_route_destinations.py @@ -1,6 +1,10 @@ # -*- coding: utf-8 -*- +# codebeat:disable[LOC, ABC] + +import argparse from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,14 +13,10 @@ TRAVEL_MODE, ) -API_KEY = "11111111111111111111111111111111" - - -# codebeat:disable[LOC, ABC] +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) optimization = r4m.optimization address = r4m.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -122,4 +122,8 @@ def main(): # codebeat:enable[LOC, ABC] if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Insert an address to an existing route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addresses/add_route_destinations_into_specific_position.py b/examples/addresses/add_route_destinations_into_specific_position.py new file mode 100644 index 0000000..700b074 --- /dev/null +++ b/examples/addresses/add_route_destinations_into_specific_position.py @@ -0,0 +1,131 @@ +# -*- coding: utf-8 -*- +# codebeat:disable[LOC, ABC] + +import argparse + +from route4me import Route4Me + +from route4me.constants import ( + ALGORITHM_TYPE, + OPTIMIZE, + DISTANCE_UNIT, + DEVICE_TYPE, + TRAVEL_MODE, +) + + +def main(api_key): + r4m = Route4Me(api_key) + + optimization = r4m.optimization + address = r4m.address + optimization.algorithm_type(ALGORITHM_TYPE.TSP) + optimization.share_route(0) + optimization.store_route(0) + optimization.route_time(0) + optimization.route_max_duration(86400) + optimization.vehicle_max_distance_mi(10000) + optimization.route_name('Single Driver Round Trip') + optimization.optimize(OPTIMIZE.DISTANCE) + optimization.distance_unit(DISTANCE_UNIT.MI) + optimization.device_type(DEVICE_TYPE.WEB) + optimization.travel_mode(TRAVEL_MODE.DRIVING) + address.add_address( + address='754 5th Ave New York, NY 10019', + lat=40.7636197, + lng=-73.9744388, + alias='Bergdorf Goodman', + is_depot=1, + time=0 + ) + address.add_address( + address='717 5th Ave New York, NY 10022', + lat=40.7669692, + lng=-73.9693864, + alias='Giorgio Armani', + time=0 + ) + address.add_address( + address='888 Madison Ave New York, NY 10014', + lat=40.7715154, + lng=-73.9669241, + alias='Ralph Lauren Women\'s and Home', + time=0 + ) + address.add_address( + address='1011 Madison Ave New York, NY 10075', + lat=40.7772129, + lng=-73.9669, + alias='Yigal Azrou\u00ebl', + time=0 + ) + address.add_address( + address='440 Columbus Ave New York, NY 10024', + lat=40.7808364, + lng=-73.9732729, + alias='Frank Stella Clothier', + time=0 + ) + address.add_address( + address='324 Columbus Ave #1 New York, NY 10023', + lat=40.7803123, + lng=-73.9793079, + alias='Liana', + time=0 + ) + address.add_address( + address='110 W End Ave New York, NY 10023', + lat=40.7753077, + lng=-73.9861529, + alias='Toga Bike Shop', + time=0 + ) + + 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, + } + ] + } + + route_id = response['addresses'][1]['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') + + +# codebeat:enable[LOC, ABC] + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Insert an address to an existing route into specific position') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addresses/get_address.py b/examples/addresses/get_address.py index da24d37..de293e7 100644 --- a/examples/addresses/get_address.py +++ b/examples/addresses/get_address.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) route = route4me.route response = route.get_routes(limit=10, offset=5) if isinstance(response, dict) and 'errors' in response.keys(): @@ -28,4 +29,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get an Address from a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/insert_address_into_route_optimal_position.py b/examples/addresses/insert_address_into_route_optimal_position.py similarity index 83% rename from examples/routes/insert_address_into_route_optimal_position.py rename to examples/addresses/insert_address_into_route_optimal_position.py index d1aafeb..20e6cc3 100644 --- a/examples/routes/insert_address_into_route_optimal_position.py +++ b/examples/addresses/insert_address_into_route_optimal_position.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -47,4 +47,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Insert an address into a Route at Optimal Position') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addresses/move_destination_to_route.py b/examples/addresses/move_destination_to_route.py index 1c050c1..b161d89 100644 --- a/examples/addresses/move_destination_to_route.py +++ b/examples/addresses/move_destination_to_route.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,14 +12,13 @@ TRAVEL_MODE, ) -API_KEY = "11111111111111111111111111111111" - # codebeat:disable[LOC, ABC] -def main(): - r4m = Route4Me(API_KEY) +def main(api_key): + r4m = Route4Me(api_key) + optimization = r4m.optimization address = r4m.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -136,4 +138,8 @@ def main(): # codebeat:enable[LOC, ABC] if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Move a Destination to other Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addresses/remove_route_destination.py b/examples/addresses/remove_route_destination.py index b4d9db0..ca2f6a8 100644 --- a/examples/addresses/remove_route_destination.py +++ b/examples/addresses/remove_route_destination.py @@ -1,6 +1,10 @@ # -*- coding: utf-8 -*- +# codebeat:disable[LOC, ABC] + +import argparse from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,14 +13,9 @@ TRAVEL_MODE, ) -API_KEY = "11111111111111111111111111111111" - - -# codebeat:disable[LOC, ABC] - -def main(): - r4m = Route4Me(API_KEY) +def main(api_key): + r4m = Route4Me(api_key) optimization = r4m.optimization address = r4m.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -104,4 +103,8 @@ def main(): # codebeat:enable[LOC, ABC] if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Remove Destination From a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/addresses/update_address_attributes.py b/examples/addresses/update_address_attributes.py index c3d2a4e..af55135 100644 --- a/examples/addresses/update_address_attributes.py +++ b/examples/addresses/update_address_attributes.py @@ -1,6 +1,10 @@ # -*- coding: utf-8 -*- +# codebeat:disable[LOC, ABC] + +import argparse from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,14 +13,10 @@ TRAVEL_MODE ) -API_KEY = "11111111111111111111111111111111" - - -# codebeat:disable[LOC, ABC] +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) optimization = r4m.optimization address = r4m.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -124,4 +124,8 @@ def main(): # codebeat:enable[LOC, ABC] if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Update Address Attributes of a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/advanced_constraints/advanced_constraint_test_case_1.py b/examples/advanced_constraints/advanced_constraint_test_case_1.py index 8e08d35..d4c161c 100644 --- a/examples/advanced_constraints/advanced_constraint_test_case_1.py +++ b/examples/advanced_constraints/advanced_constraint_test_case_1.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -from route4me import Route4Me +import argparse from route4me import AdvancedConstraint +from route4me import Route4Me from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,11 +10,10 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.ADVANCED_CVRP_TW) @@ -124,4 +124,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Advanced Constraints - Tags and Different Time Windows Fleets') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/advanced_constraints/advanced_constraint_test_case_2.py b/examples/advanced_constraints/advanced_constraint_test_case_2.py index fa23406..4ab55a5 100644 --- a/examples/advanced_constraints/advanced_constraint_test_case_2.py +++ b/examples/advanced_constraints/advanced_constraint_test_case_2.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -from route4me import Route4Me +import argparse from route4me import AdvancedConstraint +from route4me import Route4Me from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,11 +10,10 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.ADVANCED_CVRP_TW) @@ -121,4 +121,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Advanced Constraints - Some addresses without Tags') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/advanced_constraints/advanced_constraint_test_case_3.py b/examples/advanced_constraints/advanced_constraint_test_case_3.py index d934cc1..0eb2180 100644 --- a/examples/advanced_constraints/advanced_constraint_test_case_3.py +++ b/examples/advanced_constraints/advanced_constraint_test_case_3.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -from route4me import Route4Me +import argparse from route4me import AdvancedConstraint +from route4me import Route4Me from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,11 +10,10 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.ADVANCED_CVRP_TW) @@ -125,4 +125,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description="Advanced Constraints - Driver's Shift") + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/avoidance_zones/add_avoidance_zone_circular_shape.py b/examples/avoidance_zones/add_avoidance_zone_circular_shape.py index 1523888..ac02ce2 100644 --- a/examples/avoidance_zones/add_avoidance_zone_circular_shape.py +++ b/examples/avoidance_zones/add_avoidance_zone_circular_shape.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) avoidance_zones = route4me.avoidance_zones print('Creating Circle Shape Zone') territory = { @@ -37,5 +38,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Add Circular Avoidance Zone') + 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[SIMILARITY] diff --git a/examples/avoidance_zones/add_avoidance_zone_polygon_shape.py b/examples/avoidance_zones/add_avoidance_zone_polygon_shape.py index 3f70a58..707c01e 100644 --- a/examples/avoidance_zones/add_avoidance_zone_polygon_shape.py +++ b/examples/avoidance_zones/add_avoidance_zone_polygon_shape.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) avoidance_zones = route4me.avoidance_zones print('Creating Polygon Shape Zone') territory = { @@ -41,5 +42,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Add Polygon Avoidance Zone') + 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[SIMILARITY] diff --git a/examples/avoidance_zones/add_avoidance_zone_rectangular_shape.py b/examples/avoidance_zones/add_avoidance_zone_rectangular_shape.py index d4f56ae..7a14c9f 100644 --- a/examples/avoidance_zones/add_avoidance_zone_rectangular_shape.py +++ b/examples/avoidance_zones/add_avoidance_zone_rectangular_shape.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) avoidance_zones = route4me.avoidance_zones print('Creating Rectangular Shape Zone') territory = { @@ -37,5 +38,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Add Rectangular Avoidance Zone') + 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[SIMILARITY] diff --git a/examples/avoidance_zones/delete_avoidance_zone.py b/examples/avoidance_zones/delete_avoidance_zone.py index c481ab6..369986c 100644 --- a/examples/avoidance_zones/delete_avoidance_zone.py +++ b/examples/avoidance_zones/delete_avoidance_zone.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) avoidance_zones = route4me.avoidance_zones print('Creating Poly Zone') territory = { @@ -41,5 +42,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Delete Avoidance Zone') + 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[SIMILARITY] diff --git a/examples/avoidance_zones/get_avoidance_zone.py b/examples/avoidance_zones/get_avoidance_zone.py index 5fe5392..0e4ae66 100644 --- a/examples/avoidance_zones/get_avoidance_zone.py +++ b/examples/avoidance_zones/get_avoidance_zone.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, BLOCK_NESTING] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) avoidance_zones = route4me.avoidance_zones response = avoidance_zones.get_avoidance_zones() if isinstance(response, dict) and 'errors' in response.keys(): @@ -31,5 +32,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Avoidance Zone') + 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[SIMILARITY, BLOCK_NESTING] diff --git a/examples/avoidance_zones/get_avoidance_zones.py b/examples/avoidance_zones/get_avoidance_zones.py index 116a746..7570b85 100644 --- a/examples/avoidance_zones/get_avoidance_zones.py +++ b/examples/avoidance_zones/get_avoidance_zones.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, BLOCK_NESTING] +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) avoidance_zones = route4me.avoidance_zones response = avoidance_zones.get_avoidance_zones() if isinstance(response, dict) and 'errors' in response.keys(): @@ -27,5 +27,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Avoidance Zones') + 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[SIMILARITY, BLOCK_NESTING] diff --git a/examples/avoidance_zones/update_avoidance_zone.py b/examples/avoidance_zones/update_avoidance_zone.py index 5ed079f..a7460ff 100644 --- a/examples/avoidance_zones/update_avoidance_zone.py +++ b/examples/avoidance_zones/update_avoidance_zone.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, BLOCK_NESTING, LOC, ABC] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) avoidance_zones = route4me.avoidance_zones print('Creating Poly Zone') territory = { @@ -71,5 +72,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Update Avoidance Zone') + 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[SIMILARITY, BLOCK_NESTING, LOC, ABC] diff --git a/examples/bundling/bundling_by_address.py b/examples/bundling/bundling_by_address.py index 0f30d48..6e6d499 100644 --- a/examples/bundling/bundling_by_address.py +++ b/examples/bundling/bundling_by_address.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -from route4me import Route4Me +import argparse from route4me import Bundling +from route4me import Route4Me from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,11 +10,9 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" - -def main(): - route4me = Route4Me(API_KEY, redirects=False) +def main(api_key): + route4me = Route4Me(api_key, redirects=False) optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.CVRP_TW_SD) @@ -122,4 +121,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Bundling Stops per Address Name') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/bundling/bundling_by_coordinates.py b/examples/bundling/bundling_by_coordinates.py index 1464d4c..1507199 100644 --- a/examples/bundling/bundling_by_coordinates.py +++ b/examples/bundling/bundling_by_coordinates.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -from route4me import Route4Me +import argparse from route4me import Bundling, BUNDLING_MODE +from route4me import Route4Me from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,11 +10,9 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" - -def main(): - route4me = Route4Me(API_KEY, redirects=False) +def main(api_key): + route4me = Route4Me(api_key, redirects=False) optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.CVRP_TW_SD) @@ -139,4 +138,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Bundling Stops per Address Coordinate') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/file_uploading/get_file_preview.py b/examples/file_uploading/get_file_preview.py index f0d953c..4206d04 100644 --- a/examples/file_uploading/get_file_preview.py +++ b/examples/file_uploading/get_file_preview.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from route4me import Route4Me +import argparse -KEY = "11111111111111111111111111111111" +from route4me import Route4Me -def main(): - route4me = Route4Me(KEY) +def main(api_key): + route4me = Route4Me(api_key) file_uploading = route4me.file_uploading upload_id = 'b2130b5fc36ae1109ef63b6db73781f6' response = file_uploading.get_file_preview(format='json', @@ -15,4 +15,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get File Preview') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/file_uploading/upload_file.py b/examples/file_uploading/upload_file.py index 1345386..7496ed0 100644 --- a/examples/file_uploading/upload_file.py +++ b/examples/file_uploading/upload_file.py @@ -1,14 +1,12 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] +import argparse import os - from route4me import Route4Me -KEY = "11111111111111111111111111111111" - -def main(): - route4me = Route4Me(KEY) +def main(api_key): + route4me = Route4Me(api_key) file_uploading = route4me.file_uploading file_path = os.path.dirname(os.path.abspath(__file__)) filename = os.path.join(file_path, '10-Stops-MultiDepotSmall.csv') @@ -19,5 +17,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Upload a File') + 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[SIMILARITY] diff --git a/examples/file_uploading/upload_file_geocode.py b/examples/file_uploading/upload_file_geocode.py index cb762ed..6dd246a 100644 --- a/examples/file_uploading/upload_file_geocode.py +++ b/examples/file_uploading/upload_file_geocode.py @@ -1,13 +1,12 @@ # -*- coding: utf-8 -*- +import argparse import os from route4me import Route4Me -KEY = "11111111111111111111111111111111" - -def main(): - route4me = Route4Me(KEY) +def main(api_key): + route4me = Route4Me(api_key) file_uploading = route4me.file_uploading upload_id = 'b2130b5fc36ae1109ef63b6db73781f6' @@ -21,4 +20,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Upload File to Geocode') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/file_uploading/upload_file_xlsx.py b/examples/file_uploading/upload_file_xlsx.py index 178fee4..3d9ad1a 100644 --- a/examples/file_uploading/upload_file_xlsx.py +++ b/examples/file_uploading/upload_file_xlsx.py @@ -1,15 +1,13 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] +import argparse import os - from route4me import Route4Me -KEY = "11111111111111111111111111111111" - -def main(): - route4me = Route4Me(KEY) +def main(api_key): + route4me = Route4Me(api_key) file_uploading = route4me.file_uploading file_path = os.path.dirname(os.path.abspath(__file__)) filename = os.path.join(file_path, '4 addresses linked 2 New Filters.xlsx') @@ -20,6 +18,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Upload XLSX File') + 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[SIMILARITY] diff --git a/examples/generic_example.py b/examples/generic_example.py index 202b498..88657c6 100644 --- a/examples/generic_example.py +++ b/examples/generic_example.py @@ -1,13 +1,15 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import OPTIMIZATION_STATE -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization response = optimization.get_optimizations(limit=10, offset=5) if hasattr(response, 'errors'): @@ -27,4 +29,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Generic Optimization Example') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/geocoding/forward_geocoding.py b/examples/geocoding/forward_geocoding.py index 3773f0b..8f04132 100644 --- a/examples/geocoding/forward_geocoding.py +++ b/examples/geocoding/forward_geocoding.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) address = "Boston-Cambridge-Quincy, MA-NH, USA" print('Geocoding this address: {}'.format(address)) response = route4me.address.geocode( @@ -16,4 +17,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Forward Geocoding') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/geocoding/geocoding.py b/examples/geocoding/geocoding.py index 16372c8..a160b9c 100644 --- a/examples/geocoding/geocoding.py +++ b/examples/geocoding/geocoding.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) addresses = [{'address': '455 S 4th St, Louisville, KY 40202'}, {'address': '1604 PARKRIDGE PKWY, Louisville, KY, 40214'}, {'address': '1407 MCCOY, Louisville, KY, 40215'}, @@ -21,4 +22,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Geocoding') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/geocoding/reverse_geocoding.py b/examples/geocoding/reverse_geocoding.py index 3782108..c2b81e3 100644 --- a/examples/geocoding/reverse_geocoding.py +++ b/examples/geocoding/reverse_geocoding.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) coordinate = "42.35863,-71.05670" print('Getting Address from this coordinate: {}'.format(coordinate)) response = route4me.address.geocode(addresses=coordinate) @@ -13,4 +14,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Reverse Geocoding') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/members/app_purchase_user_license.py b/examples/members/app_purchase_user_license.py index b7302cb..6239106 100644 --- a/examples/members/app_purchase_user_license.py +++ b/examples/members/app_purchase_user_license.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) members = route4me.members data = { "member_id": 1, @@ -26,4 +27,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='App Purchase user License') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/members/get_users.py b/examples/members/get_users.py index 7e476ad..3b21690 100644 --- a/examples/members/get_users.py +++ b/examples/members/get_users.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) members = route4me.members response = members.get_users(limit=5, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -22,4 +23,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get All Users') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/members/member_authenticate.py b/examples/members/member_authenticate.py index c0194df..101d75c 100644 --- a/examples/members/member_authenticate.py +++ b/examples/members/member_authenticate.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) members = route4me.members data = { "email": "john@route4me.com", @@ -21,4 +22,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Member Authentication') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/members/register_action.py b/examples/members/register_action.py index 47588ae..b3d4caa 100644 --- a/examples/members/register_action.py +++ b/examples/members/register_action.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) members = route4me.members data = { "email_address": "john@route4me.com", @@ -28,4 +29,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Registering a New Member') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/members/validate_session.py b/examples/members/validate_session.py index c09af4b..2ae87d8 100644 --- a/examples/members/validate_session.py +++ b/examples/members/validate_session.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) members = route4me.members data = { "session_guid": "4552222222", @@ -21,4 +21,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Validate Session') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/members/verify_user_license.py b/examples/members/verify_user_license.py index 9318b4e..59692a4 100644 --- a/examples/members/verify_user_license.py +++ b/examples/members/verify_user_license.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) members = route4me.members data = { "device_id": "1", @@ -21,4 +21,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Verify User License') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/members/webinar_registration.py b/examples/members/webinar_registration.py index fad56ed..2c534c9 100644 --- a/examples/members/webinar_registration.py +++ b/examples/members/webinar_registration.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) members = route4me.members data = { "email_address": "john@route4me.com", @@ -25,4 +26,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Webinar Registration') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/multiple_depot_multiple_driver.py b/examples/multiple_depot_multiple_driver.py index bffe24d..3d2ce5a 100644 --- a/examples/multiple_depot_multiple_driver.py +++ b/examples/multiple_depot_multiple_driver.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,13 +12,13 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" # codebeat:disable[LOC, ABC] -def main(): - route4me = Route4Me(API_KEY) +def main(api_key): + route4me = Route4Me(api_key) + optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.CVRP_TW_MD) @@ -389,8 +392,13 @@ def main(): for address in route['addresses']: print('\t\t\tAddress: {0}'.format(address['address'])) + # codebeat:enable[LOC, ABC] if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Multiple Depot, Multiple Driver') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/multiple_depot_multiple_driver_time_window.py b/examples/multiple_depot_multiple_driver_time_window.py index 4f1e9c6..8ce0a92 100644 --- a/examples/multiple_depot_multiple_driver_time_window.py +++ b/examples/multiple_depot_multiple_driver_time_window.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -10,13 +13,13 @@ METRIC, ) -API_KEY = "11111111111111111111111111111111" # codebeat:disable[LOC, ABC] -def main(): - route4me = Route4Me(API_KEY) +def main(api_key): + route4me = Route4Me(api_key) + optimization = route4me.optimization address = route4me.address optimization.route_name('Multiple Depot, Multiple Driver, Time window') @@ -489,8 +492,13 @@ def main(): for address in route['addresses']: print('\t\t\tAddress: {0}'.format(address['address'])) + # codebeat:enable[LOC, ABC] if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Multiple Depot, Multiple Driver, Time window') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/multiple_depot_multiple_driver_with_24_stops_time_window.py b/examples/multiple_depot_multiple_driver_with_24_stops_time_window.py index 0c6f288..3b7859f 100644 --- a/examples/multiple_depot_multiple_driver_with_24_stops_time_window.py +++ b/examples/multiple_depot_multiple_driver_with_24_stops_time_window.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,13 +12,13 @@ DISTANCE_UNIT, ) -API_KEY = '11111111111111111111111111111111' # codebeat:disable[LOC, ABC] -def main(): - route4me = Route4Me(API_KEY) +def main(api_key): + route4me = Route4Me(api_key) + optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.CVRP_TW_MD) @@ -247,4 +250,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Multiple Depot, Multiple Driver') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/notes/add_address_notes.py b/examples/notes/add_address_notes.py index bc0fe2c..e3c7495 100644 --- a/examples/notes/add_address_notes.py +++ b/examples/notes/add_address_notes.py @@ -1,15 +1,16 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me + from route4me.constants import ( DEVICE_TYPE ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) route = route4me.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -49,4 +50,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Add Address Notes') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/notes/get_address_notes.py b/examples/notes/get_address_notes.py index c1c8704..4679465 100644 --- a/examples/notes/get_address_notes.py +++ b/examples/notes/get_address_notes.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- # codebeat:disable[BLOCK_NESTING] +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) route = route4me.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -35,6 +35,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Notes from an Address') + 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[BLOCK_NESTING] diff --git a/examples/optimizations/create_optimization.py b/examples/optimizations/create_optimization.py index 0a74ffb..38da322 100755 --- a/examples/optimizations/create_optimization.py +++ b/examples/optimizations/create_optimization.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, LOC, ABC] +import argparse from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -10,11 +12,10 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -101,5 +102,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Create Optimization') + 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[SIMILARITY, LOC, ABC] diff --git a/examples/optimizations/delete_address_from_optimization.py b/examples/optimizations/delete_address_from_optimization.py index 22efc8e..881c37d 100644 --- a/examples/optimizations/delete_address_from_optimization.py +++ b/examples/optimizations/delete_address_from_optimization.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- # codebeat:disable[LOC, ABC] +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -10,11 +13,10 @@ TRAVEL_MODE ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -110,5 +112,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Delete Address from an Optimization') + 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[LOC, ABC] diff --git a/examples/optimizations/delete_optimization.py b/examples/optimizations/delete_optimization.py index a8c139f..2909f74 100644 --- a/examples/optimizations/delete_optimization.py +++ b/examples/optimizations/delete_optimization.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,14 +12,13 @@ TRAVEL_MODE ) -API_KEY = "11111111111111111111111111111111" - # codebeat:disable[LOC, ABC] -def main(): - route4me = Route4Me(API_KEY) +def main(api_key): + route4me = Route4Me(api_key) + optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -107,4 +109,8 @@ def main(): # codebeat:enable[LOC, ABC] if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Delete Optimization') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/optimizations/get_optimization.py b/examples/optimizations/get_optimization.py index 4ac666e..2af4917 100644 --- a/examples/optimizations/get_optimization.py +++ b/examples/optimizations/get_optimization.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization response = optimization.get_optimizations(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -29,4 +30,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Optimization') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/optimizations/get_optimizations.py b/examples/optimizations/get_optimizations.py index ea33cbd..33cd428 100644 --- a/examples/optimizations/get_optimizations.py +++ b/examples/optimizations/get_optimizations.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization response = optimization.get_optimizations(limit=10, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -21,4 +22,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Optimizations') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/optimizations/optimized_callback.py b/examples/optimizations/optimized_callback.py index 4748d0a..589440c 100755 --- a/examples/optimizations/optimized_callback.py +++ b/examples/optimizations/optimized_callback.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, LOC, ABC] +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -10,12 +13,11 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + callback_url = 'https://private.webhook' + route4me = Route4Me(api_key) -def main(): - callback_url = 'https://requestb.in/y8bybfy8' - route4me = Route4Me(API_KEY) optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -110,5 +112,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Optimization with Callback URL') + 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[SIMILARITY, LOC, ABC] diff --git a/examples/optimizations/re_optimization.py b/examples/optimizations/re_optimization.py index 502e108..5f4c7d7 100755 --- a/examples/optimizations/re_optimization.py +++ b/examples/optimizations/re_optimization.py @@ -1,13 +1,15 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import OPTIMIZATION_STATE -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization response = optimization.get_optimizations(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -22,4 +24,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Re-Optimization') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/order/create_order.py b/examples/order/create_order.py index 2ee3727..735dc08 100644 --- a/examples/order/create_order.py +++ b/examples/order/create_order.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[ABC] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) order = route4me.order url = "http://www.bk.com/restaurants/ny/new-york/106-fulton-st-17871.html" data = { @@ -38,5 +39,10 @@ def main(): if __name__ == '__main__': - 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) + # codebeat:enable[ABC] diff --git a/examples/order/delete_order.py b/examples/order/delete_order.py index 36d1b63..314b75a 100644 --- a/examples/order/delete_order.py +++ b/examples/order/delete_order.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[ABC] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) order = route4me.order url = "http://www.bk.com/restaurants/ny/new-york/106-fulton-st-17871.html" data = { @@ -48,5 +49,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Delete 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) + # codebeat:enable[ABC] diff --git a/examples/order/get_order.py b/examples/order/get_order.py index 014a51a..3c1804d 100644 --- a/examples/order/get_order.py +++ b/examples/order/get_order.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[ABC] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) order = route4me.order url = "http://www.bk.com/restaurants/ny/new-york/106-fulton-st-17871.html" data = { @@ -43,5 +44,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get 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) + # codebeat:enable[ABC] diff --git a/examples/order/update_order.py b/examples/order/update_order.py index 5663a06..e2f6fe0 100644 --- a/examples/order/update_order.py +++ b/examples/order/update_order.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[ABC] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) order = route4me.order url = "http://www.bk.com/restaurants/ny/new-york/106-fulton-st-17871.html" data = { @@ -60,5 +61,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Update 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) + # codebeat:enable[ABC] diff --git a/examples/pickup_dropoff/pickup_dropoff.py b/examples/pickup_dropoff/pickup_dropoff.py new file mode 100644 index 0000000..c907e49 --- /dev/null +++ b/examples/pickup_dropoff/pickup_dropoff.py @@ -0,0 +1,128 @@ +# -*- coding: utf-8 -*- +import argparse + +from route4me import Route4Me + +from route4me.constants import ( + ALGORITHM_TYPE, + OPTIMIZE, + DISTANCE_UNIT, + DEVICE_TYPE, + ADDRESS_STOP_TYPE, +) + + +# codebeat:disable[LOC, ABC] + + +def main(api_key): + route4me = Route4Me(api_key) + + optimization = route4me.optimization + address = route4me.address + optimization.add({ + 'algorithm_type': ALGORITHM_TYPE.CVRP_TW_SD, + 'share_route': 0, + 'route_name': 'Route with Pickup/Dropoff Feature', + 'optimize': OPTIMIZE.DISTANCE, + 'distance_unit': DISTANCE_UNIT.MI, + 'device_type': DEVICE_TYPE.WEB, + }) + address.add_address( + address='151 Arbor Way Milledgeville GA 31061', + alias='DEPOT', + lat=33.132675170898, + lng=-83.244743347168, + is_depot=1, + time=0 + ) + address.add_address( + address='230 Arbor Way Milledgeville GA 31061', + lat=33.129695892334, + lng=-83.24577331543, + pickup='PD_CUSTOMER001', + alias='PICKUP CUSTOMER001', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + time=60 + ) + address.add_address( + address='148 Bass Rd NE Milledgeville GA 31061', + lat=33.143497, + lng=-83.224487, + dropoff='PD_CUSTOMER001', + alias='DROPOFF CUSTOMER001', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + address.add_address( + address='117 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.141784667969, + lng=-83.237518310547, + pickup='PD_CUSTOMER002', + alias='PICKUP CUSTOMER002', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + time=60 + ) + address.add_address( + address='119 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.141086578369, + lng=-83.238258361816, + dropoff='PD_CUSTOMER002', + alias='DROPOFF CUSTOMER002', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + address.add_address( + address='131 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.142036437988, + lng=-83.238845825195, + pickup='PD_CUSTOMER003', + alias='PICKUP CUSTOMER003', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + time=60 + ) + address.add_address( + address='138 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.14307, + lng=-83.239334, + dropoff='PD_CUSTOMER003', + alias='DROPOFF CUSTOMER003', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + address.add_address( + address='139 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.142734527588, + lng=-83.237442016602, + pickup='PD_CUSTOMER004', + alias='PICKUP CUSTOMER004', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + time=60 + ) + address.add_address( + address='145 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.143871307373, + lng=-83.237342834473, + dropoff='PD_CUSTOMER004', + alias='DROPOFF CUSTOMER004', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + + response = route4me.run_optimization() + print('Optimization Link: {}'.format(response['links']['view'])) + for i, route in enumerate(response['routes']): + print('\t{0}\tRoute Link: {1}'.format(i + 1, route['links']['route'])) + for address in route['addresses']: + print('\t\t\tAddress: {0}'.format(address['address'])) + + +# codebeat:enable[LOC, ABC] + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Route with Pickup/Dropoff Feature') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/pickup_dropoff/pickup_dropoff_with_capacity.py b/examples/pickup_dropoff/pickup_dropoff_with_capacity.py new file mode 100644 index 0000000..35c43e4 --- /dev/null +++ b/examples/pickup_dropoff/pickup_dropoff_with_capacity.py @@ -0,0 +1,196 @@ +# -*- coding: utf-8 -*- +import argparse + +from route4me import Route4Me + +from route4me.constants import ( + ALGORITHM_TYPE, + OPTIMIZE, + DISTANCE_UNIT, + DEVICE_TYPE, + ADDRESS_STOP_TYPE, +) + + +# codebeat:disable[LOC, ABC] + + +def main(api_key): + route4me = Route4Me(api_key) + + optimization = route4me.optimization + address = route4me.address + optimization.add({ + 'algorithm_type': ALGORITHM_TYPE.CVRP_TW_SD, + 'share_route': 0, + 'route_name': 'Route with Pickup/Dropoff Feature and Capacity', + 'optimize': OPTIMIZE.DISTANCE, + 'distance_unit': DISTANCE_UNIT.MI, + 'device_type': DEVICE_TYPE.WEB, + 'vehicle_capacity': 6 + }) + address.add_address( + address='151 Arbor Way Milledgeville GA 31061', + alias='DEPOT', + lat=33.132675170898, + lng=-83.244743347168, + is_depot=1, + time=0 + ) + address.add_address( + address='230 Arbor Way Milledgeville GA 31061', + lat=33.129695892334, + lng=-83.24577331543, + pickup='PD_CUSTOMER001', + alias='PICKUP CUSTOMER001', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + original_route_id="ROUTE001", + time=60 + ) + address.add_address( + address='230 Arbor Way Milledgeville GA 31061', + lat=33.129695892334, + lng=-83.24577331543, + pickup='PD_CUSTOMER002', + original_route_id="ROUTE001", + alias='PICKUP CUSTOMER002', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + time=60 + ) + address.add_address( + address='230 Arbor Way Milledgeville GA 31061', + lat=33.129695892334, + lng=-83.24577331543, + pickup='PD_CUSTOMER003', + original_route_id="ROUTE001", + alias='PICKUP CUSTOMER003', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + time=60 + ) + address.add_address( + address='230 Arbor Way Milledgeville GA 31061', + lat=33.129695892334, + lng=-83.24577331543, + pickup='PD_CUSTOMER004', + original_route_id="ROUTE001", + alias='PICKUP CUSTOMER004', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + time=60 + ) + address.add_address( + address='148 Bass Rd NE Milledgeville GA 31061', + lat=33.143497, + lng=-83.224487, + dropoff='PD_CUSTOMER001', + original_route_id="ROUTE001", + alias='DROPOFF CUSTOMER001', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + address.add_address( + address='117 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.141784667969, + lng=-83.237518310547, + dropoff='PD_CUSTOMER002', + original_route_id="ROUTE001", + alias='DROPOFF CUSTOMER002', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + address.add_address( + address='119 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.141086578369, + lng=-83.238258361816, + dropoff='PD_CUSTOMER003', + original_route_id="ROUTE001", + alias='DROPOFF CUSTOMER003', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + address.add_address( + address='131 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.142036437988, + lng=-83.238845825195, + dropoff='PD_CUSTOMER004', + original_route_id="ROUTE001", + alias='DROPOFF CUSTOMER004', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + address.add_address( + address='138 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.14307, + lng=-83.239334, + pickup='PD_CUSTOMER005', + original_route_id="ROUTE002", + alias='PICKUP CUSTOMER005', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + time=60 + ) + address.add_address( + address='138 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.14307, + lng=-83.239334, + pickup='PD_CUSTOMER006', + original_route_id="ROUTE002", + alias='PICKUP CUSTOMER006', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + time=60 + ) + address.add_address( + address='138 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.14307, + lng=-83.239334, + pickup='PD_CUSTOMER007', + original_route_id="ROUTE002", + alias='PICKUP CUSTOMER007', + address_stop_type=ADDRESS_STOP_TYPE.PICKUP, + time=60 + ) + address.add_address( + address='139 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.142734527588, + lng=-83.237442016602, + dropoff='PD_CUSTOMER005', + original_route_id="ROUTE002", + alias='DROPOFF CUSTOMER005', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + address.add_address( + address='145 Bill Johnson Rd NE Milledgeville GA 31061', + lat=33.143871307373, + lng=-83.237342834473, + dropoff='PD_CUSTOMER006', + original_route_id="ROUTE002", + alias='DROPOFF CUSTOMER006', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + address.add_address( + address='221 Blake Cir Milledgeville GA 31061', + lat=33.081462860107, + lng=-83.208511352539, + dropoff='PD_CUSTOMER007', + original_route_id="ROUTE002", + alias='DROPOFF CUSTOMER007', + address_stop_type=ADDRESS_STOP_TYPE.DELIVERY, + time=60 + ) + response = route4me.run_optimization() + print('Optimization Link: {}'.format(response['links']['view'])) + for i, route in enumerate(response['routes']): + print('\t{0}\tRoute Link: {1}'.format(i + 1, route['links']['route'])) + for address in route['addresses']: + print('\t\t\tAddress: {0}'.format(address['address'])) + + +# codebeat:enable[LOC, ABC] + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Route with Pickup/Dropoff Feature and Capacity') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/rapid_address/get_street_data.py b/examples/rapid_address/get_street_data.py index 5a7d717..69d8912 100644 --- a/examples/rapid_address/get_street_data.py +++ b/examples/rapid_address/get_street_data.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) rapid_address = route4me.rapid_address response = rapid_address.get_street_data() for street in response: @@ -16,4 +17,9 @@ def main(): if __name__ == '__main__': - main() + print("DEPRECATED - Service Not Available") + parser = argparse.ArgumentParser(description='Get Street Data') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/rapid_address/get_street_data_get_single.py b/examples/rapid_address/get_street_data_get_single.py index a8b308d..0174196 100644 --- a/examples/rapid_address/get_street_data_get_single.py +++ b/examples/rapid_address/get_street_data_get_single.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) rapid_address = route4me.rapid_address response = rapid_address.get_street_data(pk=33) print('Street Name:\t{0}\t\tZip Code:\t{1}'.format( @@ -15,4 +15,9 @@ def main(): if __name__ == '__main__': - main() + print("DEPRECATED - Service Not Available") + parser = argparse.ArgumentParser(description='Get Street Address by ID') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/rapid_address/get_street_data_offset_limit.py b/examples/rapid_address/get_street_data_offset_limit.py index 1bafbb6..b10b646 100644 --- a/examples/rapid_address/get_street_data_offset_limit.py +++ b/examples/rapid_address/get_street_data_offset_limit.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) rapid_address = route4me.rapid_address response = rapid_address.get_street_data(offset=10, limit=10) for street in response: @@ -16,4 +17,10 @@ def main(): if __name__ == '__main__': - main() + print("DEPRECATED - Service Not Available") + + parser = argparse.ArgumentParser(description='Get Street Addresses Using Limit and Offset') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/rapid_address/get_street_data_service.py b/examples/rapid_address/get_street_data_service.py index bf82dee..be4e405 100644 --- a/examples/rapid_address/get_street_data_service.py +++ b/examples/rapid_address/get_street_data_service.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) rapid_address = route4me.rapid_address response = rapid_address.get_street_data_service(housenumber=1800, zipcode=33166) @@ -17,4 +18,10 @@ def main(): if __name__ == '__main__': - main() + print("DEPRECATED - Service Not Available") + + parser = argparse.ArgumentParser(description='Get Street Information using house number and zipcode') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/rapid_address/get_street_data_service_offset_limit.py b/examples/rapid_address/get_street_data_service_offset_limit.py index d091e66..2e5d87d 100644 --- a/examples/rapid_address/get_street_data_service_offset_limit.py +++ b/examples/rapid_address/get_street_data_service_offset_limit.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) rapid_address = route4me.rapid_address response = rapid_address.get_street_data_service(housenumber=1800, zipcode=33166, @@ -19,4 +20,11 @@ def main(): if __name__ == '__main__': - main() + print("DEPRECATED - Service Not Available") + + parser = argparse.ArgumentParser( + description='Get Street Information using house number and zipcode with limit and offset') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/rapid_address/get_street_data_zip.py b/examples/rapid_address/get_street_data_zip.py index 8596262..3b31b11 100644 --- a/examples/rapid_address/get_street_data_zip.py +++ b/examples/rapid_address/get_street_data_zip.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) rapid_address = route4me.rapid_address response = rapid_address.get_street_data_zip(zipcode=33166) for street in response: @@ -16,4 +16,10 @@ def main(): if __name__ == '__main__': - main() + print("DEPRECATED - Service Not Available") + + parser = argparse.ArgumentParser(description='Get Street Information using zipcode') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/rapid_address/get_street_data_zip_offset_limit.py b/examples/rapid_address/get_street_data_zip_offset_limit.py index b2203ac..f2474e0 100644 --- a/examples/rapid_address/get_street_data_zip_offset_limit.py +++ b/examples/rapid_address/get_street_data_zip_offset_limit.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) rapid_address = route4me.rapid_address response = rapid_address.get_street_data_zip(zipcode=33166, offset=10, @@ -18,4 +19,10 @@ def main(): if __name__ == '__main__': - main() + print("DEPRECATED - Service Not Available") + + parser = argparse.ArgumentParser(description='Get Street Information using zipcode with Limit and Offset') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/delete_route.py b/examples/routes/delete_route.py index f753d76..fd3c178 100644 --- a/examples/routes/delete_route.py +++ b/examples/routes/delete_route.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) route = route4me.route print('Getting Last Route') response = route.get_routes(limit=1, offset=0) @@ -24,4 +24,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Delete a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/delete_routes.py b/examples/routes/delete_routes.py index 3258bec..d82b7d2 100644 --- a/examples/routes/delete_routes.py +++ b/examples/routes/delete_routes.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) route = route4me.route print('Getting Latest 2 Routes') response = route.get_routes(limit=2, offset=0) @@ -26,4 +27,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Deleting Multiple Routes') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/duplicate_route.py b/examples/routes/duplicate_route.py index 7210a13..cec8ccf 100644 --- a/examples/routes/duplicate_route.py +++ b/examples/routes/duplicate_route.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) route = route4me.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -27,4 +28,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Duplicate a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/export_route_v5.py b/examples/routes/export_route_v5.py index 0adb553..9f77bd6 100644 --- a/examples/routes/export_route_v5.py +++ b/examples/routes/export_route_v5.py @@ -6,11 +6,13 @@ def main(api_key, route_id): route4me = Route4Me(api_key) + route = route4me.route exported_route = route.export_route_v5(route_id) print(exported_route) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Route Exporter API V5') parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', diff --git a/examples/routes/get_route.py b/examples/routes/get_route.py index 10ae0f1..453986a 100644 --- a/examples/routes/get_route.py +++ b/examples/routes/get_route.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -26,4 +27,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/get_route_directions.py b/examples/routes/get_route_directions.py index 4187df9..4d7df5e 100644 --- a/examples/routes/get_route_directions.py +++ b/examples/routes/get_route_directions.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- # codebeat:disable[BLOCK_NESTING, ABC] +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -54,5 +54,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Route Directions') + 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[BLOCK_NESTING, ABC] diff --git a/examples/routes/get_route_path_points.py b/examples/routes/get_route_path_points.py index fc0d594..48f2c83 100644 --- a/examples/routes/get_route_path_points.py +++ b/examples/routes/get_route_path_points.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- # codebeat:disable[BLOCK_NESTING] +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -40,5 +40,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Route Path Points') + 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[BLOCK_NESTING] diff --git a/examples/routes/get_route_tracking.py b/examples/routes/get_route_tracking.py index bbe3405..138a5ae 100644 --- a/examples/routes/get_route_tracking.py +++ b/examples/routes/get_route_tracking.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -31,4 +31,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Route Tracking Data') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/get_routes.py b/examples/routes/get_routes.py index 25d790b..72f3690 100644 --- a/examples/routes/get_routes.py +++ b/examples/routes/get_routes.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) route = route4me.route response = route.get_routes(limit=10, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -19,4 +19,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Multiple Routes') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/merge_routes.py b/examples/routes/merge_routes.py index 4195fba..53061d6 100644 --- a/examples/routes/merge_routes.py +++ b/examples/routes/merge_routes.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=2, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -33,4 +33,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Merge Two Routes') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/resequence_multiple_stops.py b/examples/routes/resequence_multiple_stops.py index 52bafd0..8392d37 100644 --- a/examples/routes/resequence_multiple_stops.py +++ b/examples/routes/resequence_multiple_stops.py @@ -28,8 +28,9 @@ def main(args): print(f'Address Sequence: {address["sequence_no"]:6} - ' f'Route Destination ID: {address["route_destination_id"]:9} - Address: {address["address"]} ') + if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Resequence a Route') + parser = argparse.ArgumentParser(description='Re-sequence Multiple Stops from a Route') parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', type=str, required=True) parser.add_argument('--route_id', dest='route_id', help='Route ID', diff --git a/examples/routes/resequence_route.py b/examples/routes/resequence_route.py index 2b05c54..7b2c012 100644 --- a/examples/routes/resequence_route.py +++ b/examples/routes/resequence_route.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -46,4 +46,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Re-sequence a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/resequence_route_all.py b/examples/routes/resequence_route_all.py index 2e3fe34..da8d0a2 100644 --- a/examples/routes/resequence_route_all.py +++ b/examples/routes/resequence_route_all.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -29,4 +29,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Re-sequence all stops from a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/routes_manifest.py b/examples/routes/routes_manifest.py index bac549a..0324cac 100644 --- a/examples/routes/routes_manifest.py +++ b/examples/routes/routes_manifest.py @@ -1,15 +1,16 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me + from route4me.constants import ( ROUTE_PATH_OUTPUT, ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) route = route4me.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -48,4 +49,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Route Manifest') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/share_route.py b/examples/routes/share_route.py index 9b6a4ba..8497b63 100644 --- a/examples/routes/share_route.py +++ b/examples/routes/share_route.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -26,4 +27,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Share a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/update_route.py b/examples/routes/update_route.py index 3e4372e..d122538 100644 --- a/examples/routes/update_route.py +++ b/examples/routes/update_route.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,14 +12,13 @@ TRAVEL_MODE, ) -API_KEY = "11111111111111111111111111111111" - # codebeat:disable[LOC, ABC] -def main(): - r4m = Route4Me(API_KEY) +def main(api_key): + r4m = Route4Me(api_key) + optimization = r4m.optimization address = r4m.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -93,4 +95,8 @@ def main(): # codebeat:enable[LOC, ABC] if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Update a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/update_route_destination_custom_data.py b/examples/routes/update_route_destination_custom_data.py index a568d9d..dc45242 100644 --- a/examples/routes/update_route_destination_custom_data.py +++ b/examples/routes/update_route_destination_custom_data.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -37,4 +38,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Update Route Destination Custom Data') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/routes/update_route_parameters.py b/examples/routes/update_route_parameters.py index 0446642..ac556c7 100644 --- a/examples/routes/update_route_parameters.py +++ b/examples/routes/update_route_parameters.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- # codebeat:disable[LOC, ABC] +import argparse from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -10,11 +12,10 @@ TRAVEL_MODE ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + r4m = Route4Me(api_key) -def main(): - r4m = Route4Me(API_KEY) optimization = r4m.optimization address = r4m.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -96,5 +97,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Update Route Parameters') + 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[LOC, ABC] diff --git a/examples/single_depot_multiple_driver.py b/examples/single_depot_multiple_driver.py index 074bcad..f6f7c70 100644 --- a/examples/single_depot_multiple_driver.py +++ b/examples/single_depot_multiple_driver.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,13 +11,13 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" # codebeat:disable[LOC, ABC] -def main(): - route4me = Route4Me(API_KEY) +def main(api_key): + route4me = Route4Me(api_key) + optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.CVRP_TW_SD) @@ -346,4 +348,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Single Depot, Multiple Driver') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/single_depot_multiple_driver_time_window.py b/examples/single_depot_multiple_driver_time_window.py index 4266304..0f75a5b 100644 --- a/examples/single_depot_multiple_driver_time_window.py +++ b/examples/single_depot_multiple_driver_time_window.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -9,14 +12,13 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" - # codebeat:disable[LOC, ABC] -def main(): - route4me = Route4Me(API_KEY) +def main(api_key): + route4me = Route4Me(api_key) + optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.CVRP_TW_SD) @@ -492,4 +494,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Single Depot, Multiple Driver Time Window') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/single_driver_round_trip.py b/examples/single_driver_round_trip.py index 5fdf7c2..3dbd82c 100755 --- a/examples/single_driver_round_trip.py +++ b/examples/single_driver_round_trip.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, LOC, ABC] +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -10,11 +13,10 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -103,5 +105,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Single Driver Round Trip') + 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[SIMILARITY, LOC, ABC] diff --git a/examples/single_driver_round_trip_redirects_false.py b/examples/single_driver_round_trip_redirects_false.py index adffa5a..cbc03f5 100644 --- a/examples/single_driver_round_trip_redirects_false.py +++ b/examples/single_driver_round_trip_redirects_false.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, LOC, ABC] +import argparse from route4me import Route4Me from route4me.constants import ( @@ -10,11 +11,9 @@ DISTANCE_UNIT, ) -API_KEY = "11111111111111111111111111111111" - -def main(): - route4me = Route4Me(API_KEY, redirects=False) +def main(api_key): + route4me = Route4Me(api_key, redirects=False) optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -24,7 +23,7 @@ def main(): optimization.rt(1) optimization.route_max_duration(86400) optimization.vehicle_max_distance_mi(10000) - optimization.route_name('Single Driver Round Trip') + optimization.route_name('Single Driver Round Trip - No Redirects') optimization.optimize(OPTIMIZE.TIME) optimization.distance_unit(DISTANCE_UNIT.MI) optimization.device_type(DEVICE_TYPE.WEB) @@ -103,5 +102,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Single Driver Round Trip - No Redirects') + 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[SIMILARITY, LOC, ABC] diff --git a/examples/single_driver_round_trip_reoptimization.py b/examples/single_driver_round_trip_reoptimization.py index 1247a26..79c48e7 100755 --- a/examples/single_driver_round_trip_reoptimization.py +++ b/examples/single_driver_round_trip_reoptimization.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -10,14 +13,13 @@ OPTIMIZATION_STATE, ) -API_KEY = "11111111111111111111111111111111" - # codebeat:disable[LOC, ABC] -def main(): - route4me = Route4Me(API_KEY) +def main(api_key): + route4me = Route4Me(api_key) + optimization = route4me.optimization address = route4me.address optimization.algorithm_type(ALGORITHM_TYPE.TSP) @@ -27,7 +29,7 @@ def main(): optimization.route_max_duration(86400) optimization.vehicle_capacity(1) optimization.vehicle_max_distance_mi(10000) - optimization.route_name('Single Driver Round Trip') + optimization.route_name('Single Driver Round Trip - Re-Optimization') optimization.optimize(OPTIMIZE.DISTANCE) optimization.distance_unit(DISTANCE_UNIT.MI) optimization.device_type(DEVICE_TYPE.WEB) @@ -118,4 +120,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Single Driver Round Trip - Re-Optimization') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/single_driver_route_10_stops.py b/examples/single_driver_route_10_stops.py index 7d4f68a..f0b5cf8 100755 --- a/examples/single_driver_route_10_stops.py +++ b/examples/single_driver_route_10_stops.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import ( ALGORITHM_TYPE, OPTIMIZE, @@ -8,14 +11,13 @@ DEVICE_TYPE, ) -API_KEY = "11111111111111111111111111111111" - # codebeat:disable[LOC, ABC] -def main(): - route4me = Route4Me(API_KEY) +def main(api_key): + route4me = Route4Me(api_key) + optimization = route4me.optimization address = route4me.address optimization.add({ @@ -100,4 +102,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Single Driver Route 10 Stops') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/telematics/compare_vendors.py b/examples/telematics/compare_vendors.py index 0b4281a..ad79b9e 100644 --- a/examples/telematics/compare_vendors.py +++ b/examples/telematics/compare_vendors.py @@ -6,12 +6,14 @@ def main(api_key): route4me = Route4Me(api_key) + telematics = route4me.telematics vendors = telematics.compare_vendors('1,58,155') print('ID\tNAME\tFEATURES') for vendor in vendors.get('vendors', []): telematics.pp_vendor_comparison(vendor) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Telematics Vendors Comparison') parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', diff --git a/examples/telematics/delete_vendor_connection.py b/examples/telematics/delete_vendor_connection.py index 582e2b6..db5ee20 100644 --- a/examples/telematics/delete_vendor_connection.py +++ b/examples/telematics/delete_vendor_connection.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import argparse + from route4me import Route4Me diff --git a/examples/telematics/get_connections.py b/examples/telematics/get_connections.py index 4f77a53..04f6e9b 100644 --- a/examples/telematics/get_connections.py +++ b/examples/telematics/get_connections.py @@ -6,6 +6,7 @@ def main(api_key, member_id): route4me = Route4Me(api_key) + telematics = route4me.telematics token = telematics.register_member(member_id) @@ -21,6 +22,7 @@ def main(api_key, member_id): else: print("You currently have no telematics connections") + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Telematics Vendors Connections') parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', diff --git a/examples/telematics/get_vendor.py b/examples/telematics/get_vendor.py index 830dfa6..2aea209 100644 --- a/examples/telematics/get_vendor.py +++ b/examples/telematics/get_vendor.py @@ -1,16 +1,17 @@ # -*- coding: utf-8 -*- import argparse - from route4me import Route4Me def main(api_key, vendor_id): route4me = Route4Me(api_key) + telematics = route4me.telematics vendor = telematics.get_vendor(vendor_id) telematics.pp_response(vendor.get('vendor', {})) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Get Telematics Vendors') parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', diff --git a/examples/telematics/get_vendor_connection.py b/examples/telematics/get_vendor_connection.py index d578458..dbd65a1 100644 --- a/examples/telematics/get_vendor_connection.py +++ b/examples/telematics/get_vendor_connection.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import argparse + from route4me import Route4Me diff --git a/examples/telematics/get_vendors.py b/examples/telematics/get_vendors.py index 8afc515..c74bc15 100644 --- a/examples/telematics/get_vendors.py +++ b/examples/telematics/get_vendors.py @@ -6,6 +6,7 @@ def main(api_key): route4me = Route4Me(api_key) + telematics = route4me.telematics vendors = telematics.get_vendors() for vendor in vendors.get('vendors', []): diff --git a/examples/telematics/get_vendors_connection_info.py b/examples/telematics/get_vendors_connection_info.py index 006cc3a..61d7655 100644 --- a/examples/telematics/get_vendors_connection_info.py +++ b/examples/telematics/get_vendors_connection_info.py @@ -6,6 +6,7 @@ def main(api_key, member_id): route4me = Route4Me(api_key) + telematics = route4me.telematics token = telematics.register_member(member_id) @@ -18,6 +19,7 @@ def main(api_key, member_id): for vendor_connection in vendor_connections: telematics.pp_response(vendor_connection) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Get Telematics Vendors Connection Information') parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', diff --git a/examples/telematics/register_member.py b/examples/telematics/register_member.py index ba3d8fa..affa124 100644 --- a/examples/telematics/register_member.py +++ b/examples/telematics/register_member.py @@ -6,10 +6,12 @@ def main(api_key, member_id): route4me = Route4Me(api_key) + telematics = route4me.telematics token = telematics.register_member(member_id) telematics.pp_response(token) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Register Telematics Member') parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', diff --git a/examples/telematics/register_vendor_connection.py b/examples/telematics/register_vendor_connection.py index 729d797..aa4be6f 100644 --- a/examples/telematics/register_vendor_connection.py +++ b/examples/telematics/register_vendor_connection.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import argparse import json + from route4me import Route4Me @@ -13,6 +14,7 @@ def _load_credentials(fn): def main(api_key, member_id, filename): route4me = Route4Me(api_key) + telematics = route4me.telematics token = telematics.register_member(member_id) @@ -25,6 +27,7 @@ def main(api_key, member_id, filename): vendor_connection = telematics.register_connection(api_token, **vendor_credentials) telematics.pp_response(vendor_connection) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Register Telematics Member Connection') parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', diff --git a/examples/telematics/search_vendor.py b/examples/telematics/search_vendor.py index 8e56fe0..90812b0 100644 --- a/examples/telematics/search_vendor.py +++ b/examples/telematics/search_vendor.py @@ -6,6 +6,7 @@ def main(api_key): route4me = Route4Me(api_key) + telematics = route4me.telematics print('****************************') print('Searching for Global Vendors') @@ -33,6 +34,7 @@ def main(api_key): for vendor in vendors.get('vendors', []): telematics.pp_response(vendor) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Search Telematics Vendors') parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', diff --git a/examples/telematics/update_vendor_connection.py b/examples/telematics/update_vendor_connection.py index db9ce88..bf33a27 100644 --- a/examples/telematics/update_vendor_connection.py +++ b/examples/telematics/update_vendor_connection.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import argparse import json + from route4me import Route4Me @@ -18,6 +19,7 @@ def main(api_token, connection_token, filename): vendor_connection = telematics.update_connection(api_token, connection_token, **vendor_credentials) telematics.pp_response(vendor_connection) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Update Telematics Member Connection') parser.add_argument('--api_token', dest='api_token', help='Telematics API TOKEN', diff --git a/examples/territory/add_territory.py b/examples/territory/add_territory.py index 6624e87..81a4370 100644 --- a/examples/territory/add_territory.py +++ b/examples/territory/add_territory.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, LOC, ABC] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) territories = route4me.territory print('Creating Poly Territory') territory = { @@ -91,5 +92,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Add Territory') + 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[SIMILARITY, LOC, ABC] diff --git a/examples/territory/delete_territory.py b/examples/territory/delete_territory.py index ed12190..df3c9d5 100644 --- a/examples/territory/delete_territory.py +++ b/examples/territory/delete_territory.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) territories = route4me.territory print('Creating Poly Territory') territory = { @@ -40,5 +41,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Delete Territory') + 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[SIMILARITY] diff --git a/examples/territory/get_territories.py b/examples/territory/get_territories.py index 6612df7..784f3b0 100644 --- a/examples/territory/get_territories.py +++ b/examples/territory/get_territories.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, BLOCK_NESTING] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) territory = route4me.territory response = territory.get_territories() if isinstance(response, dict) and 'errors' in response.keys(): @@ -27,5 +28,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Multiple Territories') + 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[SIMILARITY, BLOCK_NESTING] diff --git a/examples/territory/get_territory.py b/examples/territory/get_territory.py index 8b4b3d1..f7f82f1 100644 --- a/examples/territory/get_territory.py +++ b/examples/territory/get_territory.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, BLOCK_NESTING] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) territories = route4me.territory response = territories.get_territories() if isinstance(response, dict) and 'errors' in response.keys(): @@ -32,5 +33,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get a Territory') + 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[SIMILARITY, BLOCK_NESTING] diff --git a/examples/territory/update_territory.py b/examples/territory/update_territory.py index 5014150..3f6ab39 100644 --- a/examples/territory/update_territory.py +++ b/examples/territory/update_territory.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- # codebeat:disable[SIMILARITY, BLOCK_NESTING, LOC, ABC] +import argparse + from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) territories = route4me.territory print('Creating Poly Zone') territory = { @@ -71,5 +72,10 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Update an existing Territory') + 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[SIMILARITY, BLOCK_NESTING, LOC, ABC] diff --git a/examples/tracking/set_gps_example.py b/examples/tracking/set_gps_example.py index 8e7b117..66c1634 100644 --- a/examples/tracking/set_gps_example.py +++ b/examples/tracking/set_gps_example.py @@ -1,16 +1,17 @@ # -*- coding: utf-8 -*- +import argparse + from route4me import Route4Me + from route4me.constants import ( FORMAT, DEVICE_TYPE ) -KEY = "11111111111111111111111111111111" - -def main(): - route4me = Route4Me(KEY) +def main(api_key): + route4me = Route4Me(api_key) route = route4me.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): @@ -32,4 +33,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Set GPS Tracking Data into a Route') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/tracking/track_device_last_location_history.py b/examples/tracking/track_device_last_location_history.py index 371b46e..2e870e1 100644 --- a/examples/tracking/track_device_last_location_history.py +++ b/examples/tracking/track_device_last_location_history.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import argparse import datetime as dt from route4me import Route4Me @@ -8,11 +9,10 @@ DEVICE_TYPE ) -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) gps = route4me.gps route = route4me.route response = route.get_routes(limit=1, offset=0) @@ -54,4 +54,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Tracking History') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/examples/vehicles/get_vehicles.py b/examples/vehicles/get_vehicles.py index 09ea862..dce027b 100644 --- a/examples/vehicles/get_vehicles.py +++ b/examples/vehicles/get_vehicles.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import argparse from route4me import Route4Me -API_KEY = "11111111111111111111111111111111" +def main(api_key): + route4me = Route4Me(api_key) -def main(): - route4me = Route4Me(API_KEY) vehicles = route4me.vehicles response = vehicles.get_vehicles() if type(response) == dict and 'errors' in response.keys(): @@ -20,4 +20,8 @@ def main(): if __name__ == '__main__': - main() + parser = argparse.ArgumentParser(description='Get Vehicles') + parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY', + type=str, required=True) + args = parser.parse_args() + main(args.api_key) diff --git a/route4me/address.py b/route4me/address.py index 4d6826e..51eb6ab 100644 --- a/route4me/address.py +++ b/route4me/address.py @@ -24,7 +24,7 @@ class Address(Base): except for depots. One depot can be part of many routes if we have a VRP (multi-route) solution. """ - REQUIRED_FIELDS = ['address', 'lat', 'lng', ] + REQUIRED_FIELDS = ['lat', 'lng', ] def __init__(self, api, addresses=[]): """ diff --git a/route4me/constants.py b/route4me/constants.py index 5b6ef85..fe867af 100644 --- a/route4me/constants.py +++ b/route4me/constants.py @@ -110,4 +110,12 @@ def auto_enum(*sequential, **named): TERRITORY_TYPE = enum(CIRCLE='circle', POLY='poly', - RECT='rect', ) + RECT='rect') + +ADDRESS_STOP_TYPE = enum(DELIVERY="DELIVERY", + PICKUP="PICKUP", + BREAK="BREAK", + MEETUP="MEETUP", + SERVICE="SERVICE", + VISIT="VISIT", + DRIVEBY="DRIVEBY")