Metadata-Version: 2.4
Name: fmconsult-chat-api-python-sdk
Version: 1.0.0
Summary: Client de comunicação c/ FMConsult Chat API
Author-email: Filipe Coelho <filipe@fmconsult.com.br>
License: MIT License
        
        Copyright (c) 2025 FMConsult
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/FMConsult/fmconsult-chat-api-python-sdk
Project-URL: Bug Tracker, https://github.com/FMConsult/fmconsult-chat-api-python-sdk/issues
Keywords: sdk,api,fmconsult,chat
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# fmconsult-chat-api-python-sdk

Client Python para a [FMConsult Chat API](https://github.com/FMConsult/fmconsult-chat-api).

## Instalação

```bash
pip install fmconsult-chat-api-python-sdk fmconsult-utils-python-sdk
```

## Variáveis de ambiente

| Variável | Obrigatório | Descrição |
|----------|-------------|-----------|
| `fmconsult.chat.api.token` | sim | Token `X-Api-Token` (gerado via fmconsult-apis-manager) |
| `fmconsult.chat.api.client_id` | sim | Tenant enviado em `X-Client-Id` |
| `fmconsult.chat.api.base_url` | não | Padrão: `https://api-chat.fmconsult.com.br` |

## Uso na core-api

```python
import os
from fmconsult.utils.configs import ConfigPropertiesHelper
from fmconsult.chatapi.apis.rooms import Rooms
from fmconsult.chatapi.apis.messages import Messages
from fmconsult.chatapi.dtos.room import CreateRoom, JoinRoom
from fmconsult.chatapi.dtos.message import SendMessage, MessageVisibility

def init_chat_environments():
  cph = ConfigPropertiesHelper()
  os.environ['fmconsult.chat.api.token'] = cph.get_property_value('FMCONSULT-CHAT', 'fmconsult.chat.api.token')
  os.environ['fmconsult.chat.api.client_id'] = cph.get_property_value('FMCONSULT-CHAT', 'fmconsult.chat.api.client_id')

# Criar sala
init_chat_environments()
rooms = Rooms()
room = rooms.create(CreateRoom(
  name='Sala Pedido',
  reference_id='64ad60d266a2f523e0ee30e7',
  color='#000000',
))

# Entrar na sala
rooms.join(room['data']['id'], JoinRoom(
  user_id='64b82ab5cc7e070e429aef43',
  name='John Doe',
  profile='passenger',
  phone_number='11 999999999',
  departments=['operacao'],
  roles=['user'],
))

# Enviar mensagem
messages = Messages()
messages.send(room['data']['id'], SendMessage(
  user_id='64b82ab5cc7e070e429aef43',
  content='Olá!',
))

# Mensagem direta
messages.send(room['data']['id'], SendMessage(
  user_id='64b82ab5cc7e070e429aef43',
  content='Privado',
  visibility=MessageVisibility(
    type='direct',
    users=['64dbb6ded80a591d2df65621'],
  ),
))

# Listar mensagens
messages.list_by_room(room['data']['id'], user_id='64b82ab5cc7e070e429aef43')

# Última mensagem visível
messages.get_latest(room['data']['id'], user_id='64b82ab5cc7e070e429aef43')
```

## Config na core-api (`configs.ini`)

```ini
[FMCONSULT-CHAT]
fmconsult.chat.api.token=seu-token
fmconsult.chat.api.client_id=77seg
fmconsult.chat.api.base_url=https://api-chat.fmconsult.com.br
```

## Publicação

Push de tag `v*` dispara o workflow de publicação no PyPI.

```bash
git tag v1.0.0
git push origin v1.0.0
```

## Dependências

Este pacote depende de `fmconsult-utils-python-sdk` em runtime (instalado separadamente pelo consumidor, como nos demais SDKs internos).
