chatgraph 0.3.12__py3-none-any.whl → 0.3.14__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.

@@ -24,7 +24,7 @@ _sym_db = _symbol_database.Default()
24
24
 
25
25
 
26
26
 
27
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fuserstate.proto\x12\tuserstate\"\x06\n\x04Void\"j\n\tUserState\x12\x0f\n\x07user_id\x18\x01 \x01(\t\x12\x0f\n\x07menu_id\x18\x02 \x01(\t\x12\r\n\x05route\x18\x03 \x01(\t\x12\x0b\n\x03obs\x18\x04 \x01(\t\x12\x0c\n\x04\x64\x61te\x18\x05 \x01(\t\x12\x11\n\tdirection\x18\x06 \x01(\t\"\x1e\n\x0bUserStateId\x12\x0f\n\x07user_id\x18\x01 \x01(\t\"0\n\rRequestStatus\x12\x0e\n\x06status\x18\x01 \x01(\x08\x12\x0f\n\x07message\x18\x02 \x01(\t\";\n\x0eUserStatesList\x12)\n\x0buser_states\x18\x01 \x03(\x0b\x32\x14.userstate.UserState2\xde\x02\n\x10UserStateService\x12?\n\x0fSelectUserState\x12\x16.userstate.UserStateId\x1a\x14.userstate.UserState\x12\x41\n\x0fInsertUserState\x12\x14.userstate.UserState\x1a\x18.userstate.RequestStatus\x12\x41\n\x0fUpdateUserState\x12\x14.userstate.UserState\x1a\x18.userstate.RequestStatus\x12\x43\n\x0f\x44\x65leteUserState\x12\x16.userstate.UserStateId\x1a\x18.userstate.RequestStatus\x12>\n\x10GetAllUserStates\x12\x0f.userstate.Void\x1a\x19.userstate.UserStatesListB\x10Z\x0e./pb/userstateb\x06proto3')
27
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fuserstate.proto\x12\tuserstate\"\x06\n\x04Void\"\x8d\x01\n\tUserState\x12\x0f\n\x07user_id\x18\x01 \x01(\t\x12\x0f\n\x07menu_id\x18\x02 \x01(\t\x12\r\n\x05route\x18\x03 \x01(\t\x12\x0b\n\x03obs\x18\x04 \x01(\t\x12\x0c\n\x04\x64\x61te\x18\x05 \x01(\t\x12\x11\n\tdirection\x18\x06 \x01(\x08\x12\x0f\n\x07voll_id\x18\x07 \x01(\t\x12\x10\n\x08platform\x18\x08 \x01(\t\"\x1e\n\x0bUserStateId\x12\x0f\n\x07user_id\x18\x01 \x01(\t\"0\n\rRequestStatus\x12\x0e\n\x06status\x18\x01 \x01(\x08\x12\x0f\n\x07message\x18\x02 \x01(\t\";\n\x0eUserStatesList\x12)\n\x0buser_states\x18\x01 \x03(\x0b\x32\x14.userstate.UserState2\xde\x02\n\x10UserStateService\x12?\n\x0fSelectUserState\x12\x16.userstate.UserStateId\x1a\x14.userstate.UserState\x12\x41\n\x0fInsertUserState\x12\x14.userstate.UserState\x1a\x18.userstate.RequestStatus\x12\x41\n\x0fUpdateUserState\x12\x14.userstate.UserState\x1a\x18.userstate.RequestStatus\x12\x43\n\x0f\x44\x65leteUserState\x12\x16.userstate.UserStateId\x1a\x18.userstate.RequestStatus\x12>\n\x10GetAllUserStates\x12\x0f.userstate.Void\x1a\x19.userstate.UserStatesListB\x10Z\x0e./pb/userstateb\x06proto3')
28
28
 
29
29
  _globals = globals()
30
30
  _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
@@ -34,14 +34,14 @@ if not _descriptor._USE_C_DESCRIPTORS:
34
34
  _globals['DESCRIPTOR']._serialized_options = b'Z\016./pb/userstate'
35
35
  _globals['_VOID']._serialized_start=30
36
36
  _globals['_VOID']._serialized_end=36
37
- _globals['_USERSTATE']._serialized_start=38
38
- _globals['_USERSTATE']._serialized_end=144
39
- _globals['_USERSTATEID']._serialized_start=146
40
- _globals['_USERSTATEID']._serialized_end=176
41
- _globals['_REQUESTSTATUS']._serialized_start=178
42
- _globals['_REQUESTSTATUS']._serialized_end=226
43
- _globals['_USERSTATESLIST']._serialized_start=228
44
- _globals['_USERSTATESLIST']._serialized_end=287
45
- _globals['_USERSTATESERVICE']._serialized_start=290
46
- _globals['_USERSTATESERVICE']._serialized_end=640
37
+ _globals['_USERSTATE']._serialized_start=39
38
+ _globals['_USERSTATE']._serialized_end=180
39
+ _globals['_USERSTATEID']._serialized_start=182
40
+ _globals['_USERSTATEID']._serialized_end=212
41
+ _globals['_REQUESTSTATUS']._serialized_start=214
42
+ _globals['_REQUESTSTATUS']._serialized_end=262
43
+ _globals['_USERSTATESLIST']._serialized_start=264
44
+ _globals['_USERSTATESLIST']._serialized_end=323
45
+ _globals['_USERSTATESERVICE']._serialized_start=326
46
+ _globals['_USERSTATESERVICE']._serialized_end=676
47
47
  # @@protoc_insertion_point(module_scope)
@@ -2,6 +2,7 @@ from chatgraph.gRPC.gRPCCall import WhatsappServiceClient, UserStateServiceClien
2
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
+ from datetime import datetime
5
6
  import json, os
6
7
 
7
8
  @dataclass
@@ -20,9 +21,9 @@ class UserState:
20
21
  customer_id: str,
21
22
  menu: str,
22
23
  route: str,
23
- voll_id: str,
24
24
  platform: str,
25
25
  direction_in: bool,
26
+ voll_id: Optional[str]=None,
26
27
  lst_update: Optional[str]=None,
27
28
  obs: Optional[dict] = None,
28
29
  ) -> None:
@@ -73,6 +74,28 @@ class UserState:
73
74
 
74
75
  user_state_client.delete_user_state(self.customer_id)
75
76
 
77
+ @classmethod
78
+ def get_user_state(cls, customer_id: str, grpc_uri: Optional[str] = None) -> 'UserState':
79
+ if grpc_uri is None:
80
+ grpc_uri = os.getenv('GRPC_URI')
81
+ user_state_client = UserStateServiceClient(grpc_uri)
82
+
83
+ response = user_state_client.select_user_state(user_id=customer_id)
84
+
85
+ if not response:
86
+ raise ValueError("Erro ao buscar estado do usuário.")
87
+
88
+ date = datetime.strptime(response.date, "%Y-%m-%d %H:%M:%S")
89
+ return cls(
90
+ customer_id=response.user_id,
91
+ menu=response.menu_id,
92
+ route=response.route,
93
+ obs=json.loads(response.obs),
94
+ direction_in=response.direction,
95
+ voll_id=response.voll_id,
96
+ platform=response.platform,
97
+ lst_update=date,
98
+ )
76
99
  class UserCall:
77
100
  """
78
101
  Representa uma mensagem recebida ou enviada pelo chatbot.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chatgraph
3
- Version: 0.3.12
3
+ Version: 0.3.14
4
4
  Summary: A user-friendly chatbot library
5
5
  Home-page: https://github.com/irissonnlima/chatgraph
6
6
  License: MIT
@@ -8,17 +8,17 @@ chatgraph/error/route_error.py,sha256=CY8m82ap7-Sr-DXPsolltRW50TqD__5RyXBmNNJCWr
8
8
  chatgraph/gRPC/gRPCCall.py,sha256=jYZg7CvtKWhtv2sQMrSunSmvnnL83MKmNVO8GWmGZ9U,7696
9
9
  chatgraph/messages/message_consumer.py,sha256=DYPZA-TTXe4jtcdRZUSfPf-QO0B_aXUzSO3FSwfhWlo,8996
10
10
  chatgraph/pb/userstate.proto,sha256=GgjD1K2t8VxrMLkceVnY043xBdXWTPxBzaBhAbAg7yw,859
11
- chatgraph/pb/userstate_pb2.py,sha256=yk7jWGFgv2eAU5Q4juf8RApedwRRhPez9-y93MaZVlw,2772
11
+ chatgraph/pb/userstate_pb2.py,sha256=aCS_Muk_uA78buV28g7yi0O2vriTJedT4HKxgzFFUVw,2856
12
12
  chatgraph/pb/userstate_pb2_grpc.py,sha256=QJEGEmdBL6bkxrTI-gNhGbZpPUFuP5jm7eFu8y21PMI,10340
13
13
  chatgraph/pb/voll.proto,sha256=cI9YEy0RCc9FWZwAntoDQQzFBGO3zOM72hbtTkiPiZg,2031
14
14
  chatgraph/pb/voll_pb2.py,sha256=WLwE7F1pe_elcnwRnSFqVDcFihLZ3JBq4ScTHNCqWGA,5328
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=l488K4sVhTdOY5bbk47Y-qjfvfyn4h7bpmOFf2xGods,3334
18
- chatgraph/types/request_types.py,sha256=JS_I4dmrSsvrxdRmIVdXUUyKDTVDy3pISThBAoY2qCE,10728
18
+ chatgraph/types/request_types.py,sha256=LOJPZF0GtSlvTw8pDqmAzQ5zR3znADJdDkItRA5E2Wg,11641
19
19
  chatgraph/types/route.py,sha256=2fuHEPKUL_Vuv4g8pB6M7eJLouxXasqjesdju6_eumE,2757
20
- chatgraph-0.3.12.dist-info/entry_points.txt,sha256=bO9_Q-PqE5vCNNo6ke_-3j2gHfKQMDGnKDTkNuCdBuA,48
21
- chatgraph-0.3.12.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
22
- chatgraph-0.3.12.dist-info/METADATA,sha256=mJFmkStnO3EE4D3PPg4Gx8RmnmYK4YjxLTKmwGSEZOo,12782
23
- chatgraph-0.3.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
24
- chatgraph-0.3.12.dist-info/RECORD,,
20
+ chatgraph-0.3.14.dist-info/entry_points.txt,sha256=bO9_Q-PqE5vCNNo6ke_-3j2gHfKQMDGnKDTkNuCdBuA,48
21
+ chatgraph-0.3.14.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
22
+ chatgraph-0.3.14.dist-info/METADATA,sha256=COT96mOosUKy3nvw1M5KLAf7FVWmEJp5wwAt9Tlm8_I,12782
23
+ chatgraph-0.3.14.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
24
+ chatgraph-0.3.14.dist-info/RECORD,,