parent
cd5adffbd0
commit
c30180221f
@ -1,63 +1,72 @@
|
|||||||
import api as GeorideApi
|
""" Example georideapilib code """
|
||||||
from objects import GeorideAccount
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
import time
|
import time
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from georideapilib.objects import GeorideAccount
|
||||||
|
import georideapilib.api as GeorideApi
|
||||||
|
|
||||||
|
|
||||||
|
def example():
|
||||||
|
""" simple example function """
|
||||||
|
token = "<your_token>"# pylint: disable=C0301
|
||||||
|
account = GeorideAccount(0, "<your_email>", False, token)
|
||||||
|
|
||||||
""" If ypu out to reuse account """
|
"""
|
||||||
"""
|
GeorideApi.getAuthorisationToken("<your_email>", "<your_password>")
|
||||||
account = GeorideAccount(<your_id>, <yout_email>, <is_admin>, <your_token>)
|
print("token 1: ", account.auth_token)
|
||||||
"""
|
""" # pylint: disable=W0105
|
||||||
|
|
||||||
""" Get an acces token """
|
|
||||||
account = GeorideApi.getAuthorisationToken("<your_email>", "<your_passord>")
|
|
||||||
print("token 1: ", account.authToken)
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
account.auth_token = GeorideApi.renewToken(account.auth_token)
|
||||||
|
print("token 2: ", account.auth_token)
|
||||||
|
""" # pylint: disable=W0105
|
||||||
|
|
||||||
""" do not abuse, renew when previous token have almost reached time """
|
user = GeorideApi.get_user(account.auth_token)
|
||||||
"""
|
print("User: ", user.first_name)
|
||||||
account.authToken = GeorideApi.renewToken(account.authToken)
|
|
||||||
print("token 2: ", account.authToken)
|
|
||||||
"""
|
|
||||||
|
|
||||||
user = GeorideApi.getUser(account.authToken)
|
trackers = GeorideApi.get_trackers(account.auth_token)
|
||||||
print("User: ", user.firstName)
|
tracker = trackers[0]
|
||||||
|
print("Tracker name: ", tracker.tracker_name)
|
||||||
|
|
||||||
trackers = GeorideApi.getTrackers(account.authToken)
|
trips = GeorideApi.get_trips(account.auth_token, tracker.tracker_id, "2019-10-10", "2019-10-24")
|
||||||
tracker = trackers[0]
|
trip = trips[0]
|
||||||
print("Tracker name: ", tracker.trackerName)
|
trip_date = datetime.datetime.strptime("2019-10-10T06:45:34.000Z", '%Y-%m-%dT%H:%M:%S.%fZ')
|
||||||
|
print("Trip date: {}, from: {}, to: {}".format(trip_date, trip.nice_start_address,
|
||||||
|
trip.nice_end_address))
|
||||||
|
|
||||||
trips = GeorideApi.getTrips(account.authToken, tracker.trackerId, "2019-10-10", "2019-10-24")
|
positions = GeorideApi.get_positions(account.auth_token, tracker.tracker_id,
|
||||||
trip = trips[0];
|
"2019-10-10", "2019-10-24")
|
||||||
trip_date = datetime.datetime.strptime("2019-10-10T06:45:34.000Z", '%Y-%m-%dT%H:%M:%S.%fZ')
|
position = positions[0]
|
||||||
print("Trip date: {}, from: {}, to: {}".format(trip_date, trip.niceStartAddress, trip.niceEndAddress))
|
print("Position speed: {}, lon: {}, lat: {}".format(position.speed, position.longitude,
|
||||||
|
position.latitude))
|
||||||
|
|
||||||
positions = GeorideApi.getPositions(account.authToken, tracker.trackerId, "2019-10-10", "2019-10-24")
|
|
||||||
position = positions[0];
|
|
||||||
print("Position speed: {}, lon: {}, lat: {}".format(position.speed, position.longitude, position.latitude))
|
|
||||||
|
|
||||||
|
trip_shared = GeorideApi.share_a_trip_by_date(account.auth_token, tracker.tracker_id,
|
||||||
|
"2019-10-10", "2019-10-24")
|
||||||
|
print("tripShared url: {}, id: {}".format(trip_shared.url, trip_shared.share_id))
|
||||||
|
|
||||||
tripShared = GeorideApi.shareATripByDate(account.authToken, tracker.trackerId, fromDate="2019-10-10", toDate="2019-10-24")
|
time.sleep(10)
|
||||||
print("tripShared url: {}, id: {}".format(tripShared.url, tripShared.shareId))
|
have_been_locked = GeorideApi.lock_tracker(account.auth_token, tracker.tracker_id)
|
||||||
|
print("Tracker have been locked: ", have_been_locked)
|
||||||
|
|
||||||
time.sleep(30)
|
time.sleep(10)
|
||||||
haveBeenLocked = GeorideApi.lockTracker(account.authToken, tracker.trackerId)
|
have_been_unlocked = GeorideApi.unlock_tracker(account.auth_token, tracker.tracker_id)
|
||||||
print("Tracker have been locked: ", haveBeenLocked)
|
print("Tracker have been unlocked: ", have_been_unlocked)
|
||||||
|
|
||||||
time.sleep(30)
|
time.sleep(10)
|
||||||
haveBeenUnlocked = GeorideApi.lockTracker(account.authToken, tracker.trackerId)
|
is_locked = GeorideApi.toogle_lock_tracker(account.auth_token, tracker.tracker_id)
|
||||||
print("Tracker have been unlocked: ", haveBeenUnlocked)
|
print("Tracker is locked: ", is_locked)
|
||||||
|
|
||||||
time.sleep(30)
|
time.sleep(10)
|
||||||
isLocked = GeorideApi.toogleLockTracker(account.authToken, tracker.trackerId)
|
trackers = GeorideApi.get_trackers(account.auth_token)
|
||||||
print("Tracker is locked: ", haveBeenUnlocked)
|
tracker = trackers[0]
|
||||||
|
print("Tracker name: ", tracker.tracker_name, " is locked: ", tracker.is_locked)
|
||||||
|
|
||||||
time.sleep(30)
|
"""
|
||||||
trackers = GeorideApi.getTrackers(account.authToken)
|
GeorideApi.revokeToken(account.auth_token)
|
||||||
tracker = trackers[0]
|
""" # pylint: disable=W0105
|
||||||
print("Tracker name: ", tracker.trackerName, " is locked: ", tracker.isLocked)
|
|
||||||
|
|
||||||
"""
|
example()
|
||||||
GeorideApi.revokeToken(account.authToken)
|
|
||||||
"""
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue