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



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/cb/clients/user_api.rb', line 90

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



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/cb/clients/user_api.rb', line 104

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

.build_retrieve_request(external_id, test_mode) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/cb/clients/user_api.rb', line 78

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

.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



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cb/clients/user_api.rb', line 35

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'
    if json_hash['ResponseUserChangePW'].has_key?('Status') && json_hash['ResponseUserChangePW']['Status'].include?('Success')
      result = true
    end
    my_api.append_api_responses result, json_hash['ResponseUserChangePW']
  end

  my_api.append_api_responses result, json_hash

  result
end

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

De-activate a user

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



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

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'
    if json_hash['ResponseUserDelete'].has_key?('Status') && json_hash['ResponseUserDelete']['Status'].include?('Success')
      result = true
    end
    my_api.append_api_responses result, json_hash['ResponseUserDelete']
  end

  my_api.append_api_responses result, json_hash

  result
end

.retrieve(external_id, test_mode = false) ⇒ Object

Retrieve a user

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.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, 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

  my_api.append_api_responses user, json_hash

  return user
end