Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luiscib3r/odoochat_flutter
Flutter package to comunicate with Odoo Conversation module
https://github.com/luiscib3r/odoochat_flutter
chat dart flutter odoo
Last synced: 1 day ago
JSON representation
Flutter package to comunicate with Odoo Conversation module
- Host: GitHub
- URL: https://github.com/luiscib3r/odoochat_flutter
- Owner: luiscib3r
- License: mit
- Created: 2021-04-02T05:57:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-16T03:17:27.000Z (10 months ago)
- Last Synced: 2024-01-17T02:49:44.437Z (10 months ago)
- Topics: chat, dart, flutter, odoo
- Language: JavaScript
- Homepage:
- Size: 414 KB
- Stars: 4
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## OdooChat.
### Example
```dart
// ignore_for_file: avoid_printimport 'package:odoochat/odoochat.dart';
Future main(List args) async {
// Init
final odooChat = OdooChat(
serverUrl: 'http://localhost:8069',
databaseName: 'luisciber',
debug: true,
);// Login
final loginResult = await odooChat.login(
username: '[email protected]',
password: '12345678',
);print(loginResult);
// Init messaging
final messagingResult = await odooChat.initMessaging();print('Current Partner: ');
print(messagingResult.currentPartner);print('Channels, Private Messages, Groups: ');
print(messagingResult.channels);if (messagingResult.channels.isEmpty) {
print('No channels found');
return;
}// Fetch messages
final messages = await odooChat.fetchMessages(
messagingResult.channels.first.id,
);print('Messages: ');
for (final message in messages.reversed) {
print(message.emailFrom);
print(message.author);
print(message.body);
print(message.date);
print('\n');
}// Send message
final newMessageId = await odooChat.sendMessage(
channelId: messagingResult.channels.first.id,
message: 'Test message from OdooChat Flutter',
);print('New message id: $newMessageId');
// Poll
while (await Future.delayed(const Duration(seconds: 3), () => true)) {
final results = await odooChat.poll();for (final result in results) {
print('\n');
switch (result.message) {
case PollMessageMessage(data: final Message data):
print('Is a message');
print(data);
case PollMessageChannel(data: final Channel data):
print('Is a new channel notification');
print(data);
case PollMessageInfo(data: final MessageInfo data):
print('Is an info message'); // ex: typing, or bot messages
switch (data) {
case MessageInfoTyping(
isTyping: final bool isTyping,
partnerId: final int partnerId,
partnerName: final String partnerName,
):
print('Partner id: $partnerId');
print('Partner name: $partnerName');
print('Is typing: $isTyping');case MessageInfoTransient(
body: final String body,
):
print('Transient message: $body');
}
case null:
print('Empty poll result');
}
}
}
}
```
### Download attachments```dart
// Get attachment in bytes
final bytes = odooChat.getAttachment(attachmentId)
```### Note
It is recommended to use isolates to run the chat poll.
Review an [application example](https://github.com/luiscib3r/odoochat_flutter/tree/main/example/odoochat_example).
### Flutter Web
Please note that currently, this package does not support Flutter Web. However, work is in progress to make it compatible with web as well.