// billdeskpg/controllers/billdeskFlightWebController.js

const service = require("../services/billdeskFlightWebService");

exports.createOrder = async (req, res) => {
  try {
    console.log("Flight WebSDK createOrder req received");
    console.log("req.body:", req.body);

    const data = await service.createOrder(req.body);

    return res.status(200).json({
      success: true,
      message: "Flight Web order created",
      data,
    });
  } catch (err) {
    console.error("Flight WebSDK Controller error:", err && err.stack || err);
    return res.status(err.statusCode || 500).json({
      success: false,
      message: err.message || "Internal server error",
      detail:  err.detail || null,
    });
  }
};