-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventInfo.py
40 lines (25 loc) · 933 Bytes
/
EventInfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import json
from collections import namedtuple
class BayInfo:
def __init__(self, isForAllBays: bool, bayId: str):
self.isForAllBays = isForAllBays
self.bayId = bayId
class Header:
def __init__(self, sent_by: str, sent_to: list[str], event_name: str, bay_info: BayInfo):
self.sentBy = sent_by
self.sentTo = sent_to
self.eventName = event_name
self.bayInfo = bay_info
class Data:
def __init__(self, value):
self.value = value
class EventInfo:
def __init__(self, header: Header, data: Data):
self.header = header
self.data = data
def customEventInfoDecoder(eventInfoDict):
return namedtuple('X', eventInfoDict.keys())(*eventInfoDict.values())
def getEventInfoObject(eventInfoJson):
return json.loads(eventInfoJson, object_hook=customEventInfoDecoder)
def getEventInfoDict(eventInfoJson):
return json.loads(eventInfoJson)