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.3.tar.gz (18.3 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.3-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whom_integration-1.0.3.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for whom_integration-1.0.3.tar.gz
Algorithm Hash digest
SHA256 844449c4fdcb4c9f4554afb91b50f46d0ec914f53c409a2ad4058a1009a3aeb3
MD5 857c45850ae54fa6d87064f82f56fde9
BLAKE2b-256 a7dccd4484b468cb28ca94c13a847a57fa9d800c2b73fcf13929593f54514bdf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for whom_integration-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ad390e957bb55f5e5efdb244bf5f4f6709fa2f833bbd0c4c7f7c26065a75cbc1
MD5 ca894d54bd109bbb9069ad7ea8db00dd
BLAKE2b-256 f2d43824432ebdf276cf7320317a85774a613838a1ded4041a514a2f835ced0a

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