{
	"info": {
		"name": "Maintenance Visit Checklists API",
		"description": "Complete API collection for Maintenance Visit Checklists with inheritance support",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"version": "1.0.0"
	},
	"auth": {
		"type": "bearer",
		"bearer": [
			{
				"key": "token",
				"value": "{{access_token}}",
				"type": "string"
			}
		]
	},
	"variable": [
		{
			"key": "BASE_URL",
			"value": "http://192.168.1.1:8001",
			"type": "string"
		},
		{
			"key": "access_token",
			"value": "",
			"type": "string"
		},
		{
			"key": "checklist_id",
			"value": "",
			"type": "string"
		},
		{
			"key": "item_id",
			"value": "",
			"type": "string"
		},
		{
			"key": "project_id",
			"value": "",
			"type": "string"
		},
		{
			"key": "asset_type_id",
			"value": "",
			"type": "string"
		},
		{
			"key": "visit_id",
			"value": "",
			"type": "string"
		}
	],
	"item": [
		{
			"name": "Checklists CRUD",
			"item": [
				{
					"name": "Get All Checklists",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists?per_page=15",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists"],
							"query": [
								{
									"key": "per_page",
									"value": "15",
									"description": "Items per page"
								}
							]
						},
						"description": "Get paginated list of all maintenance visit checklists"
					},
					"response": []
				},
				{
					"name": "Get Checklist by ID",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/{{checklist_id}}",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "{{checklist_id}}"]
						},
						"description": "Get a specific checklist by ID with all its items"
					},
					"response": []
				},
				{
					"name": "Create Checklist",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"if (pm.response.code === 201) {",
									"    var jsonData = pm.response.json();",
									"    pm.collectionVariables.set('checklist_id', jsonData.data.id);",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"title\": \"HVAC Maintenance Checklist\",\n    \"description\": \"General HVAC equipment maintenance checklist\",\n    \"maintenance_project_id\": 1,\n    \"maintenance_asset_type_id\": 1,\n    \"is_active\": true,\n    \"items\": [\n        {\n            \"question_text\": \"Check refrigerant levels\",\n            \"question_type\": \"yes_no\",\n            \"is_required\": true,\n            \"order_position\": 1,\n            \"help_text\": \"Verify refrigerant is at proper levels\"\n        },\n        {\n            \"question_text\": \"Inspect electrical connections\",\n            \"question_type\": \"yes_no\",\n            \"is_required\": true,\n            \"order_position\": 2\n        },\n        {\n            \"question_text\": \"Temperature reading\",\n            \"question_type\": \"number\",\n            \"is_required\": true,\n            \"order_position\": 3,\n            \"help_text\": \"Record temperature in Celsius\"\n        },\n        {\n            \"question_text\": \"Overall condition rating\",\n            \"question_type\": \"rating\",\n            \"is_required\": false,\n            \"order_position\": 4,\n            \"help_text\": \"Rate from 1-5\"\n        },\n        {\n            \"question_text\": \"Additional notes\",\n            \"question_type\": \"text\",\n            \"is_required\": false,\n            \"order_position\": 5\n        }\n    ]\n}"
						},
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists"]
						},
						"description": "Create a new maintenance checklist with items"
					},
					"response": []
				},
				{
					"name": "Update Checklist",
					"request": {
						"method": "PUT",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"title\": \"HVAC Maintenance Checklist - Updated\",\n    \"description\": \"Updated description\",\n    \"is_active\": true,\n    \"items\": [\n        {\n            \"id\": 1,\n            \"question_text\": \"Check refrigerant levels - Updated\",\n            \"question_type\": \"yes_no\",\n            \"is_required\": true,\n            \"order_position\": 1\n        },\n        {\n            \"question_text\": \"New question added\",\n            \"question_type\": \"text\",\n            \"is_required\": false,\n            \"order_position\": 6\n        }\n    ]\n}"
						},
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/{{checklist_id}}",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "{{checklist_id}}"]
						},
						"description": "Update an existing checklist and its items"
					},
					"response": []
				},
				{
					"name": "Delete Checklist",
					"request": {
						"method": "DELETE",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/{{checklist_id}}",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "{{checklist_id}}"]
						},
						"description": "Soft delete a checklist"
					},
					"response": []
				},
				{
					"name": "Duplicate Checklist",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"title\": \"HVAC Maintenance Checklist - Copy\",\n    \"maintenance_project_id\": 2,\n    \"maintenance_asset_type_id\": 1\n}"
						},
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/{{checklist_id}}/duplicate",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "{{checklist_id}}", "duplicate"]
						},
						"description": "Duplicate an existing checklist with all its items"
					},
					"response": []
				},
				{
					"name": "Search Checklists",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/search/query?q=HVAC",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "search", "query"],
							"query": [
								{
									"key": "q",
									"value": "HVAC",
									"description": "Search query"
								}
							]
						},
						"description": "Search checklists by title or description"
					},
					"response": []
				}
			]
		},
		{
			"name": "Checklists by Filters",
			"item": [
				{
					"name": "Get Checklists by Project",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/project/{{project_id}}",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "project", "{{project_id}}"]
						},
						"description": "Get all checklists for a specific project"
					},
					"response": []
				},
				{
					"name": "Get Checklists by Asset Type",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/asset-type/{{asset_type_id}}",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "asset-type", "{{asset_type_id}}"]
						},
						"description": "Get checklists for a specific asset type (direct only, no inheritance)"
					},
					"response": []
				}
			]
		},
		{
			"name": "Inheritance Features",
			"item": [
				{
					"name": "Get Checklists by Asset Type (With Inheritance)",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/asset-type/{{asset_type_id}}/with-inheritance",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "asset-type", "{{asset_type_id}}", "with-inheritance"]
						},
						"description": "Get checklists for an asset type including inherited checklists from parent asset types. Recursively traverses up the hierarchy."
					},
					"response": []
				},
				{
					"name": "Get Checklists by Project & Asset Type (With Inheritance)",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/project/{{project_id}}/asset-type/{{asset_type_id}}/with-inheritance",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "project", "{{project_id}}", "asset-type", "{{asset_type_id}}", "with-inheritance"]
						},
						"description": "Get checklists for a specific project and asset type including inherited checklists from parent asset types"
					},
					"response": []
				}
			]
		},
		{
			"name": "Checklist Items Management",
			"item": [
				{
					"name": "Add Item to Checklist",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"if (pm.response.code === 201) {",
									"    var jsonData = pm.response.json();",
									"    pm.collectionVariables.set('item_id', jsonData.data.id);",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"question_text\": \"Check air filter condition\",\n    \"question_type\": \"yes_no\",\n    \"is_required\": true,\n    \"order_position\": 10,\n    \"help_text\": \"Replace if dirty or clogged\"\n}"
						},
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/{{checklist_id}}/items",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "{{checklist_id}}", "items"]
						},
						"description": "Add a new item to an existing checklist"
					},
					"response": []
				},
				{
					"name": "Update Checklist Item",
					"request": {
						"method": "PUT",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"question_text\": \"Check and clean air filter\",\n    \"question_type\": \"yes_no\",\n    \"is_required\": true,\n    \"order_position\": 10,\n    \"help_text\": \"Clean or replace if needed\"\n}"
						},
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/{{checklist_id}}/items/{{item_id}}",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "{{checklist_id}}", "items", "{{item_id}}"]
						},
						"description": "Update a specific checklist item"
					},
					"response": []
				},
				{
					"name": "Delete Checklist Item",
					"request": {
						"method": "DELETE",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/{{checklist_id}}/items/{{item_id}}",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "{{checklist_id}}", "items", "{{item_id}}"]
						},
						"description": "Delete a checklist item"
					},
					"response": []
				}
			]
		},
		{
			"name": "Visit Checklist Responses",
			"item": [
				{
					"name": "Get Visit Checklist Responses",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/visits/{{visit_id}}/checklist",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "visits", "{{visit_id}}", "checklist"]
						},
						"description": "Get all checklist responses for a specific visit"
					},
					"response": []
				},
				{
					"name": "Save Visit Checklist Responses",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"maintenance_visit_id\": 1,\n    \"responses\": [\n        {\n            \"maintenance_checklist_item_id\": 1,\n            \"response_value\": \"yes\",\n            \"notes\": \"Refrigerant levels are normal\",\n            \"is_compliant\": true\n        },\n        {\n            \"maintenance_checklist_item_id\": 2,\n            \"response_value\": \"yes\",\n            \"notes\": \"All connections are tight\",\n            \"is_compliant\": true\n        },\n        {\n            \"maintenance_checklist_item_id\": 3,\n            \"response_value\": \"22.5\",\n            \"notes\": \"Temperature reading in Celsius\",\n            \"is_compliant\": true\n        },\n        {\n            \"maintenance_checklist_item_id\": 4,\n            \"response_value\": \"5\",\n            \"notes\": \"Excellent condition\",\n            \"is_compliant\": true\n        },\n        {\n            \"maintenance_checklist_item_id\": 5,\n            \"response_value\": \"Unit is operating efficiently. No issues found.\",\n            \"notes\": null,\n            \"is_compliant\": true\n        }\n    ]\n}"
						},
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/visits/{{visit_id}}/responses",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "visits", "{{visit_id}}", "responses"]
						},
						"description": "Save or update checklist responses for a visit"
					},
					"response": []
				}
			]
		},
		{
			"name": "Examples - Complete Workflow",
			"item": [
				{
					"name": "1. Create Parent Asset Type (HVAC)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"if (pm.response.code === 201) {",
									"    var jsonData = pm.response.json();",
									"    pm.collectionVariables.set('parent_asset_type_id', jsonData.data.id);",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"name\": \"HVAC Equipment\",\n    \"description\": \"General HVAC equipment category\",\n    \"code\": \"HVAC-001\",\n    \"is_active\": true\n}"
						},
						"url": {
							"raw": "{{BASE_URL}}/maintenance/asset-types",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "asset-types"]
						},
						"description": "Create parent asset type (NOTE: Replace with actual asset-types endpoint)"
					},
					"response": []
				},
				{
					"name": "2. Create Child Asset Type (Air Conditioner)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"if (pm.response.code === 201) {",
									"    var jsonData = pm.response.json();",
									"    pm.collectionVariables.set('child_asset_type_id', jsonData.data.id);",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"name\": \"Air Conditioner\",\n    \"description\": \"Air conditioning units\",\n    \"code\": \"AC-001\",\n    \"parent_id\": \"{{parent_asset_type_id}}\",\n    \"is_active\": true\n}"
						},
						"url": {
							"raw": "{{BASE_URL}}/maintenance/asset-types",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "asset-types"]
						},
						"description": "Create child asset type with parent_id (NOTE: Replace with actual asset-types endpoint)"
					},
					"response": []
				},
				{
					"name": "3. Create Checklist for Parent",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"if (pm.response.code === 201) {",
									"    var jsonData = pm.response.json();",
									"    pm.collectionVariables.set('parent_checklist_id', jsonData.data.id);",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"title\": \"General HVAC Checklist\",\n    \"description\": \"Common checks for all HVAC equipment\",\n    \"maintenance_project_id\": 1,\n    \"maintenance_asset_type_id\": \"{{parent_asset_type_id}}\",\n    \"is_active\": true,\n    \"items\": [\n        {\n            \"question_text\": \"Check power supply\",\n            \"question_type\": \"yes_no\",\n            \"is_required\": true,\n            \"order_position\": 1\n        },\n        {\n            \"question_text\": \"Inspect for leaks\",\n            \"question_type\": \"yes_no\",\n            \"is_required\": true,\n            \"order_position\": 2\n        }\n    ]\n}"
						},
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists"]
						},
						"description": "Create checklist for parent asset type"
					},
					"response": []
				},
				{
					"name": "4. Create Checklist for Child",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"if (pm.response.code === 201) {",
									"    var jsonData = pm.response.json();",
									"    pm.collectionVariables.set('child_checklist_id', jsonData.data.id);",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"title\": \"Air Conditioner Specific Checklist\",\n    \"description\": \"Checks specific to AC units\",\n    \"maintenance_project_id\": 1,\n    \"maintenance_asset_type_id\": \"{{child_asset_type_id}}\",\n    \"is_active\": true,\n    \"items\": [\n        {\n            \"question_text\": \"Check refrigerant levels\",\n            \"question_type\": \"yes_no\",\n            \"is_required\": true,\n            \"order_position\": 1\n        },\n        {\n            \"question_text\": \"Clean air filters\",\n            \"question_type\": \"yes_no\",\n            \"is_required\": true,\n            \"order_position\": 2\n        }\n    ]\n}"
						},
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists"]
						},
						"description": "Create checklist specific to child asset type"
					},
					"response": []
				},
				{
					"name": "5. Get Inherited Checklists (Child)",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{BASE_URL}}/maintenance/checklists/asset-type/{{child_asset_type_id}}/with-inheritance",
							"host": ["{{BASE_URL}}"],
							"path": ["maintenance", "checklists", "asset-type", "{{child_asset_type_id}}", "with-inheritance"]
						},
						"description": "Get all checklists for child asset type - should return BOTH parent and child checklists"
					},
					"response": []
				}
			]
		}
	]
}
