You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1342 lines
44 KiB

const installationController = require("../controllers/installationController")
module.exports = function (fastify, opts, next) {
fastify.post("/api/createTeamMember", {
schema: {
description: "Create a new team member under an installation",
tags: ["Installation"],
summary: "Create Team Member",
body: {
type: "object",
required: ["departmentId", "firstName", "phone", "password"],
properties: {
departmentId: { type: "string", description: "Installation ID to associate the team member with" },
firstName: { type: "string", description: "Full name of the team member" },
phone: { type: "string", description: "Phone number of the team member" },
password: { type: "string", description: "Password for the team member" },
alternativePhone: { type: "string", },
email: { type: "string", },
status: { type: "string", },
},
},
},
handler: installationController.createTeamMember,
});
fastify.get("/api/getTeamMembers/:departmentId", {
schema: {
description: "Get all team members under a specific department",
tags: ["Installation"],
summary: "Get Team Members by Department ID",
params: {
type: "object",
properties: {
departmentId: {
type: "string",
description: "Department ID to fetch team members from"
}
},
required: ["departmentId"]
},
},
handler: installationController.getTeamMembers
});
fastify.get("/api/getQuations/:installationId", {
schema: {
description: "Get all quatations under a specific installation",
tags: ["Installation"],
summary: "Get all quatations under a specific installation",
params: {
type: "object",
properties: {
installationId: {
type: "string",
description: "Installation ID to fetch team members from"
}
},
required: ["installationId"]
},
},
handler: installationController.getQuotationsByInstallationId
});
fastify.get("/api/getQuations/:installationId/:teamMemberId", {
schema: {
description: "Get all quatations under a specific installation and team member",
tags: ["Installation"],
summary: "Get all quatations under a specific installation and team member",
params: {
type: "object",
properties: {
installationId: {
type: "string",
description: "Installation ID to fetch team members from"
},
teamMemberId: {
type: "string",
description: "teamMember ID to fetch team members from"
}
},
// required: ["installationId"]
},
},
handler: installationController.getQuotationsByInstallationAndTeamMember
});
fastify.post("/api/assignTeammember/:installationId", {
schema: {
description: "Assign a team member to an installation's quotation",
tags: ["Installation"],
summary: "Assign a team member based on installationId",
params: {
type: "object",
properties: {
installationId: {
type: "string",
description: "Installation ID to fetch team members from"
}
},
required: ["installationId"]
},
body: {
type: "object",
properties: {
teamMemberId: {
type: "string",
description: "The team member ID to assign"
},
quotationId: {
type: "string",
description: "The team member ID to assign"
}
},
// required: ["teamMemberId"]
},
},
handler: installationController.assignTeamMemberToQuotation
});
fastify.get("/api/getAllInstallers/:departmentName", {
schema: {
description: "Get All Installtion list",
tags: ["Installation"],
summary: "Get All Installtion list",
params: {
type: "object",
properties: {
departmentName: {
type: "string",
description: "departmentName to fetch Installation list"
}
},
required: ["departmentName"]
},
},
handler: installationController.getAllInstallers
});
fastify.put("/api/editTeamMember/:installationId/:teamMemberId", {
schema: {
description: "Update an existing team member's details",
tags: ["Installation"],
summary: "Edit Team Member",
params: {
type: "object",
properties: {
installationId: { type: "string", description: "Installation ID" },
teamMemberId: { type: "string", description: "Team Member ID" }
},
required: ["installationId", "teamMemberId"]
},
body: {
type: "object",
properties: {
name: { type: "string" },
phone: { type: "string" },
email: { type: "string" },
alternativePhone: { type: "string" },
status: { type: "string" }
}
},
response: {
200: {
type: "object",
properties: {
simplydata: {
type: "object",
properties: {
error: { type: "boolean" },
message: { type: "string" }
}
}
}
}
}
},
handler: installationController.editTeamMember
});
fastify.delete("/api/deleteTeamMember/:installationId/:teamMemberId", {
schema: {
description: "Delete a team member from an installation",
tags: ["Installation"],
summary: "Delete Team Member",
params: {
type: "object",
properties: {
installationId: { type: "string", description: "Installation ID" },
teamMemberId: { type: "string", description: "Team Member ID" }
},
required: ["installationId", "teamMemberId"]
},
response: {
200: {
type: "object",
properties: {
simplydata: {
type: "object",
properties: {
error: { type: "boolean" },
message: { type: "string" }
}
}
}
}
}
},
handler: installationController.deleteTeamMember
});
7 months ago
fastify.get("/api/getDepartmentByFirstName/:firstName", {
schema: {
description: "Get department details by first name",
tags: ["Installation"],
summary: "Fetch department's firstName and phone",
params: {
type: "object",
properties: {
firstName: { type: "string", description: "Department's first name" },
},
required: ["firstName"],
},
},
handler: installationController.getDepartmentByFirstName,
});
fastify.get("/api/getGsmCheck/:hardwareId", {
schema: {
description: "Get GSM check details",
tags: ["Installation"],
summary: "Get GSM check details",
params: {
type: "object",
properties: {
hardwareId: { type: "string" },
},
required: ["hardwareId"],
},
},
handler: installationController.getByHardwareId,
});
fastify.get("/api/getGsmCheckSupport/:hardwareId", {
schema: {
description: "Get GSM check details Support",
tags: ["Installation"],
summary: "Get GSM check details Support",
params: {
type: "object",
properties: {
hardwareId: { type: "string" },
},
required: ["hardwareId"],
},
},
handler: installationController.getByHardwareIdSupport,
});
fastify.get("/api/getGsmCheckSupportTeamMember/:hardwareId", {
schema: {
description: "Get GSM check details Support Team Member",
tags: ["Installation"],
summary: "Get GSM check details Support Team Member",
params: {
type: "object",
properties: {
hardwareId: { type: "string" },
},
required: ["hardwareId"],
},
},
handler: installationController.getByHardwareIdSupportTeamMember,
});
fastify.get("/api/getLoraCheck/:hardwareId/:tankhardwareId", {
schema: {
description: "Get LORA check details",
tags: ["Installation"],
summary: "Get LORA check details",
params: {
type: "object",
properties: {
hardwareId: { type: "string" },
tankhardwareId: { type : "string"},
},
required: ["hardwareId","tankhardwareId"],
},
},
handler: installationController.getByHardwareAndTankId,
});
fastify.get("/api/getLoraCheckSupport/:hardwareId/:tankhardwareId", {
schema: {
description: "Get LORA check details Support",
tags: ["Installation"],
summary: "Get LORA check details Support",
params: {
type: "object",
properties: {
hardwareId: { type: "string" },
tankhardwareId: { type : "string"},
},
required: ["hardwareId","tankhardwareId"],
},
},
handler: installationController.getByHardwareAndTankIdSupport,
});
7 months ago
fastify.get("/api/getLoraCheckSupportTeamMember/:hardwareId/:tankhardwareId", {
schema: {
description: "Get LORA check details Support Team Member",
tags: ["Installation"],
summary: "Get LORA check details Support Team Member",
params: {
type: "object",
properties: {
hardwareId: { type: "string" },
tankhardwareId: { type : "string"},
},
required: ["hardwareId","tankhardwareId"],
},
},
handler: installationController.getByHardwareAndTankIdSupportTeamMember,
});
7 months ago
fastify.get("/api/getAllocatedSensorsByTank/:customerId/:tankName", {
schema: {
description: "Get allocated sensors by installationId, customerId, and tankName",
tags: ["Installation"],
summary: "Fetch allocated sensors for a given tank",
params: {
type: "object",
properties: {
// installationId: { type: "string" },
customerId: { type: "string" },
tankName: { type: "string" },
},
required: [ "customerId", "tankName"],
},
},
handler: installationController.getAllocatedSensorsByTank,
});
fastify.post("/api/createMasterSlaveData/:installationId", {
schema: {
description: "Create a new Master-Slave data entry under an installation",
tags: ["Installation"],
summary: "Save Master-Slave Data",
params: {
type: "object",
required: ["installationId"],
properties: {
installationId: { type: "string", description: "Installation ID" }
}
},
body: {
type: "object",
required: ["hardwareId", "masterId"],
properties: {
type: { type: "string" },
customerId: { type: "string" },
hardwareId: { type: "string" },
batchno: { type: "string" },
masterId: { type: "string" },
tankName: { type: "string" },
tankLocation: { type: "string" },
materialRecived: { type: "string" },
electricityWork: { type: "string" },
plumbingWork: { type: "string" },
loraCheck: { type: "string" },
materialRecievedPictures: {
type: "array",
items: {
type: "object",
properties: {
url: { type: "string", description: "Image URL" }, // No format validation
uploadedAt: { type: "string", format: "date-time", description: "Upload timestamp" }
}
}
},
electricityWorkPictures: {
type: "array",
items: {
type: "object",
properties: {
url: { type: "string", description: "Image URL" }, // No format validation
uploadedAt: { type: "string", format: "date-time", description: "Upload timestamp" }
}
}
},
plumbingWorkPictures: {
type: "array",
items: {
type: "object",
properties: {
url: { type: "string", description: "Image URL" }, // No format validation
uploadedAt: { type: "string", format: "date-time", description: "Upload timestamp" }
}
}
}
}
}
},
handler: installationController.createMasterSlaveData
});
fastify.get("/api/getmasterConnectedSlaveData/:connectedTo/:customerId", {
schema: {
description: "Get masrter connected slave data",
tags: ["Installation"],
summary: "Get masrter connected slave data",
params: {
type: "object",
properties: {
connectedTo: { type: "string" },
customerId: { type: "string" },
},
required: [ "connectedTo"],
},
},
handler: installationController.masterConnectedSlaveList,
});
fastify.post(
'/api/insensors/:customerId/media',
{
schema: {
summary: 'Add media (manual videos, material pictures, or work status pictures) to master or slave device',
description: 'Attach media files (video/images) to a specific Insensor (master or slave) by customerId',
tags: ['Installation'],
params: {
type: 'object',
required: ['customerId'],
properties: {
customerId: { type: 'string', description: 'Customer ID' }
}
},
body: {
type: 'object',
required: ['hardwareId', 'type'], // keep required fields
properties: {
hardwareId: { type: 'string', description: 'Hardware ID of the device' },
type: { type: 'string', enum: ['master', 'slave'], description: 'Device type' },
video: {
type: 'array',
items: { type: 'string', format: 'uri' },
description: 'URLs to save in manualTestVideos'
},
material: {
type: 'array',
items: { type: 'string', format: 'uri' },
description: 'URLs to save in materialReceivedPictures'
},
workStatus: {
type: 'array',
items: { type: 'string', format: 'uri' },
description: 'URLs to save in workStatusPictures'
},
product_status: {
type: 'string',
enum: ['pending', 'complete'],
description: 'Optional: update product_status'
}
},
// at least one of video, material, workStatus required
},
// response: {
// 200: {
// type: 'object',
// properties: {
// success: { type: 'boolean' },
// message: { type: 'string' },
// data: {
// type: 'object',
// description: 'Updated Insensor document'
// }
// }
// },
// 400: {
// type: 'object',
// properties: { success: { type: 'boolean' }, message: { type: 'string' } }
// },
// 404: {
// type: 'object',
// properties: { success: { type: 'boolean' }, message: { type: 'string' } }
// },
// 500: {
// type: 'object',
// properties: { success: { type: 'boolean' }, message: { type: 'string' } }
// }
// }
},
handler: installationController.addMediaToInsensor
}
);
fastify.get("/api/getmasterList/:customerId/:installationId", {
schema: {
description: "Get masrter connected slave data",
tags: ["Installation"],
summary: "Get masrter List",
params: {
type: "object",
properties: {
customerId: { type: "string" },
installationId: { type: "string" },
},
required: [ "customerId","installationId"],
},
},
handler: installationController.mastrerList,
});
fastify.get("/api/getmasterlistwithslaves/:customerId", {
schema: {
description: "Get masrter connected slave data with full info",
tags: ["Installation"],
summary: "Get masrter connected slave data with full info",
params: {
type: "object",
properties: {
customerId: { type: "string" },
},
required: [ "customerId"],
},
},
handler: installationController.getMasterSlaveSummary,
});
fastify.get("/api/getAllmasterlistwithslaves/:customerId", {
schema: {
description: "Get All check masrter connected slave data with full info",
tags: ["Installation"],
summary: "Get All check masrter connected slave data with full info",
params: {
type: "object",
properties: {
customerId: { type: "string" },
},
required: [ "customerId"],
},
},
handler: installationController.getIotDataByCustomer,
});
6 months ago
fastify.get("/api/getsinglemasterlistwithslaves/:customerId/:hardwareId", {
schema: {
description: "Get single check masrter connected slave data",
tags: ["Installation"],
summary: "Get single check masrter connected slave data",
params: {
type: "object",
properties: {
customerId: { type: "string" },
hardwareId: { type: "string" },
},
required: [ "customerId"],
},
},
handler: installationController.getIotDataByCustomerAndHardwareId,
});
// fastify.get("/api/getraiseAticket/:customerId/:connected_to", {
// schema: {
// description: "Raise A Ticket for Support",
// tags: ["Support"],
// summary: "Raise A Ticket for Support",
// params: {
// type: "object",
// properties: {
// customerId: { type: "string" },
// connected_to: { type: "string" },
// },
// required: [ "customerId"],
// },
// },
// handler: installationController.raiseATicket,
// });
fastify.get("/api/getraiseAticketBuildingDetails/:customerId/:connected_to/:installationId", {
schema: {
description: "Raise A Ticket for Support Building Details",
tags: ["Support"],
summary: "Raise A Ticket for Support Building Details",
params: {
type: "object",
properties: {
customerId: { type: "string" },
connected_to: { type: "string" },
installationId: { type: "string" },
},
required: [ "customerId"],
},
},
handler: installationController.raiseATicketBuildingDetails,
});
5 months ago
fastify.get("/api/getraiseAticketslave/:customerId/:connected_to/:tankHardwareId", {
schema: {
description: "Raise A Ticket particular slave for Support",
tags: ["Support"],
summary: "Raise A Ticket particular slave for Support",
params: {
type: "object",
properties: {
customerId: { type: "string" },
connected_to: { type: "string" },
tankHardwareId: { type: "string" },
},
required: [ "customerId"],
},
},
handler: installationController.raiseATicketSlave,
});
fastify.get("/api/getAllDisconnectedIsuues/:supportId/:customerId", {
schema: {
description: "Get All disconnected list for Support",
tags: ["Support"],
summary: "Get All disconnected list for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
customerId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.getDisconnectedIssuesBySupportId,
});
fastify.get("/api/getAllResolvedIsuues/:supportId/:customerId", {
schema: {
description: "Get All Resolved list for Support",
tags: ["Support"],
summary: "Get All Resolved list for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
customerId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.getResolvedIssuesBySupportId,
});
fastify.put('/api/updateComments/:supportId', {
schema: {
description: "Update comments and call status for a support record issue",
tags: ["Support"],
params: {
type: "object",
required: ["supportId"],
properties: {
supportId: { type: "string", minLength: 1 }
}
},
body: {
type: "object",
3 months ago
// required: ["customerId", "hardwareId", "comments", "call_status", "call_time"],
properties: {
3 months ago
customerId: { type: "string"},
hardwareId: { type: "string" },
comments: { type: "string"},
call_status: { type: "string"},
call_time: { type: "string" }
}
}
},
handler: installationController.updateComments
});
fastify.get("/api/getRemoveAllConnectedIsuues/:supportId/:hardwareId", {
schema: {
description: "Remove all connected list for Support",
tags: ["Support"],
summary: "Remove all connected list for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
hardwareId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.getRemoveConnectedMastersWithSlaves,
});
5 months ago
fastify.get("/api/fetchthebuildingdetails/:supportId", {
schema: {
description: "Get building details for Support",
tags: ["Support"],
summary: "Get building details list for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.getDisconnectedCustomerDetails,
});
fastify.get("/api/disconnectedCustomersbyTeamMember/:support_teamMemberId", {
schema: {
description: "Get disconnected customer details by team member ID",
tags: ["Support"],
summary: "Disconnected Customer Details by Team Member",
params: {
type: "object",
properties: {
support_teamMemberId: { type: "string" }
},
required: ["support_teamMemberId"]
}
},
handler: installationController.getDisconnectedCustomerDetailsByTeamMemberId
});
fastify.get("/api/moveisseshebuildingdetails/:supportId", {
schema: {
description: "Move the ticket Get building details move for Support",
tags: ["Support"],
summary: "Move the ticket Get building details move for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.getDisconnectedMoveCustomerDetails,
});
fastify.get("/api/resolveissusesbuildingdetails/:supportId", {
schema: {
description: "Resolve the ticket Get building details move for Support",
tags: ["Support"],
summary: "Resolve the ticket Get building details move for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.getResolvedCustomerDetails,
});
fastify.get("/api/longTermissusesbuildingdetails/:supportId", {
schema: {
description: "Long Term Issues the ticket Get building details move for Support",
tags: ["Support"],
summary: "Long Term Issues the ticket Get building details move for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.getLongTermCustomerDetails,
});
fastify.get("/api/outDoorEscalationissusesbuildingdetails/:supportId", {
schema: {
description: "Out Door Escalation Issues the ticket Get building details move for Support",
tags: ["Support"],
summary: "Out Door Escalation Issues the ticket Get building details move for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.outDoorEscalationCustomerDetails,
});
fastify.get("/api/powerOutageissusesbuildingdetails/:supportId", {
schema: {
description: "Power Outage Issues the ticket Get building details move for Support",
tags: ["Support"],
summary: "Power Outage Issues the ticket Get building details move for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.powerOutageCustomerDetails,
});
3 months ago
fastify.get("/api/longTermissusesmasterslavedetails/:supportId/:customerId", {
schema: {
description: "Long Term Issues the master and slave details move for Support",
tags: ["Support"],
summary: "Long Term Issues the master and slave details move for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
customerId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.getLongTermIssuesByCustomer,
});
fastify.get("/api/powerOutageissusesmasterslavedetails/:supportId/:customerId", {
schema: {
description: "Power Outgae Issues the master and slave details move for Support",
tags: ["Support"],
summary: "Power Outage Issues the master and slave details move for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
customerId: { type: "string" },
},
required: [ "supportId"],
},
},
3 months ago
handler: installationController.getPowerOutageIssuesByCustomer,
});
fastify.get("/api/outDoorEscalationissusesmasterslavedetails/:supportId/:customerId", {
schema: {
description: "Out Door Escalation Issues the master and slave details move for Support",
tags: ["Support"],
summary: "Out Door Escalation Issues the master and slave details move for Support",
params: {
type: "object",
properties: {
supportId: { type: "string" },
customerId: { type: "string" },
},
required: [ "supportId"],
},
},
handler: installationController.getOutDoorEscalationIssuesByCustomer,
});
fastify.route({
method: 'POST',
5 months ago
url: '/api/supportCreateTeamMember/:supportId',
schema: {
tags: ['Support'],
summary: 'Create a new team member under a support record',
params: {
type: 'object',
properties: {
supportId: { type: 'string', description: 'Support ID' },
},
required: ['supportId'],
},
body: {
type: 'object',
properties: {
name: { type: 'string' },
phone: { type: 'string' },
password: { type: 'string' },
email: { type: 'string' },
alternativePhone: { type: 'string' },
status: { type: 'string', enum: ['active', 'inactive'], default: 'active' }
},
required: [ 'name', 'phone']
},
},
handler: installationController.createTeamMemberSupport
});
fastify.get("/api/supportTeamMembersList/:supportId/", {
schema: {
description: "Get all team members for a support user",
tags: ["Support"],
summary: "Get all team members for a support user",
params: {
type: "object",
required: ["supportId"],
properties: {
supportId: { type: "string", description: "Support ID" }
}
}
},
handler: installationController.getAllTeamMembersListSupport
});
fastify.put("/api/supportUpdateTeamMember/:supportId/:teamMemberId", {
schema: {
description: "Update a support team member by ID",
tags: ["Support"],
summary: "Update a support team member by ID",
params: {
type: "object",
required: ["supportId", "teamMemberId"],
properties: {
supportId: { type: "string" },
teamMemberId: { type: "string" }
}
},
body: {
type: "object",
properties: {
name: { type: "string" },
phone: { type: "string" },
password: { type: "string" },
email: { type: "string" },
alternativePhone: { type: "string" },
status: { type: "string" }
}
}
},
handler: installationController.updateTeamMemberSupport
});
fastify.delete("/api/supportDeleteTeamMember/:supportId/:teamMemberId", {
schema: {
description: "Delete a support team member by ID",
tags: ["Support"],
summary: "Delete a support team member by ID",
params: {
type: "object",
required: ["supportId", "teamMemberId"],
properties: {
supportId: { type: "string" },
teamMemberId: { type: "string" }
}
}
},
handler: installationController.deleteTeamMemberSupport
});
5 months ago
fastify.post("/api/moveIssueToCategory/:supportId", {
schema: {
description: "Move specific issue to a categorized bucket",
tags: ["Support"],
summary: "Move disconnected issue to category and remove from issues list",
5 months ago
params: {
type: "object",
5 months ago
required: ["supportId"],
properties: {
supportId: { type: "string" },
5 months ago
},
},
body: {
type: "object",
required: ["category", "hardwareId"],
properties: {
category: { type: "string" },
hardwareId: { type: "string" },
},
},
},
handler: installationController.moveIssueToCategory
});
// fastify.get('/api/support/categorizedIssues/:supportId/:category', {
// schema: {
// description: 'Get all issues in a particular category for a support record',
// tags: ['Support'],
// summary: 'Fetch issues by category',
// params: {
// type: 'object',
// required: ['supportId', 'category'],
// properties: {
// supportId: { type: 'string' },
// //customerId: { type: 'string' },
// category: {
// type: 'string',
// enum: ['Power Outage', 'Level1', 'Pending', 'Onsite Issues'] // your allowed categories
// }
// }
// },
// },
// handler: installationController.particularCategory
// });
fastify.get('/api/support/categorizedIssues/:supportId/:category', {
schema: {
description: 'Get all issues in a particular category for a support record',
tags: ['Support'],
summary: 'Fetch issues by category',
params: {
type: 'object',
required: ['supportId', 'category'],
properties: {
supportId: { type: 'string' },
category: {
type: 'string',
4 months ago
enum: ["Power Outage",
"Resolved",
3 months ago
"OutDoor Escalation",
"LongTerm Issues"]
}
}
},
querystring: { // ✅ allow customerId in query string
type: 'object',
required: ['customerId'],
properties: {
customerId: { type: 'string' }
}
}
},
handler: installationController.particularCategory
});
fastify.post('/api/support/sendToStoreHardwareList/:supportId/:customerId', {
schema: {
description: 'Send to store the hardware list',
tags: ['Support'],
summary: 'Send to store the hardware list',
params: {
type: 'object',
required: ['supportId', 'customerId'],
properties: {
supportId: { type: 'string' },
customerId: { type: 'string' },
}
},
body: {
type: "object",
required: ["storeId"],
properties: {
storeId: { type: "string" },
3 months ago
type: { type: "string" },
},
},
},
handler: installationController.sendToStoreHardwareList
});
fastify.post('/api/repair-order/:supportId/:customerId',{
schema: {
summary: 'Create a new Repair Order',
description: 'Creates a repair order for the given supportId and customerId with replacements.',
tags: ['Repair Orders'],
params: {
type: 'object',
required: ['supportId', 'customerId'],
properties: {
supportId: { type: 'string', description: 'Support ID' },
customerId: { type: 'string', description: 'Customer ID' }
}
},
body: {
type: 'object',
required: ['replacements'],
properties: {
storeId: { type: 'string', description: 'Store ID where the repair is logged' },
status: {
type: 'string',
enum: ['pending', 'completed'],
default: 'pending',
description: 'Status of the repair order'
},
replacements: {
type: 'array',
description: 'List of hardware replacements',
items: {
type: 'object',
required: ['type', 'oldHardwareId', 'newHardwareId'],
properties: {
type: {
type: 'string',
enum: ['master', 'slave', 'sensor'],
description: 'Type of the hardware being replaced'
},
oldHardwareId: { type: 'string', description: 'Old hardware ID' },
newHardwareId: { type: 'string', description: 'New hardware ID' }
}
},
minItems: 1
}
}
},
},
handler: installationController.createRepairOrder
});
fastify.post("/api/assignTeamMemberIssueToCategory/:supportId", {
schema: {
5 months ago
description: "Assign a team member to a categorized issue",
tags: ["Support"],
5 months ago
summary: "Assign a team member to a categorized issue",
params: {
type: "object",
required: ["supportId"],
properties: {
supportId: { type: "string" },
},
},
body: {
type: "object",
5 months ago
//required: [ "support_teamMemberId", "startDate", "endDate", "category", "masterHardwareId"],
properties: {
support_teamMemberId: { type: "string" },
// startDate: { type: "string" },
// endDate: { type: "string" },
5 months ago
category: { type: "string" },
masterHardwareId: { type: "string" },
},
},
},
handler: installationController.assignCategorizeIssue
});
5 months ago
fastify.route({
method: 'POST',
url: '/api/updateHardwareList/:supportId/:customerId/:hardwareId',
schema: {
tags: ['Support'],
summary: 'Update hardware list for an escalated issue',
description: 'Updates the hardwareList (array of name-value objects) in Insensors schema only if issue is categorized as Escalation',
params: {
type: 'object',
required: ['supportId', 'customerId', 'hardwareId'],
properties: {
supportId: { type: 'string', description: 'Support record ID' },
customerId: { type: 'string', description: 'Customer ID' },
hardwareId: { type: 'string', description: 'Hardware ID of the master/slave' }
}
},
body: {
type: 'object',
required: ['hardwareList'],
properties: {
hardwareList: {
type: 'array',
description: 'List of hardware components as name-value objects',
items: {
type: 'object',
required: ['name', 'value'],
properties: {
name: { type: 'string', description: 'Component name (e.g., masters, slaves)' },
value: { type: 'number', description: 'Quantity of the component' }
}
},
example: [
{ name: 'masters', value: 2 },
{ name: 'slaves', value: 2 },
{ name: 'sensors', value: 4 },
{ name: 'plugs', value: 3 },
{ name: 'wires', value: 200 }
]
}
}
},
response: {
200: {
description: 'Successfully updated hardwareList',
type: 'object',
properties: {
status_code: { type: 'number' },
message: { type: 'string' },
data: {
type: 'object',
properties: {
supportId: { type: 'string' },
customerId: { type: 'string' },
hardwareId: { type: 'string' },
hardwareList: {
type: 'array',
items: {
type: 'object',
properties: {
name: { type: 'string' },
value: { type: 'number' }
}
}
}
}
}
}
},
400: {
description: 'Missing or invalid input',
type: 'object',
properties: {
error: { type: 'string' }
}
},
403: {
description: 'Not allowed (issue is not escalated)',
type: 'object',
properties: {
error: { type: 'string' }
}
},
404: {
description: 'Support or sensor not found',
type: 'object',
properties: {
error: { type: 'string' }
}
},
500: {
description: 'Internal server error',
type: 'object',
properties: {
error: { type: 'string' }
}
}
}
},
handler: installationController.updateHardwareList
});
fastify.post("/api/my-categorized-issues/:support_teamMemberId/:customerId", {
schema: {
description: "Get categorized issues by team member and customer",
tags: ["Support"],
summary: "Get categorized issues for a particular team member and customer",
params: {
type: "object",
required: ["support_teamMemberId", "customerId"],
properties: {
support_teamMemberId: { type: "string" },
customerId: { type: "string" }
}
}
},
handler: installationController.getCategorizedIssue
});
fastify.post("/api/updateStatusTeammember/:support_teamMemberId", {
schema: {
description: "Team Member status matain for support",
tags: ["Support"],
summary: "Team Member status matain for support",
params: {
type: "object",
properties: {
support_teamMemberId: {
type: "string",
}
},
},
body: {
type: "object",
properties: {
status: {
type: "string",
},
},
},
},
handler: installationController.StatusTeamMember
});
fastify.put('/api/resolvedIssues/:supportId', {
schema: {
description: "Resolved Issues for Support Team",
tags: ["Support"],
params: {
type: "object",
required: ["supportId"],
properties: {
supportId: { type: "string", minLength: 1 },
}
},
4 months ago
body: {
type: "object",
required: ["category", "hardwareId"],
properties: {
category: { type: "string" },
hardwareId: { type: "string" },
},
},
},
handler: installationController.resolvedIssuesForSupport
});
fastify.put('/api/resolvedAllDevicesAreConnected/:supportId', {
schema: {
description: "All Devices are connected Resolved Issues for Support Team",
tags: ["Support"],
params: {
type: "object",
required: ["supportId"],
properties: {
supportId: { type: "string", minLength: 1 },
}
},
body: {
type: "object",
required: ["category", "hardwareId"],
properties: {
category: { type: "string" },
hardwareId: { type: "string" },
reason: { type: "string" },
},
},
},
handler: installationController.resolveIssueIfAllConnected
});
next();
}