# Endpoint Test Guide

## Authentication Token

From login response:
```
auth_token: "2001d73f696e4136212bbad7050d64301c3dae6655ced2ad568e29b8730382c8"
```

## Endpoints

### 1. Collection Details
Returns collection details for the authenticated agent including loans, receipts, and summary statistics.

**Endpoint:** `GET /collection_details`

**cURL:**
```bash
curl -X GET "http://192.168.1.3:3000/collection_details" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer 2001d73f696e4136212bbad7050d64301c3dae6655ced2ad568e29b8730382c8" \
  -H "Content-Type: application/json"
```

**PowerShell:**
```powershell
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$session.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1"

Invoke-WebRequest -UseBasicParsing -Uri "http://192.168.1.3:3000/collection_details" `
  -WebSession $session `
  -Headers @{
    "Accept" = "application/json"
    "Accept-Encoding" = "gzip, deflate"
    "Accept-Language" = "en-GB,en-US;q=0.9,en;q=0.8"
    "Authorization" = "Bearer 2001d73f696e4136212bbad7050d64301c3dae6655ced2ad568e29b8730382c8"
    "Origin" = "http://localhost:54908"
    "Referer" = "http://localhost:54908/"
  } `
  -ContentType "application/json"
```

### 2. Collection Agent
Returns the authenticated agent's profile data.

**Endpoint:** `GET /collection_agent`

**cURL:**
```bash
curl -X GET "http://192.168.1.3:3000/collection_agent" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer 2001d73f696e4136212bbad7050d64301c3dae6655ced2ad568e29b8730382c8" \
  -H "Content-Type: application/json"
```

**PowerShell:**
```powershell
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$session.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1"

Invoke-WebRequest -UseBasicParsing -Uri "http://192.168.1.3:3000/collection_agent" `
  -WebSession $session `
  -Headers @{
    "Accept" = "application/json"
    "Accept-Encoding" = "gzip, deflate"
    "Accept-Language" = "en-GB,en-US;q=0.9,en;q=0.8"
    "Authorization" = "Bearer 2001d73f696e4136212bbad7050d64301c3dae6655ced2ad568e29b8730382c8"
    "Origin" = "http://localhost:54908"
    "Referer" = "http://localhost:54908/"
  } `
  -ContentType "application/json"
```

## Quick Test Scripts

### Bash Script
Run: `./test_endpoints.sh`

### PowerShell Script
Run: `.\test_endpoints.ps1`

## Response Format

### Collection Details Response
```json
{
  "status": "success",
  "message": "Collection details retrieved successfully",
  "data": {
    "agent_info": {
      "agent_id": 5,
      "agent_name": "Raja",
      "agent_mobile": "8825948300",
      "company_id": 15
    },
    "customers": [...],
    "summary": {
      "total_customers": 1,
      "total_collection_amount": 0,
      "total_amount_till_today": 2392,
      "total_needed_calculated_today": 2392,
      "total_collected_amount": 200,
      "collected_today_amount": 0,
      ...
    }
  }
}
```

### Collection Agent Response
```json
{
  "status": "success",
  "message": "Collection agent data retrieved successfully",
  "data": {
    "id": 5,
    "name": "Raja",
    "mobile_no": "8825948300",
    "line": "Line 2",
    "com_id": 15,
    ...
  }
}
```

## Notes

- Replace `192.168.1.3:3000` with your actual server URL if different
- The auth token expires at `2025-12-07T06:30:00.738Z` - you'll need to login again after expiration
- Both endpoints require authentication via Bearer token

