require ("dotenv").config();
const callHotelAPI = require("../services/callHotelAPI");

exports.getPageDetails = async (req, res) => {
  
try {
    const { pageNo, paginationCode} = req.body;
    // const payload = {
    //   "pageNo" : pageNo,
    //   "paginationCode" : paginationCode
    // }
    
    
      const response = await callHotelAPI.callPaginationService(pageNo, paginationCode);
      console.log("returning response");
      res.status(200).json(response);
    }
 catch (error) {
    if (error.code === 'ECONNABORTED') {
      console.error("Request timed out");
      return res.status(504).json({ error: "Travelport request timed out" });
    }
    console.error("Error:", error.response?.data || error.message);
    res.status(500).json({ error: error.response?.data || error.message });    
}
}
    
// {
//   "pageNo" : "3",
//   "paginationCode" : "348d419d-df6f-4f1f-97e8-6a20bc2f1453"
// }