Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 733ef83127 | |||
| edf209272d | |||
| b53fdc07f8 | |||
| 9c7d2890da | |||
| d93bab0fcf | |||
| eb260b7a7e | |||
| e29e530d42 | |||
| 6db3afcd28 | |||
| 841740ec4c |
@@ -28,10 +28,13 @@ def example():
|
||||
def locked_locked(data):
|
||||
_LOGGER.info("Lock received")
|
||||
|
||||
def refresh_tracker():
|
||||
_LOGGER.info("Refresh tracker recieved")
|
||||
|
||||
def connect_socket(account):
|
||||
socket = GeoRideSocket()
|
||||
socket.subscribe_locked(locked_locked)
|
||||
socket.subscribe_refresh_tracker(refresh_tracker)
|
||||
socket.init()
|
||||
socket.connect(account.auth_token)
|
||||
time.sleep(10)
|
||||
|
||||
@@ -13,7 +13,8 @@ from georideapilib.objects import (
|
||||
GeoRideUser,
|
||||
GeoRideTrackerTrip,
|
||||
GeoRideTrackerPosition,
|
||||
GeoRideSharedTrip
|
||||
GeoRideSharedTrip,
|
||||
GeoRideTrackerBeacon
|
||||
)
|
||||
|
||||
from georideapilib.exception import (
|
||||
@@ -128,7 +129,7 @@ def get_trackers(token):
|
||||
trackers.append(GeoRideTracker.from_json(json_tracker))
|
||||
return trackers
|
||||
|
||||
def get_tracker_beacon(token, tracker_id):
|
||||
def get_tracker_beacons(token, tracker_id):
|
||||
""" get user trackers """
|
||||
|
||||
headers = {"Authorization": "Bearer " + token}
|
||||
@@ -137,11 +138,13 @@ def get_tracker_beacon(token, tracker_id):
|
||||
headers=headers)
|
||||
|
||||
response_data = response.json()
|
||||
trackers_beacons = []
|
||||
if response.status_code == 200:
|
||||
response_data['linked_tracker_id'] = tracker_id
|
||||
return GeoRideTrackerBeacon.from_json(response_data)
|
||||
else:
|
||||
return None
|
||||
for json_tracker_beacon in response_data:
|
||||
_LOGGER.debug(json_tracker_beacon)
|
||||
json_tracker_beacon['linked_tracker_id'] = tracker_id
|
||||
trackers_beacons.append(GeoRideTrackerBeacon.from_json(json_tracker_beacon))
|
||||
return trackers_beacons
|
||||
|
||||
def get_trips(token, tracker_id, from_date, to_date):
|
||||
""" return all trips between two dates """
|
||||
|
||||
@@ -882,7 +882,7 @@ class GeoRideTrackerBeacon:
|
||||
self._power = tracker_beacon.power
|
||||
|
||||
|
||||
class GeoRideSubscription:
|
||||
class GeoRideSubscription(metaclass=JsonMgtMetaClass):
|
||||
""" Account object representation """
|
||||
def __init__(self, subscription_id, subscription_type, initial_date, next_payment_date,
|
||||
status, paused_since, cancel_requested, price, first_name, last_name, card_information):
|
||||
@@ -956,21 +956,22 @@ class GeoRideSubscription:
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
"""return new object from_json"""
|
||||
card_info = GeoRideSubscription_CardInfo.from_json(json['cardInformation']) if cls.json_field_protect(json, 'cardInformation', None) is not None else {}
|
||||
return GeoRideSubscription(
|
||||
json['id'],
|
||||
json['type'],
|
||||
json['initialDate'],
|
||||
json['nextPaymentDate'],
|
||||
json['status'],
|
||||
json['pausedSince'],
|
||||
json['cancelRequested'],
|
||||
json['price'],
|
||||
json['firstName'],
|
||||
json['lastName'],
|
||||
GeoRideSubscription_CardInfo.from_json(json['cardInformation'])
|
||||
cls.json_field_protect(json, 'initialDate'),
|
||||
cls.json_field_protect(json, 'nextPaymentDate'),
|
||||
cls.json_field_protect(json, 'status'),
|
||||
cls.json_field_protect(json, 'pausedSince'),
|
||||
cls.json_field_protect(json, 'cancelRequested'),
|
||||
cls.json_field_protect(json, 'price'),
|
||||
cls.json_field_protect(json, 'firstName'),
|
||||
cls.json_field_protect(json, 'lastName'),
|
||||
card_info
|
||||
)
|
||||
|
||||
class GeoRideSubscription_CardInfo:
|
||||
class GeoRideSubscription_CardInfo(metaclass=JsonMgtMetaClass):
|
||||
""" Account object representation """
|
||||
def __init__(self, last_digits, expiry, brand):
|
||||
self._last_digits = last_digits
|
||||
@@ -997,9 +998,9 @@ class GeoRideSubscription_CardInfo:
|
||||
def from_json(cls, json):
|
||||
"""return new object from_json"""
|
||||
return GeoRideSubscription_CardInfo(
|
||||
json['lastDigits'],
|
||||
json['expiry'],
|
||||
json['brand']
|
||||
cls.json_field_protect(json, 'lastDigits'),
|
||||
cls.json_field_protect(json, 'expiry'),
|
||||
cls.json_field_protect(json, 'brand')
|
||||
)
|
||||
|
||||
class GeoRideAccount:
|
||||
|
||||
@@ -112,19 +112,3 @@ class GeoRideSocket():
|
||||
def disconnect(self):
|
||||
"""disconnect from the georide socket"""
|
||||
sio.disconnect()
|
||||
|
||||
|
||||
#TODO: remove in v0.8.0
|
||||
class GeorideSocket(GeoRideSocket):
|
||||
""" Trip object representation """
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
"""Print deprecation warning."""
|
||||
super().__init_subclass__(**kwargs)
|
||||
_LOGGER.warning(
|
||||
"GeorideSocket is deprecated, modify %s to use GeoRideSocket",
|
||||
cls.__name__,
|
||||
)
|
||||
def __init__(self, *argv):
|
||||
"""Print deprecation warning."""
|
||||
super().__init__(*argv)
|
||||
_LOGGER.warning("GeorideSocket is deprecated, modify your code to use GeoRideSocket")
|
||||
4
setup.py
4
setup.py
@@ -19,13 +19,13 @@ CURRENT_DIR = os.path.dirname(__file__)
|
||||
setup(
|
||||
name='georideapilib',
|
||||
packages=['georideapilib'], # this must be the same as the name above
|
||||
version='0.8.0',
|
||||
version='0.8.4',
|
||||
description='Lib to control GeoRide tracker devices with theire rest api',
|
||||
author='Matthieu DUVAL',
|
||||
author_email='georideapilib@duval-dev.fr',
|
||||
# use the URL to the github repo
|
||||
url='https://github.com/hacf/georide-api',
|
||||
download_url='https://codeload.github.com/hacf/georide-api/tar.gz/0.8.0',
|
||||
download_url='https://codeload.github.com/hacf/georide-api/tar.gz/0.8.1',
|
||||
keywords=['rest', 'georide', 'api', 'grutier', 'GeoRide'], # arbitrary keywords
|
||||
classifiers=[],
|
||||
install_requires=["python-socketio[client]==4.6.1"],
|
||||
|
||||
Reference in New Issue
Block a user