From edf209272dd6983244f4b4a7c8f6363914da3f12 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Sun, 20 Mar 2022 14:01:22 +0100 Subject: [PATCH] Fix missign field 'cardInformation' on some client --- georideapilib/objects.py | 11 ++++++----- setup.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/georideapilib/objects.py b/georideapilib/objects.py index c3ec246..0724d23 100644 --- a/georideapilib/objects.py +++ b/georideapilib/objects.py @@ -956,6 +956,7 @@ class GeoRideSubscription(metaclass=JsonMgtMetaClass): @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'], @@ -967,10 +968,10 @@ class GeoRideSubscription(metaclass=JsonMgtMetaClass): cls.json_field_protect(json, 'price'), cls.json_field_protect(json, 'firstName'), cls.json_field_protect(json, 'lastName'), - GeoRideSubscription_CardInfo.from_json(json['cardInformation']) + 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: diff --git a/setup.py b/setup.py index e5eedba..b35567c 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ CURRENT_DIR = os.path.dirname(__file__) setup( name='georideapilib', packages=['georideapilib'], # this must be the same as the name above - version='0.8.3', + version='0.8.4', description='Lib to control GeoRide tracker devices with theire rest api', author='Matthieu DUVAL', author_email='georideapilib@duval-dev.fr',