<commit_before>class Api::V2::PremiumCalculatorController < ApplicationController



  def calculate


    enrollment_xml = request.body.read

    policy_parser = Parsers::Xml::Cv::PolicyParser.parse(enrollment_xml)

    @policy = PolicyBuilder.new(policy_parser.first.to_hash).policy

    @old_policy = @policy.clone

    premium_calculator = Premiums::PolicyCalculator.new

    premium_calculator.apply_calculations(@policy)

    logger.info "#{@old_policy.inspect}"
    logger.info "#{@policy.inspect}"
    render xml: @policy, layout: false
  end

end<commit_msg>1) escaping authentication 2) setting values back to CV 3) returning CV<commit_after>require File.join(Rails.root, "app", "models", "premiums", "enrollment_cv_proxy.rb")

class Api::V2::PremiumCalculatorController < ApplicationController
  skip_before_filter :authenticate_user_from_token!
  skip_before_filter :authenticate_me!
  protect_from_forgery :except => [:create]


  def calculate


    enrollment_xml = request.body.read

    enrollment_cv_proxy = EnrollmentCvProxy.new(enrollment_xml)

    policy = enrollment_cv_proxy.policy

    premium_calculator = Premiums::PolicyCalculator.new

    premium_calculator.apply_calculations(policy)

    enrollment_cv_proxy.policy_emp_res_amt = policy.tot_emp_res_amt
    enrollment_cv_proxy.policy_tot_res_amt = policy.tot_res_amt
    enrollment_cv_proxy.policy_pre_amt_tot = policy.pre_amt_tot

    policy.enrollees.each do |enrollee|
      enrollment_cv_proxy.enrollee_pre_amt=(enrollee)
    end

    render :text => enrollment_cv_proxy.to_xml
  end

end
{'fraction_non_alphanumeric': 0.08656906429026098, 'fraction_numerical': 0.003182686187141948, 'mean_word_length': 5.188976377952756, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '3746006', 'n_tokens_mistral': 540, 'n_tokens_neox': 521, 'n_words': 80}