registerPlatformRoutes(); $this->registerBotRoutes(); } /** * Routes for the platform integration API (TheFork, OpenTable, Zapier). * Same routes as before — kept unchanged. */ protected function registerPlatformRoutes() { $controller = new BookingApiController(); // POST /wp-json/alexr/v1/bookings register_rest_route(self::API_NAMESPACE, '/bookings', [ [ 'methods' => 'POST', 'callback' => [$controller, 'createBooking'], 'permission_callback' => '__return_true', ], ]); // GET /wp-json/alexr/v1/bookings/(?P[a-zA-Z0-9_-]+)/status register_rest_route(self::API_NAMESPACE, '/bookings/(?P[a-zA-Z0-9_-]+)/status', [ [ 'methods' => 'GET', 'callback' => [$controller, 'getBookingStatus'], 'permission_callback' => '__return_true', ], ]); // POST /wp-json/alexr/v1/bookings/(?P[a-zA-Z0-9_-]+)/cancel register_rest_route(self::API_NAMESPACE, '/bookings/(?P[a-zA-Z0-9_-]+)/cancel', [ [ 'methods' => 'POST', 'callback' => [$controller, 'cancelBooking'], 'permission_callback' => '__return_true', ], ]); } /** * Routes for the conversational bot API (Instagram, WhatsApp, Telegram...). * Uses a separate namespace and separate API key/log tables. */ protected function registerBotRoutes() { $ns = self::BOT_API_NAMESPACE; $restaurant = new BotRestaurantController(); $availability = new BotAvailabilityController(); $bookings = new BotBookingController(); $tables = new BotTableController(); // GET /restaurant - bot context register_rest_route($ns, '/restaurant', [ [ 'methods' => 'GET', 'callback' => [$restaurant, 'getContext'], 'permission_callback' => '__return_true', ], ]); // GET /tables - list all tables (id, name, area, capacity) register_rest_route($ns, '/tables', [ [ 'methods' => 'GET', 'callback' => [$tables, 'list'], 'permission_callback' => '__return_true', ], ]); // GET /availability register_rest_route($ns, '/availability', [ [ 'methods' => 'GET', 'callback' => [$availability, 'getAvailability'], 'permission_callback' => '__return_true', ], ]); // GET /availability/month register_rest_route($ns, '/availability/month', [ [ 'methods' => 'GET', 'callback' => [$availability, 'getMonthAvailability'], 'permission_callback' => '__return_true', ], ]); // POST /bookings - create with real availability check register_rest_route($ns, '/bookings', [ [ 'methods' => 'POST', 'callback' => [$bookings, 'create'], 'permission_callback' => '__return_true', ], [ 'methods' => 'GET', 'callback' => [$bookings, 'search'], 'permission_callback' => '__return_true', ], ]); // GET /bookings/{uuid} register_rest_route($ns, '/bookings/(?P[a-zA-Z0-9_-]+)', [ [ 'methods' => 'GET', 'callback' => [$bookings, 'read'], 'permission_callback' => '__return_true', ], [ 'methods' => ['PATCH', 'PUT'], 'callback' => [$bookings, 'update'], 'permission_callback' => '__return_true', ], ]); // POST /bookings/{uuid}/cancel register_rest_route($ns, '/bookings/(?P[a-zA-Z0-9_-]+)/cancel', [ [ 'methods' => 'POST', 'callback' => [$bookings, 'cancel'], 'permission_callback' => '__return_true', ], ]); // PATCH/PUT /bookings/{uuid}/status - operational status change (POS: seated/finished/no-show) register_rest_route($ns, '/bookings/(?P[a-zA-Z0-9_-]+)/status', [ [ 'methods' => ['PATCH', 'PUT'], 'callback' => [$bookings, 'updateStatus'], 'permission_callback' => '__return_true', ], ]); } }