Commit 576677e1 authored by Martin Manchev's avatar Martin Manchev

[Fix] Double Value Type

parent 9250011c
......@@ -47,13 +47,28 @@ class ERP5Handler(asyncua.common.subscription.SubHandler):
if self.url is not None:
return f"%s/%s" %(self.url, ERP5_REQUEST_API)
def call(self, http_method = "POST", **data):
params = urllib.parse.quote_plus(json.dumps({k: str(v) for k, v in data.items()}))
def call(self, http_method="POST", **data):
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)
if http_method == "POST":
self.session.post(f"{self.uri}?data={params}")
self.session.post(f"{self.uri}?data={params}")
elif http_method == "GET":
return self.session.get(f"{self.uri}")
return self.session.get(f"{self.uri}")
def datachange_notification(self, node, val, data):
self.call(node=node, val=val, data=data)
......
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