<commit_before>require 'faraday'
require 'certified'
require 'active_support/xml_mini'
require 'active_support/core_ext/hash/conversions'
require 'active_support/core_ext/string/inflections'


module BandwidthIris

  class Client
    def initialize (account_id = nil, user_name = nil, password = <PASSWORD>, options = nil)
      if user_name == nil && password == nil && options == nil
        if account_id && account_id.is_a?(Hash)
          options = account_id
          account_id = nil
        end
      end
      options = options || @@global_options
      account_id = options[:account_id] unless account_id
      user_name = options[:user_name] || options[:username]  unless user_name
      password = options[:password] unless password
      options[:api_endpoint] = @@global_options[:api_endpoint] unless options[:api_endpoint]
      options[:api_version] = @@global_options[:api_version] unless options[:api_version]
      api_endpoint = options[:api_endpoint] || "https://api.inetwork.com"
      api_version = options[:api_version] || "v1.0"

      @build_path = lambda {|path| "/#{api_version}" + (if path[0] == "/" then path else "/#{path}" end) }
      @set_adapter = lambda {|faraday| faraday.adapter(Faraday.default_adapter)}
      @create_connection = lambda{||
        Faraday.new(api_endpoint) { |faraday|
          faraday.basic_auth(user_name, password)
          faraday.headers['Accept'] = 'text/xml'
          @set_adapter.call(faraday)
        }
      }
      @concat_account_path = lambda {|path| "/accounts/#{account_id}" + (if path then (if path[0] == "/" then path else "/#{path}" end) else '' end) }
      @api_endpoint = api_endpoint
      @api_version = api_version
    end

    attr_reader :api_endpoint, :api_version

    @@global_options = {}

    # Return global options
    def Client.global_options
      @@global_options
    end

    # Set global options
    def Client.global_options=(v)
      @@global_options = v
    end

    # Extract id from location header
    # @param location [String] location header value
    # @return [String] extracted id
    def Client.get_id_from_location_header(location)
      items = (location || '').split('/')
      raise StandardError.new('Missing id in the location header') if items.size < 2
      items.last<commit_msg>Fixed issue with mime type<commit_after>require 'faraday'
require 'certified'
require 'active_support/xml_mini'
require 'active_support/core_ext/hash/conversions'
require 'active_support/core_ext/string/inflections'


module BandwidthIris

  class Client
    def initialize (account_id = nil, user_name = nil, password = <PASSWORD>, options = nil)
      if user_name == nil && password == <PASSWORD> && options == nil
        if account_id && account_id.is_a?(Hash)
          options = account_id
          account_id = nil
        end
      end
      options = options || @@global_options
      account_id = options[:account_id] unless account_id
      user_name = options[:user_name] || options[:username]  unless user_name
      password = options[:password] unless password
      options[:api_endpoint] = @@global_options[:api_endpoint] unless options[:api_endpoint]
      options[:api_version] = @@global_options[:api_version] unless options[:api_version]
      api_endpoint = options[:api_endpoint] || "https://api.inetwork.com"
      api_version = options[:api_version] || "v1.0"

      @build_path = lambda {|path| "/#{api_version}" + (if path[0] == "/" then path else "/#{path}" end) }
      @set_adapter = lambda {|faraday| faraday.adapter(Faraday.default_adapter)}
      @create_connection = lambda{||
        Faraday.new(api_endpoint) { |faraday|
          faraday.basic_auth(user_name, password)
          faraday.headers['Accept'] = 'application/xml'
          @set_adapter.call(faraday)
        }
      }
      @concat_account_path = lambda {|path| "/accounts/#{account_id}" + (if path then (if path[0] == "/" then path else "/#{path}" end) else '' end) }
      @api_endpoint = api_endpoint
      @api_version = api_version
    end

    attr_reader :api_endpoint, :api_version

    @@global_options = {}

    # Return global options
    def Client.global_options
      @@global_options
    end

    # Set global options
    def Client.global_options=(v)
      @@global_options = v
    end

    # Extract id from location header
    # @param location [String] location header value
    # @return [String] extracted id
    def Client.get_id_from_location_header(location)
      items = (location || '').split('/')
      raise StandardError.new('Missing id in the location header') if items.size < 2
      items.last
{'fraction_non_alphanumeric': 0.11924821775761503, 'fraction_numerical': 0.002160293799956794, 'mean_word_length': 3.3069767441860467, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '3368895', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1360, 'n_words': 333}