<commit_before>##
# = API Controller
#
# This class manages the resource API for the Test Stub.

class ApiController < ApplicationController

  before_filter   :verify_access_token

  #-------------------------------------------------------------------------------

  ##
  # This method retrieves a collection of the requested resources that match the
  # specified parameters.
  #
  # Params (from URI request):
  #   +model+::               Type of resources requested
  #   +patient_id+::          Patient associated with the requested resources
  #
  # Returns:
  #   List of resources in XML or JSON format.

  def index
    if Patient == current_model
      @objects = current_model.all
    else
      @objects = current_model.where(patient_id: params[:patient_id])
    end

    respond_to do |format|
      format.json { render json: @objects }
      format.xml  { render xml: @objects }
    end
  end

  #-------------------------------------------------------------------------------

  ##
  # This method retrieves the requested resource matching the specified parameters.
  #
  # Params:
  #   +model+::               Type of resource requested
  #   +id+::                  Resource identifier
  #
  # Returns:
  #   List of resources in XML or JSON format.

  def show
    @object = current_model.find(params[:id])

    respond_to do |format|
      format.json { render json: @object }
      format.xml  { render xml: @object }<commit_msg>Added debug statements for authorization request headers.<commit_after>##
# = API Controller
#
# This class manages the resource API for the Test Stub.

class ApiController < ApplicationController

  before_filter   :verify_access_token

  #-------------------------------------------------------------------------------

  ##
  # This method retrieves a collection of the requested resources that match the
  # specified parameters.
  #
  # Params (from URI request):
  #   +model+::               Type of resources requested
  #   +patient_id+::          Patient associated with the requested resources
  #
  # Returns:
  #   List of resources in XML or JSON format.

  def index
    if Patient == current_model
      @objects = current_model.all
    else
      @objects = current_model.where(patient_id: params[:patient_id])
    end

    respond_to do |format|
      format.json { render json: @objects }
      format.xml  { render xml: @objects }
    end
  end

  #-------------------------------------------------------------------------------

  ##
  # This method retrieves the requested resource matching the specified parameters.
  #
  # Params:
  #   +model+::               Type of resource requested
  #   +id+::                  Resource identifier
  #
  # Returns:
  #   List of resources in XML or JSON format.

  def show
    Rails.logger.debug "====== request.headers['Authorization'] = #{request.headers['Authorization']} ======"
    @object = current_model.find(params[:id])

    respond_to do |format|
      format.json { render json: @object }
      format.xml  { render xml: @object }
{'fraction_non_alphanumeric': 0.18345323741007194, 'fraction_numerical': 0.0, 'mean_word_length': 1.8482309124767224, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7638329', 'n_tokens_mistral': 785, 'n_tokens_neox': 760, 'n_words': 259}