Skip to main content

Multiburo Pipedrive integration for Django applications

Project description

Multiburo Pipedrive Integration

A Django-compatible Python package for seamless Pipedrive CRM integration.

Features

  • 🏷️ Flexible tagging system for person classification
  • 🛡️ Robust error handling with custom exceptions
  • 📊 Comprehensive logging for debugging and monitoring
  • 🧪 Thoroughly tested with 95%+ test coverage

Installation

For Production

pip install mb-pipedrive-integration

Local Development

git clone <repository-url>
cd mb-pipedrive-integration
uv sync --extra dev
uv run pre-commit install

Quick Start

1. Configure Settings

Django Settings

# settings.py
PIPEDRIVE_COMPANY_DOMAIN = "your-company"
PIPEDRIVE_API_TOKEN = "your-api-token"
PIPEDRIVE_DEFAULT_PIPELINE_ID = "1"
PIPEDRIVE_DEFAULT_STAGE_ID = "1"
PIPEDRIVE_CUSTOM_FIELDS = {
    "folder_number": "custom_field_hash_1",
    "folder_id": "custom_field_hash_2",
}

Environment Variables

export PIPEDRIVE_COMPANY_DOMAIN="your-company"
export PIPEDRIVE_API_TOKEN="your-api-token"

2. Basic Usage

from mb_pipedrive_integration import PipedriveService, DealData, PersonData

# Initialize service
service = PipedriveService()

# Create a person
person = service.create_person(
    name="John Doe",
    email="john@example.com",
    tags=["Multiexpediente"]
)

# Create a deal
deal_data = DealData(
    title="Apartment Rental",
    folder_number=12345,
    folder_id="abc-123",
    tenant=PersonData(name="John Doe", email="john@example.com", tags=["INQUILINO"])
)

deal = service.create_deal(deal_data)

3. Django Integration with Celery

# tasks.py
from celery import shared_task
from mb_pipedrive_integration import PipedriveService, DealData
from .adapters import FolderToPipedriveAdapter

@shared_task
def sync_folder_with_pipedrive(folder_id: str):
    folder = Folder.objects.get(id=folder_id)
    deal_data = FolderToPipedriveAdapter.to_deal_data(folder)
    
    service = PipedriveService()
    result = service.create_deal(deal_data)
    
    if result:
        folder.metadata['pipedrive_deal_id'] = result['id']
        folder.save()

Role Mapping

The package automatically maps roles to Pipedrive tags:

Role Pipedrive Tag
tenant INQUILINO
advisor ASESOR INMOBILIARIO
landlord PROPIETARIO

Error Handling

from mb_pipedrive_integration.exceptions import (
    PipedriveAPIError,
    PipedriveNetworkError,
    PipedriveConfigError
)

try:
    person = service.create_person("John Doe")
except PipedriveAPIError as e:
    print(f"API Error: {e.status_code} - {e}")
except PipedriveNetworkError as e:
    print(f"Network Error: {e} (retried {e.retry_count} times)")
except PipedriveConfigError as e:
    print(f"Configuration Error: {e}")

Development

Running Tests

# All tests
uv run pytest

# With coverage
uv run pytest --cov=mb_pipedrive_integration --cov-report=term-missing

# Integration tests (requires real API credentials)
uv run pytest tests/test_integration.py --integration

Code Quality

# Run all pre-commit hooks
uv run pre-commit run --all-files

# Individual tools
uv run black .
uv run flake8
uv run mypy mb_pipedrive_integration/

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Run pre-commit hooks
  7. Submit a pull request

License

MIT License

Copyright © 2025 Multiburó

See the LICENSE file for details.

Support

For questions or issues, please open an issue on GitHub.

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

mb_pipedrive_integration-1.0.4.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

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

mb_pipedrive_integration-1.0.4-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file mb_pipedrive_integration-1.0.4.tar.gz.

File metadata

File hashes

Hashes for mb_pipedrive_integration-1.0.4.tar.gz
Algorithm Hash digest
SHA256 f5ee0a4934d26ca387d358b753ad274e95cf859540750f26aaf8abc6b9c2a0d4
MD5 f610a54d4ce7d1db452c09bc508bb07d
BLAKE2b-256 c7f9d4b975b9d95ef7e4602ffad3b519b0ddc4f9c264756538e08325935623d7

See more details on using hashes here.

File details

Details for the file mb_pipedrive_integration-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for mb_pipedrive_integration-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3fcbf1c2ea3ac2dcd9422a46031e6762f2c23bee9a400364435777fb7f08dd81
MD5 fc5cb0a4fa5c7d7e9b0e6e9b27b4a81c
BLAKE2b-256 324b9a7e71a372a01a54331a9727a014ebb76c30bf33e00e86e6e516041c051a

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