<commit_before>module Moip2
  class Client
    include HTTParty

    attr_reader :env, :auth, :uri

    def initialize(env = :sandbox, auth = nil, opts = {})
      @env = env.to_sym
      @auth = auth
      @opts = opts

      @uri = get_base_uri
      self.class.base_uri @uri
    end

    def sandbox?
      env == :sandbox
    end

    def production?
      env == :production
    end

    def opts
      opts = @opts
      opts[:headers] ||= {}

      opts[:headers].merge!(
        "Content-Type" => "application/json",
        "Authorization" => auth.header,
      )

      opts
    end

    def post(path, resource)
      options = opts.merge(body: convert_hash_keys_to(:camel_case, resource).to_json)
      resp = self.class.post path, options
      create_response resp
    end

    def put(path, resource)
      options = opts.merge(body: convert_hash_keys_to(:camel_case, resource).to_json)
      resp = self.class.put path, options

      create_response resp
    end

    def get(path)
      resp = self.class.get path, opts

      create_response resp
    end

    private

    def get_base_uri
      return ENV["base_uri"] if ENV["base_uri"]
<commit_msg>chore(client): added User-Agent to match Moip's new standard<commit_after>module Moip2
  class Client
    include HTTParty

    attr_reader :env, :auth, :uri

    def initialize(env = :sandbox, auth = nil, opts = {})
      @env = env.to_sym
      @auth = auth
      @opts = opts

      @uri = get_base_uri
      self.class.base_uri @uri
    end

    def sandbox?
      env == :sandbox
    end

    def production?
      env == :production
    end

    def opts
      opts = @opts
      opts[:headers] ||= {}

      opts[:headers].merge!(
        "Content-Type" => "application/json",
        "Authorization" => auth.header,
        "User-Agent" => "MoipRubySDK/#{Moip2::VERSION} (+https://github.com/moip/moip-sdk-ruby)",
      )

      opts
    end

    def post(path, resource)
      options = opts.merge(body: convert_hash_keys_to(:camel_case, resource).to_json)
      resp = self.class.post path, options
      create_response resp
    end

    def put(path, resource)
      options = opts.merge(body: convert_hash_keys_to(:camel_case, resource).to_json)
      resp = self.class.put path, options

      create_response resp
    end

    def get(path)
      resp = self.class.get path, opts

      create_response resp
    end

    private

    def get_base_uri
      return ENV["base_uri"] if ENV["base_uri"]

{'fraction_non_alphanumeric': 0.10712847362062022, 'fraction_numerical': 0.0012082158679017317, 'mean_word_length': 2.2944297082228116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2928302', 'n_tokens_mistral': 821, 'n_tokens_neox': 785, 'n_words': 196}