Line data Source code
1 : import 'package:chatwoot_client_sdk/data/chatwoot_repository.dart'; 2 : import 'package:chatwoot_client_sdk/data/local/entity/chatwoot_message.dart'; 3 : import 'package:chatwoot_client_sdk/data/remote/chatwoot_client_exception.dart'; 4 : import 'package:chatwoot_client_sdk/data/remote/responses/chatwoot_event.dart'; 5 : 6 : ///Chatwoot callback are specified for each created client instance. Methods are triggered 7 : ///when a method satisfying their respective conditions occur. 8 : /// 9 : /// 10 : /// {@category FlutterClientSdk} 11 : class ChatwootCallbacks { 12 : ///Triggered when a welcome event/message is received after connecting to 13 : ///the chatwoot websocket. See [ChatwootRepository.listenForEvents] 14 : void Function()? onWelcome; 15 : 16 : ///Triggered when a ping event/message is received after connecting to 17 : ///the chatwoot websocket. See [ChatwootRepository.listenForEvents] 18 : void Function()? onPing; 19 : 20 : ///Triggered when a subscription confirmation event/message is received after connecting to 21 : ///the chatwoot websocket. See [ChatwootRepository.listenForEvents] 22 : void Function()? onConfirmedSubscription; 23 : 24 : ///Triggered when a conversation typing on event/message [ChatwootEventMessageType.conversation_typing_on] 25 : ///is received after connecting to the chatwoot websocket. See [ChatwootRepository.listenForEvents] 26 : void Function()? onConversationStartedTyping; 27 : 28 : ///Triggered when a presence update event/message [ChatwootEventMessageType.presence_update] 29 : ///is received after connecting to the chatwoot websocket and conversation is online. See [ChatwootRepository.listenForEvents] 30 : void Function()? onConversationIsOnline; 31 : 32 : ///Triggered when a presence update event/message [ChatwootEventMessageType.presence_update] 33 : ///is received after connecting to the chatwoot websocket and conversation is offline. 34 : ///See [ChatwootRepository.listenForEvents] 35 : void Function()? onConversationIsOffline; 36 : 37 : ///Triggered when a conversation typing off event/message [ChatwootEventMessageType.conversation_typing_off] 38 : ///is received after connecting to the chatwoot websocket. See [ChatwootRepository.listenForEvents] 39 : void Function()? onConversationStoppedTyping; 40 : 41 : ///Triggered when a message created event/message [ChatwootEventMessageType.message_created] 42 : ///is received and message doesn't belong to current user after connecting to the chatwoot websocket. 43 : ///See [ChatwootRepository.listenForEvents] 44 : void Function(ChatwootMessage)? onMessageReceived; 45 : 46 : void Function(ChatwootMessage, String)? onMessageSent; 47 : 48 : ///Triggered when a message created event/message [ChatwootEventMessageType.message_created] 49 : ///is received and message belongs to current user after connecting to the chatwoot websocket. 50 : ///See [ChatwootRepository.listenForEvents] 51 : void Function(ChatwootMessage, String)? onMessageDelivered; 52 : 53 : ///Triggered when a conversation's messages persisted on device are successfully retrieved 54 : void Function(List<ChatwootMessage>)? onPersistedMessagesRetrieved; 55 : 56 : ///Triggered a conversation's messages is successfully retrieved from remote server 57 : void Function(List<ChatwootMessage>)? onMessagesRetrieved; 58 : 59 : /// Triggered when any error occurs in chatwoot client's operations with the error 60 : /// 61 : /// See [ChatwootClientExceptionType] for the various types of exceptions that can be triggered 62 : void Function(ChatwootClientException)? onError; 63 : 64 2 : ChatwootCallbacks({ 65 : this.onWelcome, 66 : this.onPing, 67 : this.onConfirmedSubscription, 68 : this.onMessageReceived, 69 : this.onMessageSent, 70 : this.onMessageDelivered, 71 : this.onPersistedMessagesRetrieved, 72 : this.onMessagesRetrieved, 73 : this.onConversationStartedTyping, 74 : this.onConversationStoppedTyping, 75 : this.onConversationIsOnline, 76 : this.onConversationIsOffline, 77 : this.onError, 78 : }); 79 : }