parent
cd5adffbd0
commit
c30180221f
@ -1,63 +1,72 @@
|
||||
import api as GeorideApi
|
||||
from objects import GeorideAccount
|
||||
""" Example georideapilib code """
|
||||
|
||||
|
||||
import datetime
|
||||
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 """
|
||||
"""
|
||||
account = GeorideAccount(<your_id>, <yout_email>, <is_admin>, <your_token>)
|
||||
"""
|
||||
"""
|
||||
GeorideApi.getAuthorisationToken("<your_email>", "<your_password>")
|
||||
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 """
|
||||
"""
|
||||
account.authToken = GeorideApi.renewToken(account.authToken)
|
||||
print("token 2: ", account.authToken)
|
||||
"""
|
||||
user = GeorideApi.get_user(account.auth_token)
|
||||
print("User: ", user.first_name)
|
||||
|
||||
user = GeorideApi.getUser(account.authToken)
|
||||
print("User: ", user.firstName)
|
||||
trackers = GeorideApi.get_trackers(account.auth_token)
|
||||
tracker = trackers[0]
|
||||
print("Tracker name: ", tracker.tracker_name)
|
||||
|
||||
trackers = GeorideApi.getTrackers(account.authToken)
|
||||
tracker = trackers[0]
|
||||
print("Tracker name: ", tracker.trackerName)
|
||||
trips = GeorideApi.get_trips(account.auth_token, tracker.tracker_id, "2019-10-10", "2019-10-24")
|
||||
trip = trips[0]
|
||||
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")
|
||||
trip = trips[0];
|
||||
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.niceStartAddress, trip.niceEndAddress))
|
||||
positions = GeorideApi.get_positions(account.auth_token, tracker.tracker_id,
|
||||
"2019-10-10", "2019-10-24")
|
||||
position = positions[0]
|
||||
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")
|
||||
print("tripShared url: {}, id: {}".format(tripShared.url, tripShared.shareId))
|
||||
time.sleep(10)
|
||||
have_been_locked = GeorideApi.lock_tracker(account.auth_token, tracker.tracker_id)
|
||||
print("Tracker have been locked: ", have_been_locked)
|
||||
|
||||
time.sleep(30)
|
||||
haveBeenLocked = GeorideApi.lockTracker(account.authToken, tracker.trackerId)
|
||||
print("Tracker have been locked: ", haveBeenLocked)
|
||||
time.sleep(10)
|
||||
have_been_unlocked = GeorideApi.unlock_tracker(account.auth_token, tracker.tracker_id)
|
||||
print("Tracker have been unlocked: ", have_been_unlocked)
|
||||
|
||||
time.sleep(30)
|
||||
haveBeenUnlocked = GeorideApi.lockTracker(account.authToken, tracker.trackerId)
|
||||
print("Tracker have been unlocked: ", haveBeenUnlocked)
|
||||
time.sleep(10)
|
||||
is_locked = GeorideApi.toogle_lock_tracker(account.auth_token, tracker.tracker_id)
|
||||
print("Tracker is locked: ", is_locked)
|
||||
|
||||
time.sleep(30)
|
||||
isLocked = GeorideApi.toogleLockTracker(account.authToken, tracker.trackerId)
|
||||
print("Tracker is locked: ", haveBeenUnlocked)
|
||||
time.sleep(10)
|
||||
trackers = GeorideApi.get_trackers(account.auth_token)
|
||||
tracker = trackers[0]
|
||||
print("Tracker name: ", tracker.tracker_name, " is locked: ", tracker.is_locked)
|
||||
|
||||
time.sleep(30)
|
||||
trackers = GeorideApi.getTrackers(account.authToken)
|
||||
tracker = trackers[0]
|
||||
print("Tracker name: ", tracker.trackerName, " is locked: ", tracker.isLocked)
|
||||
"""
|
||||
GeorideApi.revokeToken(account.auth_token)
|
||||
""" # pylint: disable=W0105
|
||||
|
||||
"""
|
||||
GeorideApi.revokeToken(account.authToken)
|
||||
"""
|
||||
example()
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue