diff options
Diffstat (limited to 'fatcat_scholar/api_entities.py')
-rw-r--r-- | fatcat_scholar/api_entities.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fatcat_scholar/api_entities.py b/fatcat_scholar/api_entities.py index 738c5c8..df24eda 100644 --- a/fatcat_scholar/api_entities.py +++ b/fatcat_scholar/api_entities.py @@ -1,10 +1,10 @@ - import json import collections from fatcat_openapi_client import ApiClient _global_serde_api_client = ApiClient() + def entity_to_dict(entity, api_client=None): """ Hack to take advantage of the code-generated serialization code. @@ -19,6 +19,7 @@ def entity_to_dict(entity, api_client=None): api_client = _global_serde_api_client return api_client.sanitize_for_serialization(entity) + def entity_from_json(json_str, entity_type, api_client=None): """ Hack to take advantage of the code-generated deserialization code @@ -27,10 +28,11 @@ def entity_from_json(json_str, entity_type, api_client=None): """ if not api_client: api_client = _global_serde_api_client - thing = collections.namedtuple('Thing', ['data']) + thing = collections.namedtuple("Thing", ["data"]) thing.data = json_str return api_client.deserialize(thing, entity_type) + def entity_from_dict(obj, entity_type, api_client=None): json_str = json.dumps(obj) return entity_from_json(json_str, entity_type, api_client=api_client) |