{
	"info": {
		"_postman_id": "8a41dfc8-fcbd-461b-a197-75a7d3dcc211",
		"name": "Maintenance Emergency Lifecycle",
		"description": "Collection for the Emergency Maintenance Lifecycle, Technician Dispatch, and Visit execution features.",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "Emergency Dashboard",
			"item": [
				{
					"name": "Technicians Map",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{base_url}}/maintenance/emergency/technicians-map",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"maintenance",
								"emergency",
								"technicians-map"
							]
						},
						"description": "Returns all technicians with an active or recently completed visit in the last 8 hours, including their last known GPS coordinates."
					},
					"response": []
				},
				{
					"name": "Request SLA Status",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{base_url}}/maintenance/requests/:id/sla-status",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"maintenance",
								"requests",
								":id",
								"sla-status"
							],
							"variable": [
								{
									"key": "id",
									"value": "1",
									"description": "Maintenance Request ID"
								}
							]
						},
						"description": "Retrieves the SLA tracking details, including response and arrival deadlines and breach status."
					},
					"response": []
				}
			]
		},
		{
			"name": "Visit Execution",
			"item": [
				{
					"name": "Pause Visit",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{base_url}}/maintenance/visits/:id/pause",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"maintenance",
								"visits",
								":id",
								"pause"
							],
							"variable": [
								{
									"key": "id",
									"value": "1",
									"description": "Maintenance Visit ID"
								}
							]
						},
						"description": "Pauses an in-progress maintenance visit."
					},
					"response": []
				},
				{
					"name": "Resume Visit",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{base_url}}/maintenance/visits/:id/resume",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"maintenance",
								"visits",
								":id",
								"resume"
							],
							"variable": [
								{
									"key": "id",
									"value": "1",
									"description": "Maintenance Visit ID"
								}
							]
						},
						"description": "Resumes a paused maintenance visit."
					},
					"response": []
				},
				{
					"name": "Get Contract Units",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{base_url}}/maintenance/visits/:id/contract-units",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"maintenance",
								"visits",
								":id",
								"contract-units"
							],
							"variable": [
								{
									"key": "id",
									"value": "1"
								}
							]
						},
						"description": "Lists all asset units associated with the visit's contract/site."
					},
					"response": []
				},
				{
					"name": "Store Faulted Units",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"faulted_units\": [\n        {\n            \"contract_unit_id\": 101,\n            \"is_faulted\": true,\n            \"fault_description\": \"Compressor failure due to refrigerant leak.\",\n            \"checklist_responses\": {\n                \"power_on\": true,\n                \"noise_level\": \"high\"\n            }\n        }\n    ]\n}"
						},
						"url": {
							"raw": "{{base_url}}/maintenance/visits/:id/faulted-units",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"maintenance",
								"visits",
								":id",
								"faulted-units"
							],
							"variable": [
								{
									"key": "id",
									"value": "1"
								}
							]
						},
						"description": "Records details of faulted units identified during the visit."
					},
					"response": []
				}
			]
		},
		{
			"name": "Requests & Clients",
			"item": [
				{
					"name": "Client Search (Contracted)",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{base_url}}/maintenance/projects/clients/search?q=Al Rajhi",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"maintenance",
								"projects",
								"clients",
								"search"
							],
							"query": [
								{
									"key": "q",
									"value": "Al Rajhi",
									"description": "Search term (min 2 chars)"
								}
							]
						},
						"description": "Searches for clients with active maintenance contracts."
					},
					"response": []
				},
				{
					"name": "Store Emergency Request",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"customer_id\": 1,\n    \"location_id\": 5,\n    \"incident_type\": \"full_cooling_failure\",\n    \"priority\": \"critical\",\n    \"site_contact_name\": \"John Doe\",\n    \"site_contact_phone\": \"+966500000000\",\n    \"reported_issue\": \"AC is not cooling in the main server room.\",\n    \"asset_type_ids\": [1, 2],\n    \"attachments\": [\n        {\n            \"temporary_folder\": \"tmp_upload_12345\"\n        }\n    ]\n}"
						},
						"url": {
							"raw": "{{base_url}}/maintenance/requests",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"maintenance",
								"requests"
							]
						},
						"description": "Creates a new emergency maintenance request. Note: Ensure 'request_type' includes 'emergency' in the underlying logic if not explicitly passed."
					},
					"response": []
				}
			]
		}
	],
	"auth": {
		"type": "bearer",
		"bearer": [
			{
				"key": "token",
				"value": "{{auth_token}}",
				"type": "string"
			}
		]
	},
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "base_url",
			"value": "http://localhost/api/v1",
			"type": "string"
		},
		{
			"key": "auth_token",
			"value": "your_bearer_token_here",
			"type": "string"
		}
	]
}
