<commit_before>require "httparty"
require "zendesk"
require "zendesk/api_error"
require "zendesk/users"

module Zendesk
  class ApiClient
    include HTTParty
    format :json

    attr_reader :username
    attr_accessor :users, :next_page, :previous_page, :count

    def initialize(options = {})
      @username   = options[:username] || Zendesk.config[:username]
      @token      = options[:token]    || Zendesk.config[:token]
      password    = options[:password] || Zendesk.config[:password]
      auth_token  = password || @token
      @username  += "/token" if auth_token == @token

      self.class.base_uri(zendesk_url(options) + '/api/v2')
      # This makes it so that every request uses basic auth
      self.class.basic_auth(@username, auth_token)
      # Sets the headers for every response
      self.class.headers({'Content-Type' => 'application/json', 'Accept' => 'application/json'})

      fail "Missing required options: :username"           unless @username
      fail "Missing required options: :password or :token" unless password || @token
    end

    def users
      @users ||= get_users
    end

    private<commit_msg>wrapped fail statments in parens and ensured that we fail if username is not set<commit_after>require "httparty"
require "zendesk"
require "zendesk/api_error"
require "zendesk/users"

module Zendesk
  class ApiClient
    include HTTParty
    format :json

    attr_reader :username
    attr_accessor :users, :next_page, :previous_page, :count

    def initialize(options = {})
      @username   = options[:username] || Zendesk.config[:username] || fail("Missing required options: :username")
      @token      = options[:token]    || Zendesk.config[:token]
      password    = options[:password] || Zendesk.config[:password]
      auth_token  = password || @token
      @username  += "/token" if auth_token == @token

      self.class.base_uri(zendesk_url(options) + '/api/v2')
      # This makes it so that every request uses basic auth
      self.class.basic_auth(@username, auth_token)
      # Sets the headers for every response
      self.class.headers({'Content-Type' => 'application/json', 'Accept' => 'application/json'})

      fail("Missing required options: :username")           unless @username
      fail("Missing required options: :password or :token") unless password || @token
    end

    def users
      @users ||= get_users
    end

    private
{'fraction_non_alphanumeric': 0.11276948590381426, 'fraction_numerical': 0.0008291873963515755, 'mean_word_length': 3.278368794326241, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '325659', 'n_tokens_mistral': 701, 'n_tokens_neox': 683, 'n_words': 195}