const fastify = require("fastify"); const supplierOrderController = require("../controllers/supplierOrderController"); const validationHandler = require("../handlers/supplierHandler"); module.exports = function (fastify, opts, next) { fastify.route({ method: "POST", url: "/api/ordernow/:bookingId", schema: { tags: ["Supplier-Order"], description:"This is for giving booking data to supplier", summary: "This is for giving booking data to supplier", params: { required: ["bookingId"], type: "object", properties: { bookingId: { type: "string", description: "bookingId", }, }, }, body: { type: "object", properties: { supplierName: {type: 'string'}, supplierId: { type: "string" }, customerId:{type:"string"}, capacity: { type: "string" }, customer_address: { type: "string" }, dateOfOrder: { type: "string"}, action:{type:"string"}, price :{type:"string"}, delivery_agent :{type:"string"}, agent_mobile :{type:"string"}, agent_alternative_mobile :{type:"string"}, expectedDateOfDelivery : { type: "string"}, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler:supplierOrderController.orderNow, // onResponse: (request, reply) => { // validationHandler.sendPhoneVerificationCode(request, reply); // }, //onResponse: validationHandler.sendPhoneVerificationCode, }); fastify.route({ method: "POST", url: "/api/orderStartedSms/:bookingId", schema: { tags: ["Supplier-Order"], description:"This is for giving booking data to user through sms", summary: "This is for giving booking data to user through sms", params: { required: ["bookingId"], type: "object", properties: { bookingId: { type: "string", description: "bookingId", }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler:supplierOrderController.orderStartedSms, // onResponse: (request, reply) => { // validationHandler.sendPhoneVerificationCode(request, reply); // }, //onResponse: validationHandler.sendPhoneVerificationCode, }); fastify.route({ method: "POST", url: "/api/addDeliveryboys/:supplierId", schema: { tags: ["Delivery"], description: "This is for adding delivery boys", summary: "This is for adding delivery boys", params: { required: ["supplierId"], type: "object", properties: { supplierId: { type: "string", description: "supplierId", }, }, }, body: { type: "object", properties: { suppliername: { type: "string"}, Name: { type: "string" }, phone: { type: "string" }, alternativeContactNumber : { type : "string" }, address: { type: "string", default: null }, city: { type: "string", default: null }, state: { type: "string", default: null }, zip: { type: "string", default: null }, status: { type: "string" }, latitude: { type: 'number', default: 0.0 }, longitude: { type: 'number', default: 0.0}, fcmId: { type: "string", default: null }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: [ //validationHandler.fieldCheck, //validationHandler.verifySupplier, // validationHandler.validatePhoneFormat, //validationHandler.validateEmailFormat, ], handler: supplierOrderController.addDeliveryboy, }); fastify.get("/api/getsupplierbookings/:supplierId", { schema: { tags: ["Supplier"], description: "This is for Get supplier bookings Data", summary: "This is for to Get supplier bookings Data", params: { required: ["supplierId"], type: "object", properties: { supplierId: { type: "string", description: "supplierId", }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: supplierOrderController.getbookingsofsupplier, }); fastify.get("/api/getdeliveryboybookings/:agent_mobile", { schema: { tags: ["Delivery"], description: "This is for Get delivery bookings Data", summary: "This is for to Get delivery bookings Data", params: { required: ["agent_mobile"], type: "object", properties: { agent_mobile: { type: "string", description: "agent_mobile", }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: supplierOrderController.getbookingsofdeliveryboy, }); fastify.get("/api/getalldeliveryboys/:supplierId", { schema: { tags: ["Delivery"], description: "This is for Get all delivery boys under supplier", summary: "This is for to Get all delivery boys under supplier", params: { required: ["supplierId"], type: "object", properties: { supplierId: { type: "string", description: "supplierId", }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: supplierOrderController.getalldeliveryboysofsupplier, }); fastify.get("/api/getactivedeliveryboys/:supplierId", { schema: { tags: ["Delivery"], description: "This is for Get all active delivery boys under supplier", summary: "This is for to Get all active delivery boys under supplier", params: { required: ["supplierId"], type: "object", properties: { supplierId: { type: "string", description: "supplierId", }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: supplierOrderController.getactivedeliveryboysofsupplier, }); fastify.route({ method: "PUT", url: "/api/deliveryboystartandstop/:bookingId", schema: { tags: ["Delivery"], summary: "This is for delivery boy start and stop", params: { required: ["bookingId"], type: "object", properties: { bookingId: { type: "string", description: "bookingId", }, }, }, body: { type: "object", // required: ['phone'], properties: { action: { type: "string" }, percentage: { type: "string",default: "100" }, //startTime:{ type: "string" }, //stopTime:{ type: "string" }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: [ // fastify.auth([fastify.operatorAuthenticate]), // validationHandler.validatePhoneFormat, // ], preHandler: fastify.auth([fastify.authenticate]), handler: supplierOrderController.deliveryboystartandstop, }); fastify.route({ method: "PUT", url: "/api/amountpaidByCustomer/:bookingId", schema: { tags: ["Delivery"], summary: "This is for delivery boy to update the amount paid by customer after start and stop", params: { required: ["bookingId"], type: "object", properties: { bookingId: { type: "string", description: "bookingId", }, }, }, body: { type: "object", // required: ['phone'], properties: { amount_paid: { type: "string" }, payment_mode: { type: "string" }, orderStatus:{type:"string"}, deliveredDate: { type: "string"}, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: [ // fastify.auth([fastify.operatorAuthenticate]), // validationHandler.validatePhoneFormat, // ], preHandler: fastify.auth([fastify.authenticate]), handler: supplierOrderController.amountUpdateByDeliveryBoy, }); fastify.get("/api/userAccounts/:customerId", { schema: { tags: ["User"], description: "This is for Get accounts of user", summary: "This is for to Get accounts of user", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: supplierOrderController.userAccounts, }); fastify.get("/api/supplierAccounts/:supplierId", { schema: { tags: ["Supplier"], description: "This is for Get accounts of Supplier", summary: "This is for to Get accounts of Supplier", params: { required: ["supplierId"], type: "object", properties: { supplierId: { type: "string", description: "supplierId", }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: supplierOrderController.supplierAccounts, }); fastify.route({ method: "PUT", url: "/api/tankerAccounts/:supplierId", schema: { tags: ["Tanker-Data"], summary: "This is for tanker accounts", params: { required: ["supplierId"], type: "object", properties: { supplierId: { type: "string", description: "supplierId", }, }, }, body: { type: "object", // required: ['phone'], properties: { customerId: { type: "string" }, tankerName: { type: "string" }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: [ // fastify.auth([fastify.operatorAuthenticate]), // validationHandler.validatePhoneFormat, // ], preHandler: fastify.auth([fastify.authenticate]), handler: supplierOrderController.tankerAccounts, }); fastify.route({ method: "GET", url: "/api/accepted/:customerId", schema: { tags: ["Supplier-Order"], description:"This is for Get All order pending for delivery", summary: "This is for Get All order pending for delivery", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, security: [ { basicAuth: [], }, ], }, handler:supplierOrderController.getAllOrderaccepted, }); fastify.route({ method: "GET", url: "/api/allrejected", schema: { tags: ["Supplier-Order"], description:"This is for Get All order cancelled", summary: "This is for Get All order cancelled", // params: { // required: ["customerId"], // type: "object", // properties: { // customerId: { // type: "string", // description: "customerId", // }, // }, // }, security: [ { basicAuth: [], }, ], }, handler:supplierOrderController.getAllOrderreject, }); fastify.route({ method: "GET", url: "/api/rejected/:customerId", schema: { tags: ["Supplier-Order"], description:"This is for Get particular customer order cancelled", summary: "This is for Get particular customer order cancelled", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, security: [ { basicAuth: [], }, ], }, handler:supplierOrderController.getCustomerOrderreject, }); fastify.route({ method: "GET", url: "/api/delivered/:customerId", schema: { tags: ["Supplier-Order"], description:"This is for Get All order Delivered", summary: "This is for Get All order Delivered", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, security: [ { basicAuth: [], }, ], }, handler:supplierOrderController.getAllOrderdelivered, }); fastify.route({ method: "GET", url: "/api/pendingconformation/:customerId", schema: { tags: ["Supplier-Order"], description:"This is for Get All order Pending for confirmation", summary: "This is for Get All order pending for confirmation", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, security: [ { basicAuth: [], }, ], }, handler:supplierOrderController.getAllOrderpending, }); // fastify.route({ // method: "GET", // url: "/api/billing/:bookingId", // schema: { // tags: ["Supplier-Order"], // description:"This is for Get Billing Information", // summary: "This is for Get Billing Information", // params: { // required: ["bookingId"], // type: "object", // properties: { // bookingId: { // type: "string", // description: "bookingId", // }, // }, // }, // security: [ // { // basicAuth: [], // }, // ], // }, // handler:supplierOrderController.getBillingInfo, // }); fastify.route({ method: "GET", url: "/api/billinginfo/:bookingId", schema: { tags: ["Supplier-Order"], description:"This is for giving booking data billing information", summary: "This is for giving booking data billing information", params: { required: ["bookingId"], type: "object", properties: { bookingId: { type: "string", description: "bookingId", }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler:supplierOrderController.getBillingInfo, // onResponse: (request, reply) => { // validationHandler.sendPhoneVerificationCode(request, reply); // }, //onResponse: validationHandler.sendPhoneVerificationCode, }); fastify.route({ method: "GET", url: "/api/userAccountsofparticularSupplier/:customerId", schema: { tags: ["Supplier-Order"], description: "This is for Get accounts of user for particular supplier", summary: "This is for to Get accounts of user for particular supplier", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, body: { type: "object", //required: ["customerId"], properties: { supplierId : { type : "string"} }, }, security: [ { basicAuth: [], }, ], }, handler:supplierOrderController.userAccountsofparticularSupplier, }); fastify.route({ method: "GET", url: "/api/getAlldistrubanceamountsdetails/:customerId", schema: { tags: ["Supplier-Order"], description:"This is to get all distrubance amount accounts", summary: "This is to get all distrubance amount accounts", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, security: [ { basicAuth: [], }, ], }, handler:supplierOrderController.getAlldistrubanceamountsdetails, }); fastify.route({ method: "GET", url: "/api/medicine/:medicine", schema: { tags: ["Supplier-Order"], description:"This is to get all medicine details", summary: "This is to get all medicine details", params: { required: ["medicine"], type: "object", properties: { medicine: { type: "string", description: "medicine", }, }, }, security: [ { basicAuth: [], }, ], }, handler:supplierOrderController.medicine, }); next(); }