From 9f815817f6b31f03aeb9a3f25e10a0dc038eb1bf Mon Sep 17 00:00:00 2001 From: Julien Rossow-Greenberg Date: Sat, 17 Feb 2024 15:16:29 -0500 Subject: [PATCH] attributes handled differently --- pytdx/tdx.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pytdx/tdx.py b/pytdx/tdx.py index b022eb2..465278d 100644 --- a/pytdx/tdx.py +++ b/pytdx/tdx.py @@ -129,15 +129,23 @@ def __to_patch_payload( payload = [] for attr_name, attr_value in data_dict.items(): if attr_value is not None: - # Attributes require a different format, you have to spell each one out + # Attributes require a different format, you have to spell each one out # Attributes should be represented as a List of Dicts if attr_name == "Attributes": - # Iterate through list + # Iterate through list for item in attr_value: - # Append to payload, accessing item ID and Value k,vs. - payload.append({"op": op, "path": f"/attributes/{item["ID"]}", "value": item["Value"]}) - else: - payload.append({"op": op, "path": f"/{attr_name}", "value": attr_value}) + # Append to payload, accessing item ID and Value k,vs. + payload.append( + { + "op": op, + "path": f"""/attributes/{item["ID"]}""", + "value": item["Value"], + } + ) + else: + payload.append( + {"op": op, "path": f"/{attr_name}", "value": attr_value} + ) return payload def __request(self, method: str, url: str, data=False):