|
|
|
@ -3,7 +3,12 @@ Georide objects implementation
|
|
|
|
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
class GeorideSharedTrip:
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
class GeoRideSharedTrip:
|
|
|
|
|
""" Shared trip object representation """
|
|
|
|
|
def __init__(self, url, shareId):
|
|
|
|
|
self._url = url
|
|
|
|
@ -22,12 +27,12 @@ class GeorideSharedTrip:
|
|
|
|
|
@staticmethod
|
|
|
|
|
def from_json(json):
|
|
|
|
|
"""return new object fromjson"""
|
|
|
|
|
return GeorideSharedTrip(
|
|
|
|
|
return GeoRideSharedTrip(
|
|
|
|
|
json['url'],
|
|
|
|
|
json['shareId']
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
class GeorideTrackerTrip: # pylint: disable=too-many-instance-attributes
|
|
|
|
|
class GeoRideTrackerTrip: # pylint: disable=too-many-instance-attributes
|
|
|
|
|
""" Trip object representation """
|
|
|
|
|
def __init__(self, trip_id, tracker_id, average_speed, max_speed, distance, duration, # pylint: disable=R0914, R0913
|
|
|
|
|
start_address, nice_start_address, start_lat, start_lon, end_address,
|
|
|
|
@ -134,7 +139,7 @@ class GeorideTrackerTrip: # pylint: disable=too-many-instance-attributes
|
|
|
|
|
@staticmethod
|
|
|
|
|
def from_json(json):
|
|
|
|
|
"""return new object from json"""
|
|
|
|
|
return GeorideTrackerTrip(
|
|
|
|
|
return GeoRideTrackerTrip(
|
|
|
|
|
json['id'],
|
|
|
|
|
json['trackerId'],
|
|
|
|
|
json['averageSpeed'],
|
|
|
|
@ -153,8 +158,7 @@ class GeorideTrackerTrip: # pylint: disable=too-many-instance-attributes
|
|
|
|
|
json['endTime']
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeorideTrackerPosition:
|
|
|
|
|
class GeoRideTrackerPosition:
|
|
|
|
|
""" Tracker position object representation """
|
|
|
|
|
def __init__(self, fixtime, latitude, longitude, altitude, speed, address): # pylint: disable= R0913
|
|
|
|
|
self._fixtime = fixtime
|
|
|
|
@ -197,7 +201,7 @@ class GeorideTrackerPosition:
|
|
|
|
|
@staticmethod
|
|
|
|
|
def from_json(json):
|
|
|
|
|
"""return new object fromjson"""
|
|
|
|
|
return GeorideTrackerPosition(
|
|
|
|
|
return GeoRideTrackerPosition(
|
|
|
|
|
json['fixtime'],
|
|
|
|
|
json['latitude'],
|
|
|
|
|
json['longitude'],
|
|
|
|
@ -206,10 +210,7 @@ class GeorideTrackerPosition:
|
|
|
|
|
json['address']
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeorideTracker: # pylint: disable=R0904,R0902
|
|
|
|
|
class GeoRideTracker: # pylint: disable=R0904,R0902
|
|
|
|
|
""" Tracker position object representation """
|
|
|
|
|
def __init__(self, tracker_id, tracker_name, device_button_action, device_button_delay, # pylint: disable= R0913, R0914, R0915
|
|
|
|
|
vibration_level, is_old_tracker, auto_lock_freezed_to, fixtime, role,
|
|
|
|
@ -218,34 +219,34 @@ class GeorideTracker: # pylint: disable=R0904,R0902
|
|
|
|
|
longitude, altitude, locked_position_id, locked_latitude, locked_longitude,
|
|
|
|
|
is_locked, can_see_position, can_lock, can_unlock, can_share, can_unshare,
|
|
|
|
|
can_check_speed, can_see_statistics, can_send_broken_down_signal,
|
|
|
|
|
can_send_stolen_signal, status):
|
|
|
|
|
can_send_stolen_signal, status, subscription_id, external_battery_voltage,
|
|
|
|
|
internal_battery_voltage, timezone, is_second_gen, is_up_to_date):
|
|
|
|
|
self._tracker_id = tracker_id
|
|
|
|
|
self._tracker_name = tracker_name
|
|
|
|
|
self._device_button_action = device_button_action
|
|
|
|
|
self._device_button_delay = device_button_delay
|
|
|
|
|
self._vibration_level = vibration_level
|
|
|
|
|
self._is_old_tracker = is_old_tracker
|
|
|
|
|
self._auto_lock_freezed_to = auto_lock_freezed_to
|
|
|
|
|
self._position_id = position_id
|
|
|
|
|
self._fixtime = fixtime
|
|
|
|
|
self._latitude = latitude
|
|
|
|
|
self._longitude = longitude
|
|
|
|
|
self._altitude = altitude
|
|
|
|
|
self._locked_position_id = locked_position_id
|
|
|
|
|
self._locked_latitude = locked_latitude
|
|
|
|
|
self._locked_longitude = locked_longitude
|
|
|
|
|
self._role = role
|
|
|
|
|
self._last_payment_date = last_payment_date
|
|
|
|
|
self._gift_card_id = gift_card_id
|
|
|
|
|
self._expires = expires
|
|
|
|
|
self._activation_date = activation_date
|
|
|
|
|
self._odometer = odometer
|
|
|
|
|
self._is_locked = is_locked
|
|
|
|
|
self._is_stolen = is_stolen
|
|
|
|
|
self._is_crashed = is_crashed
|
|
|
|
|
self._crash_detection_disabled = crash_detection_disabled
|
|
|
|
|
self._speed = speed
|
|
|
|
|
self._moving = moving
|
|
|
|
|
self._position_id = position_id
|
|
|
|
|
self._latitude = latitude
|
|
|
|
|
self._longitude = longitude
|
|
|
|
|
self._altitude = altitude
|
|
|
|
|
self._locked_position_id = locked_position_id
|
|
|
|
|
self._locked_latitude = locked_latitude
|
|
|
|
|
self._locked_longitude = locked_longitude
|
|
|
|
|
self._is_locked = is_locked
|
|
|
|
|
self._can_see_position = can_see_position
|
|
|
|
|
self._can_lock = can_lock
|
|
|
|
|
self._can_unlock = can_unlock
|
|
|
|
@ -256,7 +257,13 @@ class GeorideTracker: # pylint: disable=R0904,R0902
|
|
|
|
|
self._can_send_broken_down_signal = can_send_broken_down_signal
|
|
|
|
|
self._can_send_stolen_signal = can_send_stolen_signal
|
|
|
|
|
self._status = status
|
|
|
|
|
|
|
|
|
|
self._auto_lock_freezed_to = auto_lock_freezed_to
|
|
|
|
|
self._subscription_id = subscription_id
|
|
|
|
|
self._external_battery_voltage = external_battery_voltage
|
|
|
|
|
self._internal_battery_voltage = internal_battery_voltage
|
|
|
|
|
self._timezone = timezone
|
|
|
|
|
self._is_second_gen = is_second_gen
|
|
|
|
|
self._is_up_to_date = is_up_to_date
|
|
|
|
|
@property
|
|
|
|
|
def tracker_id(self):
|
|
|
|
|
""" tracker_id """
|
|
|
|
@ -336,12 +343,22 @@ class GeorideTracker: # pylint: disable=R0904,R0902
|
|
|
|
|
def is_stolen(self):
|
|
|
|
|
""" is_stolen """
|
|
|
|
|
return self._is_stolen
|
|
|
|
|
|
|
|
|
|
@is_stolen.setter
|
|
|
|
|
def is_stolen(self, is_stolen):
|
|
|
|
|
""" is_stolen setter"""
|
|
|
|
|
self._is_stolen = is_stolen
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def is_crashed(self):
|
|
|
|
|
""" is_crashed """
|
|
|
|
|
return self._is_crashed
|
|
|
|
|
|
|
|
|
|
@is_crashed.setter
|
|
|
|
|
def is_crashed(self, is_crashed):
|
|
|
|
|
""" is_crashed setter"""
|
|
|
|
|
self._is_crashed = is_crashed
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def crash_detection_disabled(self):
|
|
|
|
|
""" crash_detection_disabled """
|
|
|
|
@ -487,10 +504,41 @@ class GeorideTracker: # pylint: disable=R0904,R0902
|
|
|
|
|
""" status """
|
|
|
|
|
self._status = status
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def subscription_id(self):
|
|
|
|
|
"""subscription_id property"""
|
|
|
|
|
return self._subscription_id
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def external_battery_voltage(self):
|
|
|
|
|
"""_external_battery_voltage property"""
|
|
|
|
|
return self._external_battery_voltage
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def internal_battery_voltage(self):
|
|
|
|
|
"""internal_battery_voltage property"""
|
|
|
|
|
return self._internal_battery_voltage
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def timezone(self):
|
|
|
|
|
"""timezone property"""
|
|
|
|
|
return self._timezone
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def is_second_gen(self):
|
|
|
|
|
"""is_second_gen property"""
|
|
|
|
|
return self._is_second_gen
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def is_up_to_date(self):
|
|
|
|
|
"""is_up_to_date property"""
|
|
|
|
|
return self._is_up_to_date
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def from_json(json):
|
|
|
|
|
"""return new object fromjson"""
|
|
|
|
|
return GeorideTracker(
|
|
|
|
|
return GeoRideTracker(
|
|
|
|
|
json['trackerId'],
|
|
|
|
|
json['trackerName'],
|
|
|
|
|
json['deviceButtonAction'],
|
|
|
|
@ -527,11 +575,61 @@ class GeorideTracker: # pylint: disable=R0904,R0902
|
|
|
|
|
json['canSeeStatistics'],
|
|
|
|
|
json['canSendBrokenDownSignal'],
|
|
|
|
|
json['canSendStolenSignal'],
|
|
|
|
|
json['status']
|
|
|
|
|
json['status'],
|
|
|
|
|
None if json['subscriptionId'] == "None" else json['subscriptionId'],
|
|
|
|
|
None if json['externalBatteryVoltage'] == "None" else json['externalBatteryVoltage'],
|
|
|
|
|
None if json['internalBatteryVoltage'] == "None" else json['internalBatteryVoltage'],
|
|
|
|
|
json['timezone'],
|
|
|
|
|
json['isSecondGen'],
|
|
|
|
|
json['isUpToDate']
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeorideAccount:
|
|
|
|
|
def update_all_data(self, tracker):
|
|
|
|
|
"""update all data of th tracker from anew object"""
|
|
|
|
|
self._tracker_name = tracker.tracker_name
|
|
|
|
|
self._device_button_action = tracker.device_button_action
|
|
|
|
|
self._device_button_delay = tracker.device_button_delay
|
|
|
|
|
self._vibration_level = tracker.vibration_level
|
|
|
|
|
self._is_old_tracker = tracker.is_old_tracker
|
|
|
|
|
self._position_id = tracker.position_id
|
|
|
|
|
self._fixtime = tracker.fixtime
|
|
|
|
|
self._latitude = tracker.latitude
|
|
|
|
|
self._longitude = tracker.longitude
|
|
|
|
|
self._altitude = tracker.altitude
|
|
|
|
|
self._locked_position_id = tracker.locked_position_id
|
|
|
|
|
self._locked_latitude = tracker.locked_latitude
|
|
|
|
|
self._locked_longitude = tracker.locked_longitude
|
|
|
|
|
self._role = tracker.role
|
|
|
|
|
self._last_payment_date = tracker.last_payment_date
|
|
|
|
|
self._gift_card_id = tracker.gift_card_id
|
|
|
|
|
self._expires = tracker.expires
|
|
|
|
|
self._activation_date = tracker.activation_date
|
|
|
|
|
self._odometer = tracker.odometer
|
|
|
|
|
self._is_locked = tracker.is_locked
|
|
|
|
|
self._is_stolen = tracker.is_stolen
|
|
|
|
|
self._is_crashed = tracker.is_crashed
|
|
|
|
|
self._crash_detection_disabled = tracker.crash_detection_disabled
|
|
|
|
|
self._speed = tracker.speed
|
|
|
|
|
self._moving = tracker.moving
|
|
|
|
|
self._can_see_position = tracker.can_see_position
|
|
|
|
|
self._can_lock = tracker.can_lock
|
|
|
|
|
self._can_unlock = tracker.can_unlock
|
|
|
|
|
self._can_share = tracker.can_share
|
|
|
|
|
self._can_unshare = tracker.can_unshare
|
|
|
|
|
self._can_check_speed = tracker.can_check_speed
|
|
|
|
|
self._can_see_statistics = tracker.can_see_statistics
|
|
|
|
|
self._can_send_broken_down_signal = tracker.can_send_broken_down_signal
|
|
|
|
|
self._can_send_stolen_signal = tracker.can_send_stolen_signal
|
|
|
|
|
self._status = tracker.status
|
|
|
|
|
self._auto_lock_freezed_to = tracker.auto_lock_freezed_to
|
|
|
|
|
self._subscription_id = tracker.subscription_id
|
|
|
|
|
self._external_battery_voltage = tracker.external_battery_voltage
|
|
|
|
|
self._internal_battery_voltage = tracker.internal_battery_voltage
|
|
|
|
|
self._timezone = tracker.timezone
|
|
|
|
|
self._is_second_gen = tracker.is_second_gen
|
|
|
|
|
self._is_up_to_date = tracker.is_up_to_date
|
|
|
|
|
|
|
|
|
|
class GeoRideAccount:
|
|
|
|
|
""" Account object representation """
|
|
|
|
|
def __init__(self, account_id, email, is_admin, auth_token):
|
|
|
|
|
self._account_id = account_id
|
|
|
|
@ -567,7 +665,7 @@ class GeorideAccount:
|
|
|
|
|
@staticmethod
|
|
|
|
|
def from_json(json):
|
|
|
|
|
"""return new object from_json"""
|
|
|
|
|
return GeorideAccount(
|
|
|
|
|
return GeoRideAccount(
|
|
|
|
|
json['id'],
|
|
|
|
|
json['email'],
|
|
|
|
|
json['isAdmin'],
|
|
|
|
@ -575,7 +673,8 @@ class GeorideAccount:
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeorideUser: # pylint: disable= R0902
|
|
|
|
|
|
|
|
|
|
class GeoRideUser: # pylint: disable= R0902
|
|
|
|
|
""" User object representation """
|
|
|
|
|
def __init__(self, user_id, email, first_name, created_at, phone_number, # pylint: disable= R0913
|
|
|
|
|
push_user_token, legal, date_of_birth):
|
|
|
|
@ -631,7 +730,7 @@ class GeorideUser: # pylint: disable= R0902
|
|
|
|
|
@staticmethod
|
|
|
|
|
def from_json(json):
|
|
|
|
|
"""return new object fromjson"""
|
|
|
|
|
return GeorideUser(
|
|
|
|
|
return GeoRideUser(
|
|
|
|
|
json['id'],
|
|
|
|
|
json['email'],
|
|
|
|
|
json['firstName'],
|
|
|
|
@ -641,3 +740,95 @@ class GeorideUser: # pylint: disable= R0902
|
|
|
|
|
json['legal'],
|
|
|
|
|
json['dateOfBirth']
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
#TODO: remove in v0.8.0
|
|
|
|
|
class GeorideSharedTrip(GeoRideSharedTrip):
|
|
|
|
|
""" Shared trip object representation """
|
|
|
|
|
|
|
|
|
|
def __init_subclass__(cls, **kwargs):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init_subclass__(**kwargs)
|
|
|
|
|
_LOGGER.warning(
|
|
|
|
|
"GeorideSharedTrip is deprecated, modify %s to use GeoRideSharedTrip",
|
|
|
|
|
cls.__name__,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def __init__(self, *argv):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init__(*argv)
|
|
|
|
|
_LOGGER.warning("GeorideSharedTrip is deprecated, modify your code to use GeoRideSharedTrip")
|
|
|
|
|
|
|
|
|
|
class GeorideTrackerTrip(GeoRideTrackerTrip):
|
|
|
|
|
""" Trip object representation """
|
|
|
|
|
def __init_subclass__(cls, **kwargs):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init_subclass__(**kwargs)
|
|
|
|
|
_LOGGER.warning(
|
|
|
|
|
"GeorideTrackerTrip is deprecated, modify %s to use GeoRideTrackerTrip",
|
|
|
|
|
cls.__name__,
|
|
|
|
|
)
|
|
|
|
|
def __init__(self, *argv):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init__(*argv)
|
|
|
|
|
_LOGGER.warning("GeorideTrackerTrip is deprecated, modify your code to use GeoRideTrackerTrip")
|
|
|
|
|
|
|
|
|
|
class GeorideTrackerPosition(GeoRideTrackerPosition):
|
|
|
|
|
""" Trip object representation """
|
|
|
|
|
def __init_subclass__(cls, **kwargs):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init_subclass__(**kwargs)
|
|
|
|
|
_LOGGER.warning(
|
|
|
|
|
"GeorideTrackerPosition is deprecated, modify %s to use GeoRideTrackerPosition",
|
|
|
|
|
cls.__name__,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def __init__(self, *argv):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init__(*argv)
|
|
|
|
|
_LOGGER.warning("GeorideTrackerPosition is deprecated, modify your code to use GeoRideTrackerPosition")
|
|
|
|
|
|
|
|
|
|
class GeorideTracker(GeoRideTracker):
|
|
|
|
|
""" Trip object representation """
|
|
|
|
|
def __init_subclass__(cls, **kwargs):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init_subclass__(**kwargs)
|
|
|
|
|
_LOGGER.warning(
|
|
|
|
|
"GeorideTracker is deprecated, modify %s to use GeoRideTracker",
|
|
|
|
|
cls.__name__,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def __init__(self, *argv):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init__(*argv)
|
|
|
|
|
_LOGGER.warning("GeorideTracker is deprecated, modify your code to use GeoRideTracker")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeorideAccount(GeoRideAccount):
|
|
|
|
|
""" Trip object representation """
|
|
|
|
|
def __init_subclass__(cls, **kwargs):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init_subclass__(**kwargs)
|
|
|
|
|
_LOGGER.warning(
|
|
|
|
|
"GeorideAccount is deprecated, modify %s to use GeoRideAccount",
|
|
|
|
|
cls.__name__,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def __init__(self, *argv):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init__(*argv)
|
|
|
|
|
_LOGGER.warning("GeorideAccount is deprecated, modify your code to use GeoRideAccount")
|
|
|
|
|
|
|
|
|
|
class GeorideUser(GeoRideUser):
|
|
|
|
|
""" Trip object representation """
|
|
|
|
|
def __init_subclass__(cls, **kwargs):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init_subclass__(**kwargs)
|
|
|
|
|
_LOGGER.warning(
|
|
|
|
|
"GeorideUser is deprecated, modify %s to use GeoRideUser",
|
|
|
|
|
cls.__name__,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def __init__(self, *argv):
|
|
|
|
|
"""Print deprecation warning."""
|
|
|
|
|
super().__init__(*argv)
|
|
|
|
|
_LOGGER.warning("GeorideUser is deprecated, modify your code to use GeoRideUser")
|
|
|
|
|