guard_staff(); if ( $check ) { return $check; } // Confirms the appointment exists and (for team members) that it is theirs. $access = $this->assert_appointment_access( $appointment_id ); if ( $access ) { return $access; } try { $request = new \WP_REST_Request( 'GET', '/booktics/v1/appointments/' . $appointment_id ); $request->set_url_params( [ 'id' => $appointment_id ] ); $controller = new \Booktics\Appointment\Controllers\Appointment_Controller(); $appointment = $this->extract_response( $controller->get_item( $request ), 'Failed to retrieve appointment.' ); if ( isset( $appointment['error'] ) ) { return $appointment; } return $this->shape_appointment( $appointment, true ); } catch ( \Throwable $e ) { Log::error( 'Booktics_Get_Appointment_Tool error', [ 'error' => $e->getMessage() ] ); return [ 'error' => 'Failed to retrieve appointment: ' . $e->getMessage() ]; } } }