-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADDED] Feature to set, get, rollback Route Status
- Loading branch information
Showing
10 changed files
with
172 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import argparse | ||
|
||
from route4me import Route4Me | ||
|
||
|
||
def main(api_key, route_id): | ||
r4m = Route4Me(api_key) | ||
|
||
route = r4m.route_status | ||
print('Route ID: {}'.format(route_id)) | ||
response = route.get_route_status(route_id=route_id) | ||
print(response) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Get 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='Route4Me Route ID', | ||
type=str, required=True) | ||
args = parser.parse_args() | ||
main(args.api_key, args.route_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import argparse | ||
|
||
from route4me import Route4Me | ||
|
||
|
||
def main(api_key, route_id): | ||
r4m = Route4Me(api_key) | ||
|
||
route = r4m.route_status | ||
print('Route ID: {}'.format(route_id)) | ||
response = route.get_route_status_history(route_id=route_id) | ||
print(response) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Get 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='Route4Me Route ID', | ||
type=str, required=True) | ||
args = parser.parse_args() | ||
main(args.api_key, args.route_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import argparse | ||
|
||
from route4me import Route4Me | ||
|
||
|
||
def main(api_key, route_id): | ||
r4m = Route4Me(api_key) | ||
|
||
route = r4m.route_status | ||
print('Route ID: {}'.format(route_id)) | ||
response = route.rollback_route_status(route_id=route_id) | ||
print(response) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Get 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='Route4Me Route ID', | ||
type=str, required=True) | ||
args = parser.parse_args() | ||
main(args.api_key, args.route_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import argparse | ||
|
||
from route4me import Route4Me | ||
|
||
|
||
def main(api_key, route_id, status, lat, lng): | ||
r4m = Route4Me(api_key) | ||
|
||
route = r4m.route_status | ||
print('Route ID: {}'.format(route_id)) | ||
print('Latitude: {} - Longitude: {}'.format(lat, lng)) | ||
response = route.set_route_status(route_id=route_id, status=status, lat=lat, lng=lng) | ||
print(response) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Get 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='Route4Me Route ID', | ||
type=str, required=True) | ||
parser.add_argument('--status', dest='status', help='Route Status: planned, started, paused, completed', | ||
type=str, required=True) | ||
parser.add_argument('--lat', dest='lat', help='Latitude', | ||
type=float, required=True) | ||
parser.add_argument('--lng', dest='lng', help='Longitude', | ||
type=float, required=True) | ||
args = parser.parse_args() | ||
main(args.api_key, args.route_id, args.status, args.lat, args.lng) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from datetime import datetime | ||
from .base import Base | ||
from .api_endpoints import ROUTE_STATUS_V5 | ||
|
||
|
||
class RouteStatus(Base): | ||
""" | ||
Route Status | ||
- Planned | ||
- Started | ||
- Paused | ||
- Resumed | ||
- Completed | ||
""" | ||
|
||
def __init__(self, api): | ||
""" | ||
Routes | ||
:param api: Route4Me API Instance | ||
""" | ||
self.params = {'api_key': api.key, } | ||
Base.__init__(self, api) | ||
|
||
def get_route_status(self, route_id): | ||
response = self.api._request_get("{}/{}".format(ROUTE_STATUS_V5, route_id), | ||
self.params) | ||
return response.json() | ||
|
||
def get_route_status_history(self, route_id): | ||
response = self.api._request_get("{}/{}/history".format(ROUTE_STATUS_V5, route_id), | ||
self.params) | ||
return response.json() | ||
|
||
def set_route_status(self, route_id, status, lat, lng, event_timestamp=None): | ||
if event_timestamp is None: | ||
event_timestamp = int(datetime.now().timestamp()) | ||
data = { | ||
"status": status, | ||
"lat": lat, | ||
'lng': lng, | ||
'event_timestamp': event_timestamp, | ||
} | ||
response = self.api._request_post("{}/{}".format(ROUTE_STATUS_V5, route_id), | ||
self.params, | ||
json=data) | ||
return response.json() | ||
|
||
def rollback_route_status(self, route_id): | ||
response = self.api._request_get("{}/{}/rollback".format(ROUTE_STATUS_V5, route_id), | ||
self.params) | ||
return response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,14 @@ | |
# VERSION.py - MAINTAINER's. Don't edit, if you don't know what are you doing | ||
# ============================================================================== | ||
|
||
VERSION = (0, 1, 4, 4) | ||
VERSION = (0, 1, 5, 0) | ||
RELEASE_SUFFIX = '' | ||
|
||
VERSION_STRING = '.'.join([str(x) for x in VERSION]) | ||
RELEASE_STRING = "v{}{}".format(VERSION_STRING, RELEASE_SUFFIX) | ||
|
||
PROJECT = 'Route4Me Python SDK' | ||
COPYRIGHT = '2016-2023 © Route4Me Python Team' | ||
COPYRIGHT = '2016-2021 © Route4Me Python Team' | ||
AUTHOR = 'Route4Me Python Team (SDK)' | ||
AUTHOR_EMAIL = '[email protected]' | ||
TITLE = 'route4me' | ||
|