chatgraph 0.3.4__tar.gz → 0.3.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chatgraph might be problematic. Click here for more details.
- {chatgraph-0.3.4 → chatgraph-0.3.5}/PKG-INFO +1 -1
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/types/request_types.py +52 -8
- {chatgraph-0.3.4 → chatgraph-0.3.5}/pyproject.toml +1 -1
- {chatgraph-0.3.4 → chatgraph-0.3.5}/LICENSE +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/README.md +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/__init__.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/auth/credentials.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/bot/chatbot_model.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/bot/chatbot_router.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/cli/__init__.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/error/chatbot_error.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/error/route_error.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/gRPC/gRPCCall.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/messages/message_consumer.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/pb/userstate.proto +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/pb/userstate_pb2.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/pb/userstate_pb2_grpc.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/pb/voll.proto +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/pb/voll_pb2.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/pb/voll_pb2_grpc.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/types/end_types.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/types/message_types.py +0 -0
- {chatgraph-0.3.4 → chatgraph-0.3.5}/chatgraph/types/route.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from
|
|
2
|
-
from .message_types import Message, Button, ListElements, messageTypes, MessageTypes
|
|
1
|
+
from chatgraph.gRPC.gRPCCall import WhatsappServiceClient, UserStateServiceClient
|
|
2
|
+
from chatgraph.types.message_types import Message, Button, ListElements, messageTypes, MessageTypes
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
from typing import Optional
|
|
5
|
-
import json
|
|
5
|
+
import json, os
|
|
6
6
|
|
|
7
7
|
@dataclass
|
|
8
8
|
class UserState:
|
|
@@ -15,12 +15,56 @@ class UserState:
|
|
|
15
15
|
lst_update (str): A última atualização do menu.
|
|
16
16
|
obs (dict): Observações adicionais sobre o estado do usuário.
|
|
17
17
|
"""
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
customer_id: str,
|
|
21
|
+
menu: str,
|
|
22
|
+
route: str,
|
|
23
|
+
lst_update: Optional[str]=None,
|
|
24
|
+
obs: Optional[dict] = None,
|
|
25
|
+
direction_in: Optional[bool] = True,
|
|
26
|
+
) -> None:
|
|
27
|
+
|
|
28
|
+
self.customer_id = customer_id
|
|
29
|
+
self.menu = menu
|
|
30
|
+
self.route = route
|
|
31
|
+
self.lst_update = lst_update
|
|
32
|
+
self.obs = obs
|
|
33
|
+
self.direction_in = direction_in
|
|
34
|
+
|
|
35
|
+
def __str__(self):
|
|
36
|
+
return f"UserState:\n\tcustomer_id={self.customer_id},\n\tmenu={self.menu},\n\troute={self.route},\n\tlst_update={self.lst_update},\n\tobs={self.obs},\n\tdirection_in={self.direction_in}"
|
|
23
37
|
|
|
38
|
+
def insert(self, grpc_uri: Optional[str] = None) -> None:
|
|
39
|
+
if grpc_uri is None:
|
|
40
|
+
grpc_uri = os.getenv('GRPC_URI')
|
|
41
|
+
user_state_client = UserStateServiceClient(grpc_uri)
|
|
42
|
+
|
|
43
|
+
user_state_client.insert_user_state({
|
|
44
|
+
'user_id': self.customer_id,
|
|
45
|
+
'menu_id': self.menu,
|
|
46
|
+
'route': self.route,
|
|
47
|
+
'obs': json.dumps(self.obs),
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
def update(self, grpc_uri: Optional[str] = None) -> None:
|
|
51
|
+
if grpc_uri is None:
|
|
52
|
+
grpc_uri = os.getenv('GRPC_URI')
|
|
53
|
+
user_state_client = UserStateServiceClient(grpc_uri)
|
|
54
|
+
|
|
55
|
+
user_state_client.update_user_state({
|
|
56
|
+
'user_id': self.customer_id,
|
|
57
|
+
'menu_id': self.menu,
|
|
58
|
+
'route': self.route,
|
|
59
|
+
'obs': json.dumps(self.obs),
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
def delete(self, grpc_uri: Optional[str] = None) -> None:
|
|
63
|
+
if grpc_uri is None:
|
|
64
|
+
grpc_uri = os.getenv('GRPC_URI')
|
|
65
|
+
user_state_client = UserStateServiceClient(grpc_uri)
|
|
66
|
+
|
|
67
|
+
user_state_client.delete_user_state(self.customer_id)
|
|
24
68
|
|
|
25
69
|
class UserCall:
|
|
26
70
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|