chatgraph 0.3.4__py3-none-any.whl → 0.3.5__py3-none-any.whl

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.

@@ -1,8 +1,8 @@
1
- from ..gRPC.gRPCCall import WhatsappServiceClient, UserStateServiceClient
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
- customer_id: str
19
- menu: str
20
- route: str
21
- lst_update: str
22
- obs: Optional[dict] = None
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
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chatgraph
3
- Version: 0.3.4
3
+ Version: 0.3.5
4
4
  Summary: A user-friendly chatbot library
5
5
  Home-page: https://github.com/irissonnlima/chatgraph
6
6
  License: MIT
@@ -15,10 +15,10 @@ chatgraph/pb/voll_pb2.py,sha256=IkopsIc8x-lS9j6WpL9Wk5MHl41FDa8cU0kmZRpKKKY,5291
15
15
  chatgraph/pb/voll_pb2_grpc.py,sha256=U-_nXTAIEzo2GMYjHiphbSyTx3zyipsnKebFuZuoU1k,17685
16
16
  chatgraph/types/end_types.py,sha256=--Ty2gM_y7J-yRAvZV26e4HMUpoguAMAhfOIS9-kQTk,1316
17
17
  chatgraph/types/message_types.py,sha256=-GQAQi1iMz1ysZLAXJImIg34ObnSJnhz7zv6VBrlNuw,3364
18
- chatgraph/types/request_types.py,sha256=ZTJY-jc4zwPO4cfpksL7J0MKtYuTtecn9ZObkTSi9OU,8577
18
+ chatgraph/types/request_types.py,sha256=Huv9qcaR3ltmOEtrP7lAiGVYTIGjWnGEtSN1ag5IL9o,10303
19
19
  chatgraph/types/route.py,sha256=2fuHEPKUL_Vuv4g8pB6M7eJLouxXasqjesdju6_eumE,2757
20
- chatgraph-0.3.4.dist-info/entry_points.txt,sha256=bO9_Q-PqE5vCNNo6ke_-3j2gHfKQMDGnKDTkNuCdBuA,48
21
- chatgraph-0.3.4.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
22
- chatgraph-0.3.4.dist-info/METADATA,sha256=hHLj0Qq0hX0TFE8xpHmjA4xQc_YLC51cld9uBOnTbX8,12781
23
- chatgraph-0.3.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
24
- chatgraph-0.3.4.dist-info/RECORD,,
20
+ chatgraph-0.3.5.dist-info/entry_points.txt,sha256=bO9_Q-PqE5vCNNo6ke_-3j2gHfKQMDGnKDTkNuCdBuA,48
21
+ chatgraph-0.3.5.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
22
+ chatgraph-0.3.5.dist-info/METADATA,sha256=L_CDt9AKggDZhHZujk2AgvJxhPj5NRGhT1U02rbb0C4,12781
23
+ chatgraph-0.3.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
24
+ chatgraph-0.3.5.dist-info/RECORD,,