<commit_before>module Cohber
  class Client
    # Defines methods related to getting a quote
    module Quotes

      def quote(*args)
        # response = Faraday.post do |req|
        #   req.url 'http://orders.cohber.com/snapstagram/default.aspx'
        #   req.headers['Content-Type'] = 'application/xml'
        #   req.headers['Accept'] = 'application/xml'
        #   req.body = args
        #   put "REQUEST:: #{req.inspect}"
        # end
        conn = Faraday.new('http://orders.cohber.com/snapstagram', ssl: {verify: false}) do |builder|
          builder.use FaradayMiddleware::ParseXml
          builder.request  :url_encoded
          builder.response :logger
          builder.adapter  :net_http
        end
        conn.headers["Accept"] = 'application/xml'
        conn.headers["Content-Type"] = 'application/xml'
        response = conn.post '/default.aspx', args

        puts "RESPONSE: #{response.inspect}"
        # response = post("default.aspx", args, true, true)
        parsed = MultiXml.parse(response.body)
        root = parsed["root"]
        reply = root["quoteReply"] unless root.nil?
        reply
      end

    end
  end
end<commit_msg>More trial and error, mostly error. #6<commit_after>module Cohber
  class Client
    # Defines methods related to getting a quote
    module Quotes

      def quote(*args)
        # response = Faraday.post do |req|
        #   req.url 'http://orders.cohber.com/snapstagram/default.aspx'
        #   req.headers['Content-Type'] = 'application/xml'
        #   req.headers['Accept'] = 'application/xml'
        #   req.body = args
        #   put "REQUEST:: #{req.inspect}"
        # end
        conn = Faraday.new('http://orders.cohber.com/snapstagram', ssl: {verify: false}) do |c|
          c.response :xml,  :content_type => /\bxml$/
          c.response :logger          
          c.request  :url_encoded
          c.request  :xml
          c.adapter  :net_http
          c.use :instrumentation
          c.adapter Faraday.default_adapter
        end
        conn.headers["Accept"] = 'application/xml'
        conn.headers["Content-Type"] = 'application/xml'

        response = conn.post '/default.aspx', args

        puts "RESPONSE: #{response.inspect}"
        # response = post("default.aspx", args, true, true)
        parsed = MultiXml.parse(response.body)
        root = parsed["root"]
        reply = root["quoteReply"] unless root.nil?
        reply
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.12494929006085193, 'fraction_numerical': 0.00040567951318458417, 'mean_word_length': 2.1175726927939316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 11}, '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': '1654288', 'n_tokens_mistral': 745, 'n_tokens_neox': 722, 'n_words': 165}