SAGACE Package - Auxiliary package for developing integrations with the SAGACE system.
Project description
SAGACE Python SDK
Visão Geral
O SAGACE Python SDK é um SDK para interação com o sistema SAGACE, que fornece funcionalidades de autenticação, gerenciamento de tokens e comunicação com APIs REST.
Funcionalidades
- Autenticação Segura: Implementação de autenticação via API.
- Cliente API: Interface para envio de requisições HTTP.
- Gerenciamento de Tokens: Armazenamento em memória, arquivo ou Redis.
- Exceções Personalizadas: Tratamento de erros e falhas comuns.
- Testes Automatizados: Cobertura de testes unitários para todas as funcionalidades principais.
Requisitos
Antes de instalar o SDK, certifique-se de que possui os seguintes requisitos:
- Python 3.8+
pipatualizado- Redis (opcional, se for utilizar armazenamento de token via Redis)
Instalação
Para instalar a versão mais recente do SAGACE Python SDK, utilize:
pip install sagace-sdk
Se estiver instalando a partir do código-fonte:
git clone https://github.com/ampereconsultoria/sagace-python-sdk.git
cd sagace-python-sdk
pip install -r requirements.txt
Uso
Autenticação
Para autenticar e obter um token:
from sagace.auth.application.authentication_use_case import AuthenticationUseCase
auth_use_case = AuthenticationUseCase()
token = auth_use_case.authenticate("usuario", "senha")
print("Token obtido:", token)
Requisição para a API
Exemplo de requisição GET usando o APIClient:
from sagace.core.http_api_client import HttpApiClient
api = HttpApiClient(token)
response = api.get("/endpoint/desejado")
print(response.json())
Armazenamento de Token
O SDK permite armazenar tokens em diferentes formatos:
Memória
from sagace.core.storage.memory_storage import MemoryStorage
storage = MemoryStorage()
storage.save(token)
print("Token armazenado em memória!")
Arquivo
from sagace.core.storage.file_storage import FileStorage
storage = FileStorage("token.json")
storage.save(token)
print("Token salvo no arquivo token.json!")
Redis
from sagace.core.storage.redis_storage import RedisStorage
storage = RedisStorage()
storage.save(token)
print("Token armazenado no Redis!")
Estrutura do Projeto
sagace-sdk/
├── sagace/
│ ├── auth/
│ │ ├── application/
│ │ │ ├── authentication_use_case.py
│ │ ├── domain/
│ │ │ ├── authentication_repository.py
│ │ ├── infrastructure/
│ │ │ ├── authentication_api.py
│ │ ├── interfaces/
│ │ ├── authentication_service.py
│ ├── core/
│ │ ├── api_client.py
│ │ ├── http_api_client.py
│ │ ├── token.py
│ │ ├── token_storage.py
│ │ ├── storage/
│ │ ├── file_storage.py
│ │ ├── memory_storage.py
│ │ ├── redis_storage.py
│ ├── exceptions/
│ │ ├── application/
│ │ │ ├── application_error.py
│ │ ├── domain/
│ │ │ ├── api_request_error.py
│ │ │ ├── domain_error.py
│ │ │ ├── permission_denied_error.py
│ │ │ ├── token_expired_error.py
│ │ ├── infrastructure/
│ │ │ ├── authentication_error.py
│ │ │ ├── infrastructure_error.py
│ │ ├── interfaces/
│ │ ├── interface_error.py
│ ├── samples/
│ │ ├── basic_autentication.py
│
├── tests/ # Testes unitários
│ ├── auth/
│ │ ├── test_authentication_api.py
│ │ ├── test_authentication_use_case.py
│ ├── core/
│ │ ├── test_api_client.py
│ │ ├── test_http_api_client.py
│ │ ├── storage/
│ │ ├── test_file_storage.py
│ │ ├── test_memory_storage.py
│ │ ├── test_redis_storage.py
│ ├── exceptions/
│ │ ├── test_domain_exceptions.py
│ │ ├── test_infrastructure_exceptions.py
│
├── docs/ # Documentação Sphinx
│ ├── conf.py
├── setup.py # Script de instalação do pacote
├── requirements.txt # Dependências do projeto
├── README.md # Documentação principal
├── LICENSE # Licença do projeto
Testes
Para rodar os testes unitários:
pytest tests/
Contribuição
Se desejar contribuir para o projeto, siga os passos:
- Clone o repositório:
git clone https://github.com/ampereconsultoria/sagace-python-sdk.git
- Crie um branch para sua contribuição:
git checkout -b minha-contribuicao
- Implemente e documente suas mudanças.
- Execute os testes para garantir que tudo funciona corretamente.
- Crie um Pull Request para revisão.
Licença
Este projeto está licenciado sob a MIT License. Consulte o arquivo LICENSE para mais detalhes.
Contato
Para suporte e dúvidas:
- Email: desenvolvimento@ampereconsultoria.com.br
- GitHub Issues: Reportar Problema
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sagace-0.1.3.tar.gz.
File metadata
- Download URL: sagace-0.1.3.tar.gz
- Upload date:
- Size: 183.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9ba5bec98a235a71fdb9dae1364e7dbec4a9d3acaad68e32e7f6e1459351e7f
|
|
| MD5 |
f6f5eda32ec616b86bcebc63f4830267
|
|
| BLAKE2b-256 |
a21583a9137395f293ddf482e5a49fc1ebd09391bbc89705eb83039f7f37736e
|
File details
Details for the file sagace-0.1.3-py2.py3-none-any.whl.
File metadata
- Download URL: sagace-0.1.3-py2.py3-none-any.whl
- Upload date:
- Size: 36.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cdd4eada18021e6383a31ece07613cb0b050b9d185431d779180b8b06c44b9f
|
|
| MD5 |
64cbe10025c0c37a7b2f112f8408dc0b
|
|
| BLAKE2b-256 |
210b77c4f1cd90ec2d0b80d2fc838b9fd4339932d4473cc1c4490e3536f64e90
|