Skip to main content

Python library for Whom API integration, supporting multiple systems and web automation drivers

Project description

Whom Integration Library

Versatile Python library for Whom API integration, supporting multiple systems and web automation drivers.

๐Ÿš€ Features

  • ๐Ÿ”Œ Multiple Drivers: Support for Selenium and Playwright
  • ๐ŸŽฏ Extensible Systems: Modular architecture for different systems
  • โšก Easy to Use: Simple and intuitive API
  • ๐Ÿ›ก๏ธ Error Handling: Custom and robust exceptions
  • ๐Ÿ“š Well Documented: Complete examples and documentation

๐Ÿ“ฆ Installation

Basic Installation

pip install whom-integration

Installation with Specific Drivers

# Install with Selenium support
pip install "whom-integration[selenium]"

# Install with Playwright support
pip install "whom-integration[playwright]"

# Install with all drivers
pip install "whom-integration[all]"

Development Installation

# Install with development tools
pip install "whom-integration[dev]"

# Manual installation from source
git clone https://github.com/doc9/whom-integration.git
cd whom-integration
pip install -e .

Driver Setup

After installation, you may need to set up the drivers:

# For Playwright
playwright install chromium

# For Selenium
# ChromeDriver is usually auto-installed via webdriver-manager

๐ŸŽฏ Quick Start

Command Line Interface

The library includes a CLI for quick testing:

# Test ECAC with Playwright
whom-integration --system ecac --driver playwright --token YOUR_TOKEN --extension YOUR_EXTENSION

# Test PJE with Selenium
whom-integration --system pje --driver selenium --token YOUR_TOKEN --extension YOUR_EXTENSION

# Show help
whom-integration --help

Example with Selenium

from whom_integration import WhomClient, ECACSystem, SeleniumDriver

# Configure client
client = WhomClient(token="your_token", extension_id="your_extension_id")

# Create session
with client.create_session(ECACSystem, SeleniumDriver) as session:
    # Authenticate and connect
    session.authenticate_and_connect()
    
    # Execute workflow
    result = session.execute_workflow("default")
    
    print(f"Success: {result['success']}")

Example with Playwright

from whom_integration import WhomClient, ECACSystem, PlaywrightDriver


client = WhomClient(token="your_token", extension_id="your_extension_id")

with client.create_session(ECACSystem, PlaywrightDriver) as session:
    session.authenticate_and_connect()
    result = session.execute_workflow("default")
    print(f"Success: {result['success']}")

๐Ÿ—๏ธ Architecture

Main Components

whom_integration/
โ”œโ”€โ”€ __init__.py          # Main interface
โ”œโ”€โ”€ core.py              # Client and session
โ”œโ”€โ”€ drivers/             # Automation drivers
โ”‚   โ”œโ”€โ”€ base.py         # Abstract base class
โ”‚   โ”œโ”€โ”€ selenium_driver.py
โ”‚   โ””โ”€โ”€ playwright_driver.py
โ”œโ”€โ”€ systems/             # Supported systems
โ”‚   โ”œโ”€โ”€ base.py         # Abstract base class
โ”‚   โ””โ”€โ”€ ecac_system.py  # ECAC system
โ”‚   โ””โ”€โ”€ pje_system.py  # PJE system
โ””โ”€โ”€ exceptions.py        # Custom exceptions

Workflow

  1. Whom Client: Manages API authentication
  2. Driver: Controls the browser (Selenium/Playwright)
  3. System: Implements target system specific logic
  4. Session: Orchestrates the entire process

๐Ÿ”ง Configuration

Basic Configuration

from whom_integration import WhomClient

client = WhomClient(
    token="your_token_here",
    extension_id="your_extension_id_here",
    base_url="https://cloud.doc9.com.br"  # Optional
)

Driver Configuration

# Selenium
session = client.create_session(
    ECACSystem,
    SeleniumDriver,
    headless=False,
    window_size=(1920, 1080)
)

# Playwright
session = client.create_session(
    ECACSystem,
    PlaywrightDriver,
    headless=False,
    viewport={'width': 1920, 'height': 1080}
)

๐ŸŽฏ Direct Access to Session Objects

When you create a session, you have direct access to all available objects and methods:

๐Ÿ“ฑ Driver (Browser)

# Direct access to configured driver
session.driver.navigate("https://example.com")
session.driver.execute_script("alert('Hello!')")
session.driver.click_element("#button")
session.driver.wait_for_element(".class", timeout=10)
session.driver.get_page_title()
session.driver.get_current_url()

# For Playwright - direct access to page object
if hasattr(session.driver, 'page'):
    session.driver.page.fill("#input", "text")
    session.driver.page.screenshot(path="screenshot.png")
    session.driver.page.pdf(path="page.pdf")

# For Selenium - direct access to driver object
if hasattr(session.driver, 'driver'):
    session.driver.driver.find_element(By.ID, "element")
    session.driver.driver.execute_script("return document.title")

๐Ÿ–ฅ๏ธ System Data

# System specific methods
redirect_url = session.system.get_redirect_url()
target_url = session.system.get_target_url()
js_commands = session.system.get_js_commands()
cookies = session.system.get_cookies()

# Execute custom workflows
result = session.system.execute_workflow("custom_workflow", param1="value")

๐Ÿ“Š Session Data

# Direct access to data returned by API
session_data = session.session_data

# Session cookies
cookies = session_data.get('cookies', [])

# Important URLs
entry_point = session_data.get('entry_point')
redirect_url = session_data.get('redirect')
target_url = session_data.get('url')

# JavaScript commands for execution
js_commands = session_data.get('js', [])

# Allowed domains
allowed_domains = session_data.get('domains', [])

# Elements to hide
hidden_elements = session_data.get('elements_to_hidden', {})

# Extra data
extra_data = session_data.get('extra', {})

๐ŸŽฏ Supported Systems

๐Ÿ“Š Driver Compatibility Table

System Selenium Playwright Notes
ECAC โŒ โœ… Federal Revenue System - only works with Playwright
PJE โœ… โŒ Judiciary System - only works with Selenium

๐Ÿ”„ Changelog

v1.0.0

  • โœ… Initial support for ECAC
  • โœ… Initial support for PJE
  • โœ… Selenium and Playwright drivers
  • โœ… Intelligent proxy system
  • โœ… Modular and extensible architecture
  • โœ… Complete documentation

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

whom_integration-1.0.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whom_integration-1.0.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file whom_integration-1.0.0.tar.gz.

File metadata

  • Download URL: whom_integration-1.0.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for whom_integration-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2a5643cea2e5481d7d9d033378edffd413a56f82011de028208f46a69026e733
MD5 e6d216a6a498a7d219d32ca08c5ee399
BLAKE2b-256 060a667152c7038618ff8806124327df3a84c17ce6bf0b0cf2a092822afa2390

See more details on using hashes here.

File details

Details for the file whom_integration-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for whom_integration-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db0dffe9a084cdc0b6532faafcb3dbd902dd3910a0b64ae42eb3c37e3f68cb01
MD5 c3f4fa35382797f6c078bc33742705c4
BLAKE2b-256 ff0cd371f1c990ae635f290058f5d43a239dd6ae83e45bfbb33b3b9463be93c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page