Class: Cb::UserApi

Inherits:
Object
  • Object
show all
Defined in:
lib/cb/clients/user_api.rb

Class Method Summary collapse

Class Method Details

.build_change_password_request(external_id, old_password, new_password, test_mode) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/cb/clients/user_api.rb', line 47

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_ old_password
NewPassword_ new_password
Test_ test_mode.to_s
DeveloperKey_ Cb.configuration.dev_key
			}
		end
		
		builder.to_xml
end

.build_delete_request(external_id, password, test_mode) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cb/clients/user_api.rb', line 61

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

.change_password(external_id, old_password, new_password, test_mode = false) ⇒ Object

Change a user's password

For detailed information around this API please visit: http://www.careerbuilder.com/api/UserInfo.aspx



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cb/clients/user_api.rb', line 12

def self.change_password external_id, old_password, new_password, test_mode = false
	result = false

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

    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

    result
end

.delete(external_id, password, test_mode = false) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cb/clients/user_api.rb', line 29

def self.delete external_id, password, test_mode = false
  result = false

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

  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

  result
end