Skip to content

Conversation

@JohnLZeller
Copy link

@JohnLZeller JohnLZeller commented Mar 30, 2021

The Synapse API supports using a filter string in calls to get all transactions, however, this package does not support this feature.

The API docs show this input as a string, though it's more than that, it should be a valid JSON string. This PR is the barebones approach, user is responsible for making the input a string. An alternative could obviously be to handle JSON serializing the string if it's possible, automatically under the hood. Happy to do that if you'd prefer.

jenstroeger
jenstroeger previously approved these changes Apr 27, 2021
Copy link

@jenstroeger jenstroeger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@jenstroeger
Copy link

jenstroeger commented Apr 27, 2021

@JohnLZeller, thanks for the PR.

The API docs show this input as a string, though it's more than that, it should be a valid JSON string.

Either that, or a JSON-serializable object. And I guess the code would be something along those lines:

if filter is None:
    pass  # No filter, don’t serialize.
elif isinstance(filter, str):
    try:
        _ = json.loads(filter)  # All good, a valid JSON string.
    except json.decoder.JSONDecodeError as e:
        raise ValueError("filter is not a valid JSON string") from e
else:
    try:
        filter = json.dumps(filter)  # All good, a JSON serializable object.
    except TypeError as e:
        raise ValueError("filter is not JSON serializable") from e
# Continue to use `filter` as JSON serialized string.

Happy to do that if you'd prefer.

That’d be great 👍🏼

@JohnLZeller
Copy link
Author

@jenstroeger no problem, how's this! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants