<commit_before>module SoapyCake
  class Request
    attr_accessor :api_key, :time_offset
    attr_reader :role, :service, :method, :opts

    def initialize(role, service, method, opts = {})
      @role = role.to_s
      @service = service.to_s
      @method = method.to_s
      @opts = opts
    end

    def path
      "#{api_path}/#{service}.asmx"
    end

    def xml
      Nokogiri::XML::Builder.new do |xml|
        xml['env'].Envelope(xml_namespaces) do
          xml.Header
          xml.Body do
            xml['cake'].send(method.camelize.to_sym) do
              xml_params(xml)
            end
          end
        end
      end.to_xml
    end

    def short_response?
      %w(addedit track signup).include?(service)
    end

    private

    def api_path
      "#{(role == 'admin') ? '' : "/#{role.pluralize}"}/api/#{version}"
    end

    def xml_params(xml)
      xml.api_key api_key
      opts.each do |k, v|
        xml.send(k.to_sym, format_param(v))
      end
    end<commit_msg>"Style/Send: Prefer Object#__send__ or Object#public_send to send."<commit_after>module SoapyCake
  class Request
    attr_accessor :api_key, :time_offset
    attr_reader :role, :service, :method, :opts

    def initialize(role, service, method, opts = {})
      @role = role.to_s
      @service = service.to_s
      @method = method.to_s
      @opts = opts
    end

    def path
      "#{api_path}/#{service}.asmx"
    end

    def xml
      Nokogiri::XML::Builder.new do |xml|
        xml['env'].Envelope(xml_namespaces) do
          xml.Header
          xml.Body do
            xml['cake'].public_send(method.camelize.to_sym) do
              xml_params(xml)
            end
          end
        end
      end.to_xml
    end

    def short_response?
      %w(addedit track signup).include?(service)
    end

    private

    def api_path
      "#{(role == 'admin') ? '' : "/#{role.pluralize}"}/api/#{version}"
    end

    def xml_params(xml)
      xml.api_key api_key
      opts.each do |k, v|
        xml.public_send(k.to_sym, format_param(v))
      end
    end
{'fraction_non_alphanumeric': 0.1185866408518877, 'fraction_numerical': 0.0, 'mean_word_length': 2.0263543191800877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 28}, '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': '6312068', 'n_tokens_mistral': 702, 'n_tokens_neox': 701, 'n_words': 151}