chatgraph 0.3.12__tar.gz → 0.3.14__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.

Files changed (24) hide show
  1. {chatgraph-0.3.12 → chatgraph-0.3.14}/PKG-INFO +1 -1
  2. chatgraph-0.3.14/chatgraph/pb/userstate_pb2.py +47 -0
  3. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/types/request_types.py +24 -1
  4. {chatgraph-0.3.12 → chatgraph-0.3.14}/pyproject.toml +1 -1
  5. chatgraph-0.3.12/chatgraph/pb/userstate_pb2.py +0 -47
  6. {chatgraph-0.3.12 → chatgraph-0.3.14}/LICENSE +0 -0
  7. {chatgraph-0.3.12 → chatgraph-0.3.14}/README.md +0 -0
  8. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/__init__.py +0 -0
  9. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/auth/credentials.py +0 -0
  10. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/bot/chatbot_model.py +0 -0
  11. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/bot/chatbot_router.py +0 -0
  12. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/cli/__init__.py +0 -0
  13. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/error/chatbot_error.py +0 -0
  14. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/error/route_error.py +0 -0
  15. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/gRPC/gRPCCall.py +0 -0
  16. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/messages/message_consumer.py +0 -0
  17. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/pb/userstate.proto +0 -0
  18. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/pb/userstate_pb2_grpc.py +0 -0
  19. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/pb/voll.proto +0 -0
  20. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/pb/voll_pb2.py +0 -0
  21. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/pb/voll_pb2_grpc.py +0 -0
  22. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/types/end_types.py +0 -0
  23. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/types/message_types.py +0 -0
  24. {chatgraph-0.3.12 → chatgraph-0.3.14}/chatgraph/types/route.py +0 -0
@@ -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
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: userstate.proto
5
+ # Protobuf Python Version: 5.27.2
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 5,
15
+ 27,
16
+ 2,
17
+ '',
18
+ 'userstate.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+
26
+
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
+
29
+ _globals = globals()
30
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'userstate_pb2', _globals)
32
+ if not _descriptor._USE_C_DESCRIPTORS:
33
+ _globals['DESCRIPTOR']._loaded_options = None
34
+ _globals['DESCRIPTOR']._serialized_options = b'Z\016./pb/userstate'
35
+ _globals['_VOID']._serialized_start=30
36
+ _globals['_VOID']._serialized_end=36
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
+ # @@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
  [tool.poetry]
2
2
  name = "chatgraph"
3
- version = "0.3.12"
3
+ version = "0.3.14"
4
4
  description = "A user-friendly chatbot library"
5
5
  authors = ["Irisson N. Lima <irisson.lima@verdecard.com.br>"]
6
6
  readme = "README.md"
@@ -1,47 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Generated by the protocol buffer compiler. DO NOT EDIT!
3
- # NO CHECKED-IN PROTOBUF GENCODE
4
- # source: userstate.proto
5
- # Protobuf Python Version: 5.27.2
6
- """Generated protocol buffer code."""
7
- from google.protobuf import descriptor as _descriptor
8
- from google.protobuf import descriptor_pool as _descriptor_pool
9
- from google.protobuf import runtime_version as _runtime_version
10
- from google.protobuf import symbol_database as _symbol_database
11
- from google.protobuf.internal import builder as _builder
12
- _runtime_version.ValidateProtobufRuntimeVersion(
13
- _runtime_version.Domain.PUBLIC,
14
- 5,
15
- 27,
16
- 2,
17
- '',
18
- 'userstate.proto'
19
- )
20
- # @@protoc_insertion_point(imports)
21
-
22
- _sym_db = _symbol_database.Default()
23
-
24
-
25
-
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')
28
-
29
- _globals = globals()
30
- _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
- _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'userstate_pb2', _globals)
32
- if not _descriptor._USE_C_DESCRIPTORS:
33
- _globals['DESCRIPTOR']._loaded_options = None
34
- _globals['DESCRIPTOR']._serialized_options = b'Z\016./pb/userstate'
35
- _globals['_VOID']._serialized_start=30
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
47
- # @@protoc_insertion_point(module_scope)
File without changes
File without changes