-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrutils.py
More file actions
27 lines (24 loc) · 715 Bytes
/
rutils.py
File metadata and controls
27 lines (24 loc) · 715 Bytes
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
from enum import Enum
# ---
class RequestType(Enum):
MESSAGE_REQUEST = 1
CONVERSATION_STARTED_REQUEST = 2
_str_rq_to_typed = {
"MESSAGE_REQUEST" : MESSAGE_REQUEST,
"CONVERSATION_STARTED_REQUEST" : CONVERSATION_STARTED_REQUEST
}
@staticmethod
def to_enum(str_rqtype):
return _str_rq_to_typed[str_rqtype]
# ---
class RequestPayloadUT(object):
def __init__(self, payload):
self._payload = payload
def type(self):
return RequestType.to_enum(self._payload[0])
def text(self):
return self._payload[1]
def time(self):
return self._payload[2]
def user_id(self):
return self._payload[3]