Commit b10eefa3 authored by Martin Manchev's avatar Martin Manchev Committed by Ivan Tyagov

[Fix] Double Value Type

parent 17683dff
...@@ -47,9 +47,24 @@ class ERP5Handler(asyncua.common.subscription.SubHandler): ...@@ -47,9 +47,24 @@ class ERP5Handler(asyncua.common.subscription.SubHandler):
if self.url is not None: if self.url is not None:
return f"%s/%s" %(self.url, ERP5_REQUEST_API) return f"%s/%s" %(self.url, ERP5_REQUEST_API)
def call(self, http_method = "POST", **data): def call(self, http_method="POST", **data):
params = urllib.parse.quote_plus(json.dumps({k: str(v) for k, v in data.items()})) serialized_data = {}
for k, v in data.items():
# Convert non-serializable types to string
if not isinstance(v, (int, float, str)):
v = str(v)
elif isinstance(v, float):
# Ensure proper serialization of float values
if v.is_integer():
v = int(v)
else:
v = float(v)
serialized_data[k] = v
print(f"Key: {k}\nValue: {v}\nValue Type: {type(v)}\n\n")
params = urllib.parse.quote_plus(json.dumps(serialized_data))
self.session.auth = (erp5_username, erp5_password) self.session.auth = (erp5_username, erp5_password)
if http_method == "POST": if http_method == "POST":
self.session.post(f"{self.uri}?data={params}") self.session.post(f"{self.uri}?data={params}")
elif http_method == "GET": elif http_method == "GET":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment