<commit_before>require 'json'
require 'nokogiri'

module Cb
  class UserApi
    #############################################################
    ## Retrieve a user
    ##
    ## For detailed information around this API please visit:
    ## http://www.careerbuilder.com/api/UserInfo.aspx
    #############################################################
    def self.retrieve external_id, test_mode = false
      my_api = Cb::Utils::Api.new

      json_hash = my_api.cb_post Cb.configuration.uri_user_retrieve, :body => build_retrieve_request('XRHP5HT66R55L6RVP6R9', true)

      if json_hash.has_key? 'ResponseUserInfo'
        if json_hash['ResponseUserInfo'].has_key? 'UserInfo'
          user = CbUser.new json_hash['ResponseUserInfo']['UserInfo']
        end
        my_api.append_api_responses user, json_hash['ResponseUserInfo']
      end

      return user
    end

    #############################################################
    ## Change a user's password
    ##
    ## For detailed information around this API please visit:
    ## http://www.careerbuilder.com/api/UserInfo.aspx
    #############################################################
    def self.change_password external_id, old_password, new_password, test_mode = false
      result = false

      my_api = Cb::Utils::Api.new
      json_hash = my_api.cb_post Cb.configuration.uri_user_change_password, :body => build_change_password_request(external_id, old_password, new_password, test_mode)

      if json_hash.has_key? 'ResponseUserChangePW'
        my_api.append_api_responses result, json_hash['ResponseUserChangePW']
        if result.cb_response.status.include? 'Success'
          result = true
          my_api.append_api_responses result, json_hash['ResponseUserChangePW']
        end
      end

      result
    end

    #############################################################
    ## De-activate a user
    ##
    ## For detailed information around this API please visit:
    ## http://www.careerbuilder.com/api/UserInfo.aspx
    #############################################################
    def self.delete external_id, password, test_mode = false
      result = false

      my_api = Cb::Utils::Api.new
      json_hash = my_api.cb_post Cb.configuration.uri_user_delete, :body => build_delete_request(external_id, password, test_mode)

      if json_hash.has_key? 'ResponseUserDelete'
        my_api.append_api_responses result, json_hash['ResponseUserDelete']

        if result.cb_response.status.include? 'Success'
          result = true
          my_api.append_api_responses result, json_hash['ResponseUserDelete']
        end
      end

      result
    end

    private
    def self.build_retrieve_request external_id, test_mode
      builder = Nokogiri::XML::Builder.new do
        Request {
          ExternalID_ external_id
          Test_ test_mode.to_s
          DeveloperKey_ Cb.configuration.dev_key
        }
      end

      builder.to_xml
    end

    def self.build_change_password_request external_id, old_password, <PASSWORD>_password, test_mode
      builder = Nokogiri::XML::Builder.new do
        Request {
          ExternalID_ external_id
          OldPassword_ <PASSWORD>password
          NewPassword_ <PASSWORD>
          Test_ test_mode.to_s
          DeveloperKey_ Cb.configuration.dev_key
        }
    end
    
    builder.to_xml
    end

    def self.build_delete_request external_id, password, test_mode
      builder = Nokogiri::XML::Builder.new do
        Request {
          ExternalID_ external_id
          Password_ password
          Test_ test_mode.to_s
          DeveloperKey_ Cb.configuration.dev_key
        }
      end

      builder.to_xml
    end

  end
end<commit_msg>Removing externalID hardcode and testmode from user retrieve<commit_after>require 'json'
require 'nokogiri'

module Cb
  class UserApi
    #############################################################
    ## Retrieve a user
    ##
    ## For detailed information around this API please visit:
    ## http://www.careerbuilder.com/api/UserInfo.aspx
    #############################################################
    def self.retrieve external_id, test_mode = false
      my_api = Cb::Utils::Api.new

      json_hash = my_api.cb_post Cb.configuration.uri_user_retrieve, :body => build_retrieve_request(external_id, test_mode)

      if json_hash.has_key? 'ResponseUserInfo'
        if json_hash['ResponseUserInfo'].has_key? 'UserInfo'
          user = CbUser.new json_hash['ResponseUserInfo']['UserInfo']
        end
        my_api.append_api_responses user, json_hash['ResponseUserInfo']
      end

      return user
    end

    #############################################################
    ## Change a user's password
    ##
    ## For detailed information around this API please visit:
    ## http://www.careerbuilder.com/api/UserInfo.aspx
    #############################################################
    def self.change_password external_id, old_password, new_password, test_mode = false
      result = false

      my_api = Cb::Utils::Api.new
      json_hash = my_api.cb_post Cb.configuration.uri_user_change_password, :body => build_change_password_request(external_id, old_password, new_password, test_mode)

      if json_hash.has_key? 'ResponseUserChangePW'
        my_api.append_api_responses result, json_hash['ResponseUserChangePW']
        if result.cb_response.status.include? 'Success'
          result = true
          my_api.append_api_responses result, json_hash['ResponseUserChangePW']
        end
      end

      result
    end

    #############################################################
    ## De-activate a user
    ##
    ## For detailed information around this API please visit:
    ## http://www.careerbuilder.com/api/UserInfo.aspx
    #############################################################
    def self.delete external_id, password, test_mode = false
      result = false

      my_api = Cb::Utils::Api.new
      json_hash = my_api.cb_post Cb.configuration.uri_user_delete, :body => build_delete_request(external_id, password, test_mode)

      if json_hash.has_key? 'ResponseUserDelete'
        my_api.append_api_responses result, json_hash['ResponseUserDelete']

        if result.cb_response.status.include? 'Success'
          result = true
          my_api.append_api_responses result, json_hash['ResponseUserDelete']
        end
      end

      result
    end

    private
    def self.build_retrieve_request external_id, test_mode
      builder = Nokogiri::XML::Builder.new do
        Request {
          ExternalID_ external_id
          Test_ test_mode.to_s
          DeveloperKey_ Cb.configuration.dev_key
        }
      end

      builder.to_xml
    end

    def self.build_change_password_request external_id, old_password, new_password, test_mode
      builder = Nokogiri::XML::Builder.new do
        Request {
          ExternalID_ external_id
          OldPassword_ <PASSWORD>password
          NewPassword_ <PASSWORD>
          Test_ test_mode.to_s
          DeveloperKey_ Cb.configuration.dev_key
        }
    end
    
    builder.to_xml
    end

    def self.build_delete_request external_id, password, test_mode
      builder = Nokogiri::XML::Builder.new do
        Request {
          ExternalID_ external_id
          Password_ password
          Test_ test_mode.to_s
          DeveloperKey_ Cb.configuration.dev_key
        }
      end

      builder.to_xml
    end

  end
end
{'fraction_non_alphanumeric': 0.16572958500669344, 'fraction_numerical': 0.00107095046854083, 'mean_word_length': 3.051518438177874, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1750618', 'n_tokens_mistral': 2150, 'n_tokens_neox': 2059, 'n_words': 426}