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 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.2.tar.gz (18.0 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.2-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whom_integration-1.0.2.tar.gz
  • Upload date:
  • Size: 18.0 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.2.tar.gz
Algorithm Hash digest
SHA256 deadc55644afcf1f9419a364790642ea8c5e41dba91b8f70f9e894bfd0a75bdd
MD5 fc2217f11d499d0ddb2c5ca52a4149aa
BLAKE2b-256 dffa6685383df941d10e1e302b521e02240f41141b802c36399ef775c9230869

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for whom_integration-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b52632418245a8d633c82a674a1426c3badfa92c09d1be903718276d76c0806e
MD5 cd69414a7aa12494ecd52f12ceac0cd1
BLAKE2b-256 03fff0d251bfffa744930c0bbef47c5fcc6cbfddbc24320283174d23bd776cb0

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