Fix missign field 'cardInformation' on some client

develop
Matthieu DUVAL 3 years ago
parent 9c7d2890da
commit edf209272d

@ -956,6 +956,7 @@ class GeoRideSubscription(metaclass=JsonMgtMetaClass):
@classmethod @classmethod
def from_json(cls, json): def from_json(cls, json):
"""return new object from_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( return GeoRideSubscription(
json['id'], json['id'],
json['type'], json['type'],
@ -967,10 +968,10 @@ class GeoRideSubscription(metaclass=JsonMgtMetaClass):
cls.json_field_protect(json, 'price'), cls.json_field_protect(json, 'price'),
cls.json_field_protect(json, 'firstName'), cls.json_field_protect(json, 'firstName'),
cls.json_field_protect(json, 'lastName'), 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 """ """ Account object representation """
def __init__(self, last_digits, expiry, brand): def __init__(self, last_digits, expiry, brand):
self._last_digits = last_digits self._last_digits = last_digits
@ -997,9 +998,9 @@ class GeoRideSubscription_CardInfo:
def from_json(cls, json): def from_json(cls, json):
"""return new object from_json""" """return new object from_json"""
return GeoRideSubscription_CardInfo( return GeoRideSubscription_CardInfo(
json['lastDigits'], cls.json_field_protect(json, 'lastDigits'),
json['expiry'], cls.json_field_protect(json, 'expiry'),
json['brand'] cls.json_field_protect(json, 'brand')
) )
class GeoRideAccount: class GeoRideAccount:

@ -19,7 +19,7 @@ CURRENT_DIR = os.path.dirname(__file__)
setup( setup(
name='georideapilib', name='georideapilib',
packages=['georideapilib'], # this must be the same as the name above 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', description='Lib to control GeoRide tracker devices with theire rest api',
author='Matthieu DUVAL', author='Matthieu DUVAL',
author_email='georideapilib@duval-dev.fr', author_email='georideapilib@duval-dev.fr',

Loading…
Cancel
Save