guard_admin(); if ( $check ) { return $check; } try { $query = $this->clamp_pagination( $per_page, $paged ); if ( null !== $meeting_id && $meeting_id > 0 ) { $query['meeting_id'] = $meeting_id; } if ( null !== $start_date && '' !== trim( $start_date ) ) { $query['start_date'] = sanitize_text_field( $start_date ); } $request = $this->build_request( 'GET', '/timetics/v1/bookings', $query ); if ( is_array( $request ) ) { return $request; } $controller = \Timetics\Core\Bookings\Api_Booking::instance(); $data = $this->extract_response( $controller->get_items( $request ), 'Failed to list bookings.' ); if ( isset( $data['error'] ) ) { return $data; } $items = $this->list_items( $data ); return [ 'total' => $data['total'] ?? count( $items ), 'per_page' => $query['per_page'], 'paged' => $query['paged'], 'bookings' => $this->shape_rows( $items, fn( $item ) => $this->shape_booking( $item ) ), ]; } catch ( \Throwable $e ) { Log::error( 'Timetics_List_Bookings_Tool error', [ 'error' => $e->getMessage() ] ); return [ 'error' => 'Failed to list bookings: ' . $e->getMessage() ]; } } }