Skip to content

Commit 4128242

Browse files
OhmniDdmurray-smar
andauthored
Add check for dict in serialize function (#48)
* fix: adds dict as a type to serialize in serialize util function, tests for additional_details in event reporting return data * fix: extra newline * chore: update changelog * chore: update changelog with note about adding to param for event reporting, markdown lint --------- Co-authored-by: dmurray <dave.murray@smartsheet.com>
1 parent 11c29ea commit 4128242

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [3.0.4] - 2024-07-29
9+
10+
### Changed
11+
12+
- Changed `serialize` function to also handle dicts - this allows the Event Reporting API to
13+
return the `additionalDetails` object correctly
14+
15+
### Added
16+
17+
- `to` parameter added for Event Reporting - allows setting an end timestamp for filtering for
18+
events
19+
820
## [3.0.3] - 2024-07-17
921

1022
### Fixed

smartsheet/util.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ def serialize(obj):
112112
serialized = serialize(item)
113113
if not hasattr(serialized, "is_explicit_null"):
114114
retval.append(serialized)
115+
116+
elif isinstance(obj, dict):
117+
retval = {}
118+
for key, value in obj.items():
119+
serialized_value = serialize(value)
120+
if not hasattr(serialized_value, "is_explicit_null"):
121+
retval[key] = serialized_value
122+
115123
else:
116124
retval = {}
117125
prop_list = get_child_properties(obj)

tests/integration/test_events.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def test_list_events(self, smart_setup):
2525
assert event.request_user_id is not None
2626
# assert event.access_token_name is not None
2727
assert event.source.value is not None
28+
if event.additional_details is not None:
29+
assert isinstance(event.additional_details, dict)
2830

2931
while events_list.more_available:
3032
events_list = smart.Events.list_events(stream_position=events_list.next_stream_position, max_count=10,
@@ -41,6 +43,8 @@ def test_list_events(self, smart_setup):
4143
assert event.request_user_id is not None
4244
# assert event.access_token_name is not None
4345
assert event.source.value is not None
46+
if event.additional_details is not None:
47+
assert isinstance(event.additional_details, dict)
4448

4549
def test_invalid_params(self, smart_setup):
4650
smart = smart_setup['smart']

0 commit comments

Comments
 (0)