Metadata-Version: 2.1
Name: crm-connectors
Version: 0.0.1
Summary: Utility classes to interact with CRMs like HubSpot, Salesforce, and Zoho using OAuth 2.0.
Author: Mukhtar
Author-email: mrather552@gmail.com
Description-Content-Type: text/markdown
Requires-Dist: requests

# 🧩 CRM Connector Suite
Unified Python Clients for Zoho, HubSpot, and Salesforce CRM APIs
This repository provides independent Python connectors to interact with popular CRM systems — Zoho, HubSpot, and Salesforce — through a unified, modular interface.
Each connector supports OAuth 2.0 authentication, and includes features such as creating, updating, fetching, and exporting leads.

---

### Prerequisites

*   Python 3.11+
*   `pip` (Python package installer)

---
### 2. Create a Virtual Environment (Recommended)

```bash
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
```

### 3. Install Dependencies

```bash
pip install -r requirements.txt
```

## 🔧 Installation
🧩 Installation Guide
This package contains three individual CRM connector modules:
<details>
<summary>📘 Table of Contents</summary>

- [Zoho CRM Connector](#-zoho-crm-connector)
- [HubSpot CRM Connector](#-hubspot-crm-connector)
- [Salesforce CRM Connector](#-salesforce-crm-connector)

</details>

Each connector is built as a subpackage under the main package connector/.
Once installed, you can import and use them independently.

---

## 🚀 Features
- Create new leads  
- Update lead   
- Export all leads to **CSV**  

---

## 📂 Project Structure

```
connector/
├── __init__.py
├── zoho/
│   ├── __init__.py
│   └── client.py                # Zoho CRM connector
├── hubspot/
│   ├── __init__.py
│   └── client.py                # HubSpot CRM connector
├── salesforce/
│   ├── __init__.py
│   └── client.py                # Salesforce CRM connector
├── requirements.txt
├── setup.py                     # Build & packaging configuration
├── script.sh                    # Wheel build and upload automation
├── README.md                    # Combined documentation
```
---

## ⚙️ How to Use / Test Each Connector with `.env`

You can securely manage your CRM credentials using a `.env` file in your project root.  
This avoids hardcoding sensitive information in your scripts.


---
### 🧩 Common Environment Variables

All connectors require these basic credentials:

```env
CLIENT_ID=YOUR_CLIENT_ID
CLIENT_SECRET=YOUR_CLIENT_SECRET
ACCESS_TOKEN=YOUR_ACCESS_TOKEN
REFRESH_TOKEN=YOUR_REFRESH_TOKEN
```
---

### Additional for Zoho
```env
TOKEN_URL=https://accounts.zoho.in/oauth/v2/token
CRM_API_URL=https://www.zohoapis.in
DOMAIN=zoho.in
```
---
### Additional for Salesforce
```env
INSTANCE_URL=https://your-instance.salesforce.com
```
---

## 🧩 Usage Examples

---

### Salesforce CRM Connector

---

***Create a New Lead***
```lead_data = {
    "FirstName": "Example",
    "LastName": "Exam",
    "Company": "X-labs Plt",
    "Email": "exam@example.com"}
created_lead = salesforce.create_lead(lead_data)
print(created_lead)
```
---

***Export All Leads to CSV***
```salesforce.get_all_leads_and_save_csv("all_leads.csv")```

---

### HubSpot CRM Connector
---
***Fetch All Leads***
```hubspot.get_all_leads()```

***Create a New Lead***
```hubspot.create_lead(firstname, lastname, email)```

***Update an Existing Lead***
```hubspot.update_lead(email, updated_fields={})```

***Get Lead by Email***
```hubspot.get_lead_by_email(email)```

***Export Leads to CSV***
```hubspot.export_leads_to_csv(file_name, path)```

---

### Zoho CRM Connector

---

**refresh_access_token()**

Refreshes the access token using the refresh token.

**get_all_leads(per_page=200)**

Retrieves all leads from Zoho CRM.

-   `per_page` (int, optional): The number of leads to retrieve per page. Defaults to 200.

**_search_lead(email=None, phone=None)**

Searches for a lead by email or phone.

-   `email` (str, optional): The email of the lead to search for.
-   `phone` (str, optional): The phone number of the lead to search for.

**create_lead(lead_data)**

Creates a new lead in Zoho CRM.

-   `lead_data` (dict): The data for the new lead.

**add_note_to_lead(lead_id, note_title, note_content)**

Adds a note to an existing lead.

-   `lead_id` (str): The ID of the lead to add the note to.
-   `note_title` (str): The title of the note.
-   `note_content` (str): The content of the note.

**add_lead(zoho_data)**

Adds a lead to Zoho CRM. If the lead already exists, it adds a note to the existing lead.

-   `zoho_data` (dict): The data for the lead.

**write_leads_to_file(filename="leads.csv")**

Writes all leads to a CSV file.

-   `filename` (str, optional): The name of the file to write the leads to. Defaults to "leads.csv".

**generate_leads_csv(leads_data)**

Generates CSV data from a list of leads.

-   `leads_data` (list): A list of lead data dictionaries.
