guard( 'manage_pointics', 'manage_options' ); if ( null !== $guard ) { return $guard; } $ready = $this->pointics_tables_ready(); if ( null !== $ready ) { return $this->steer( $ready ); } try { $controller = pointics_container()->make( \Pointics\Api\Controllers\Rewards_Controller::class ); $data = $this->extract_response( $controller->get_stats(), __( 'Failed to retrieve Pointics reward statistics.', 'aisentic' ), 'pointics-get-reward-stats' ); if ( $this->is_error( $data ) ) { return $data; } return [ 'total_redemptions' => (int) ( $data['total_redemptions'] ?? 0 ), 'points_redeemed' => (int) ( $data['points_redeemed'] ?? 0 ), 'redemption_rate' => (float) ( $data['redemption_rate'] ?? 0 ), ]; } catch ( \Throwable $e ) { Log::error( 'Pointics_Get_Reward_Stats_Tool error', [ 'error' => $e->getMessage() ] ); return $this->steer( [ 'error' => __( 'Failed to retrieve Pointics reward statistics.', 'aisentic' ), 'code' => 'internal', 'status' => null, ] ); } } }