Spaces:
Sleeping
Sleeping
File size: 5,014 Bytes
7ed6785 39f910d 7ed6785 7982cf3 6b5c755 7ed6785 7982cf3 7ed6785 39f910d 7ed6785 6b5c755 7ed6785 6b5c755 7ed6785 6b5c755 7ed6785 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# Ticket Detail API
## Endpoint
`GET /api/v1/tickets/{ticket_id}/detail`
## Response
```json
{
"ticket": {
"id": "uuid",
"ticket_name": "Peter Otieno",
"ticket_type": "installation",
"service_type": "ftth",
"work_description": "Install Standard 20Mbps for Peter Otieno",
"status": "open",
"priority": "normal",
"scheduled_date": "2025-12-10",
"scheduled_time_slot": "10:00-14:00",
"notes": "Needs router configuration assistance",
...
},
"source_data": {
"type": "sales_order",
"id": "uuid",
"order_number": "SO-2024-001",
"customer_preferred_package": "Standard 20Mbps",
"installation_address": "123 Main St, Nairobi",
"preferred_visit_date": "2025-12-10",
"status": "pending",
"total_amount": 5000.00
},
"customer": {
"id": "uuid",
"name": "Peter Otieno",
"phone": "+254712345678",
"email": "peter@example.com",
"address": "123 Main St, Apt 4B",
"location_latitude": -1.2921,
"location_longitude": 36.8219
},
"expenses": [
{
"id": "uuid",
"expense_type": "transport",
"description": "Fuel to customer site",
"quantity": 1,
"unit_cost": 500.00,
"total_cost": 500.00,
"is_approved": false,
"approved_at": null,
"created_at": "2025-11-27T10:00:00Z"
}
],
"images": [
{
"id": "uuid",
"image_url": "https://...",
"image_type": "before",
"caption": "Site before installation",
"uploaded_by_user_id": "uuid",
"created_at": "2025-11-27T10:00:00Z"
}
],
"comments": [
{
"id": "uuid",
"comment_text": "Customer confirmed availability",
"user_id": "uuid",
"user_name": "John Doe",
"created_at": "2025-11-27T10:00:00Z"
}
],
"assignments": [
{
"id": "uuid",
"user_id": "uuid",
"user_name": "Field Agent Name",
"action": "assigned",
"status": "PENDING",
"assigned_at": "2025-11-27T08:00:00Z",
"responded_at": null,
"journey_started_at": null,
"arrived_at": null,
"ended_at": null
}
]
}
```
## Usage
```typescript
const response = await fetch(
`/api/v1/tickets/${ticketId}/detail`,
{ headers: { 'Authorization': `Bearer ${token}` } }
);
const data = await response.json();
// Display ticket info
<TicketHeader ticket={data.ticket} />
// Display customer info
{data.customer && (
<CustomerCard customer={data.customer} />
)}
// Display source data (sales order, task, incident, or subscription)
{data.source_data && (
<>
{data.source_data.type === 'sales_order' && (
<SalesOrderCard order={data.source_data} />
)}
{data.source_data.type === 'task' && (
<TaskCard task={data.source_data} />
)}
{data.source_data.type === 'incident' && (
<IncidentCard incident={data.source_data} />
)}
{data.source_data.type === 'subscription' && (
<SubscriptionCard subscription={data.source_data} />
)}
</>
)}
// Display expenses
<ExpensesList expenses={data.expenses} />
// Display images
<ImageGallery images={data.images} />
// Display comments
<CommentsList comments={data.comments} />
// Display assignments
<AssignmentTimeline assignments={data.assignments} />
```
## Source Data Types
### Sales Order (type: "sales_order")
```json
{
"type": "sales_order",
"id": "uuid",
"order_number": "SO-2024-001",
"customer_preferred_package": "Standard 20Mbps",
"package_price": 5000.00,
"installation_address": "123 Main St, Apt 4B",
"installation_latitude": -1.2921,
"installation_longitude": 36.8219,
"preferred_visit_date": "2025-12-10",
"status": "pending"
}
```
**Note:** Customer data comes from `sales_order.customer` relationship
### Task (type: "task")
```json
{
"type": "task",
"id": "uuid",
"task_title": "Install fiber backbone",
"task_description": "Install 10km fiber cable",
"task_type": "infrastructure",
"priority": "high",
"status": "in_progress",
"scheduled_date": "2025-12-10",
"due_date": "2025-12-15"
}
```
### Incident (type: "incident")
```json
{
"type": "incident",
"id": "uuid",
"incident_type": "service_outage",
"issue_description": "No internet connection",
"priority": "urgent",
"status": "open",
"reported_at": "2025-11-27T10:00:00Z",
"created_at": "2025-11-27T10:00:00Z"
}
```
### Subscription (type: "subscription")
```json
{
"type": "subscription",
"id": "uuid",
"service_type": "ftth",
"package_name": "Premium 100Mbps",
"status": "active",
"monthly_fee": 5000.00,
"start_date": "2025-01-01",
"next_billing_date": "2025-12-01",
"created_at": "2025-01-01T00:00:00Z"
}
```
## Notes
- `source_data` is null if no source linked
- `source_data.type` indicates the source type (sales_order, task, incident, subscription)
- `customer` is null if no customer linked (tasks don't have customers)
- Arrays are empty if no data exists
- All dates in ISO 8601 format
- Authorization: User must have access to ticket's project
|