Class: Cb::UserApi
- Inherits:
-
Object
- Object
- Cb::UserApi
- Defined in:
- lib/cb/clients/user_api.rb
Class Method Summary collapse
- .build_change_password_request(external_id, old_password, new_password, test_mode) ⇒ Object
- .build_delete_request(external_id, password, test_mode) ⇒ Object
- .build_retrieve_request(external_id, test_mode) ⇒ Object
-
.change_password(external_id, old_password, new_password, test_mode = false) ⇒ Object
Change a user's password.
-
.delete(external_id, password, test_mode = false) ⇒ Object
De-activate a user.
-
.retrieve(external_id, test_mode = false) ⇒ Object
Retrieve a user.
Class Method Details
.build_change_password_request(external_id, old_password, new_password, test_mode) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/cb/clients/user_api.rb', line 85 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
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/cb/clients/user_api.rb', line 99 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
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cb/clients/user_api.rb', line 73 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
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cb/clients/user_api.rb', line 32 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
De-activate a user
For detailed information around this API please visit: http://www.careerbuilder.com/api/UserInfo.aspx
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cb/clients/user_api.rb', line 55 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 |
.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 |
# File 'lib/cb/clients/user_api.rb', line 12 def self.retrieve external_id, test_mode = false my_api = Cb::Utils::Api.new cb_response = my_api.cb_post Cb.configuration.uri_user_retrieve, :body => build_retrieve_request(external_id, test_mode) json_hash = JSON.parse cb_response.response.body user = CbUser.new json_hash['ResponseUserInfo']['UserInfo'] my_api.append_api_responses user, json_hash['ResponseUserInfo'] return user end |