Skip to content

Commit

Permalink
Merge pull request #13 from yyolk/more-nits-deux-20221110
Browse files Browse the repository at this point in the history
More nits deux 20221110
  • Loading branch information
yyolk authored Nov 10, 2022
2 parents c297b7b + ca3d832 commit 779b33b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions dexie.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def __init__(self, model, model_cls):
self._model_cls = model_cls

def convert(self, value):
if hasattr(value, "json"):
if hasattr(value, "json") and callable(value.get("json")):
data = value.json()
else:
# this is a safe fallback that should be forwards compatible to
Expand All @@ -221,17 +221,17 @@ def convert(self, value):

if data.get("success"):
if self._model is not None:
# sometimes we do need to inject more data like HistoricalTrades
# which doesn't just have a single key with all the data
# we could detect it here, but we can maybe also pass the req_def
# collections are plural
if self._model.endswith("s"):
datas = data[self._model]
return [self._model_cls(**datum) for datum in datas]
return self._model_cls(**data[self._model])

# we wrap our data with our model_cls
# sometimes we do need to inject more data like HistoricalTrades
# which doesn't just have a single key with all the data
# remove the response success key, which we no longer need
model_data = {k: data[k] for k in data if k != "success"}
# we wrap our data with our model_cls
return self._model_cls(**model_data)

return data
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build-backend = "hatchling.build"

[project]
name = "dexie.py"
version = "0.0.8"
version = "0.0.9"
authors = [
{ name="Joseph Chiocchi", email="joe@yolk.cc" },
]
Expand Down

0 comments on commit 779b33b

Please sign in to comment.