จองรถประจำทาง
Optionalcookies: string | string[]ดึงข้อมูลรถที่มีให้จองในเดือนที่ระบุ
Optionalmonth: stringOptionalcookies: string | string[]const availableBuses = await busApi.getAvailableBuses('2025-11');
console.log(availableBuses);
// Output:
// {
// currentMonth: "2025-11",
// totalAvailable: 30,
// availableSchedules: [
// {
// id: 1450,
// title: "( ไปแม่ริม )",
// destination: "แม่ริม",
// destinationType: 1,
// departureDate: "2025-11-15",
// departureTime: "08:00",
// canReserve: true,
// isReserved: false
// }
// ]
// }
ดึงข้อมูลตารางการจองรถประจำทาง
Optionalcookies: string | string[]const schedule = await busApi.getSchedule();
console.log(schedule);
// Output:
// {
// userInfo: { name: "นายจอห์น โด" },
// totalReservations: 5,
// currentPage: 1,
// totalPages: 1,
// hasNextPage: false,
// hasPrevPage: false,
// reservations: [
// {
// id: "12345",
// route: "CMRU-Central",
// date: "2025-11-15",
// time: "08:00",
// status: "confirmed"
// }
// ]
// }
ดึงข้อมูลตั้วขึ้นรถประจำทาง
Optionalcookies: string | string[]const schedule = await busApi.getSchedule();
const ticketUrl = schedule.reservations[0].actions.ticketUrl;
const ticketInfo = await busApi.getTicketInfo(ticketUrl);
console.log(ticketInfo);
// Output:
// {
// destination: { name: "แม่ริม", type: "แม่ริม" },
// schedule: {
// day: "วันจันทร์",
// date: "15 พฤศจิกายน 2568",
// time: "08:00",
// fullSchedule: "วันจันทร์, 15 พฤศจิกายน 2568 เวลา 08:00"
// },
// qrCode: { imageUrl: "/qrcode/generate?data=..." },
// student: { studentId: "66143000", name: "นายจอห์น โด" }
// }
ดาวน์โหลดรูป QR Code ของตั้วรถประจำทาง
Optionalcookies: string | string[]const schedule = await busApi.getSchedule();
const ticketUrl = schedule.reservations[0].actions.ticketUrl;
const qrImage = await busApi.getTicketQRCodeImage(ticketUrl);
const buffer = qrImage.data;
// บันทึกเป็นไฟล์
import fs from 'fs';
fs.writeFileSync('qr-code.png', buffer);
// Output: ไฟล์ qr-code.png ถูกสร้างขึ้น
เข้าสู่ระบบรถประจำทาง CMRU
เข้าสู่ระบบรถประจำทาง CMRU ด้วยประเภทผู้ใช้ที่ระบุ
คลาสสำหรับเรียกใช้ API ของระบบรถประจำทาง CMRU ใช้สำหรับจองรถ ดูตารางเดินทาง และตรวจสอบการจอง
Example