cb-api 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cb/clients/user_api.rb +60 -22
- data/lib/cb/config.rb +4 -2
- data/lib/cb/models/cb_user.rb +52 -0
- data/lib/cb/version.rb +1 -1
- metadata +5 -2
data/lib/cb/clients/user_api.rb
CHANGED
@@ -3,29 +3,55 @@ require 'nokogiri'
|
|
3
3
|
|
4
4
|
module Cb
|
5
5
|
class UserApi
|
6
|
-
|
6
|
+
#############################################################
|
7
|
+
## Retrieve a user
|
8
|
+
##
|
9
|
+
## For detailed information around this API please visit:
|
10
|
+
## http://www.careerbuilder.com/api/UserInfo.aspx
|
11
|
+
#############################################################
|
12
|
+
def self.retrieve external_id, test_mode = false
|
13
|
+
my_api = Cb::Utils::Api.new
|
14
|
+
|
15
|
+
cb_response = my_api.cb_post Cb.configuration.uri_user_retrieve, :body => build_retrieve_request(external_id, test_mode)
|
16
|
+
|
17
|
+
json_hash = JSON.parse cb_response.response.body
|
18
|
+
|
19
|
+
user = CbUser.new json_hash['ResponseUserInfo']['UserInfo']
|
20
|
+
|
21
|
+
my_api.append_api_responses user, json_hash['ResponseUserInfo']
|
22
|
+
|
23
|
+
return user
|
24
|
+
end
|
25
|
+
|
26
|
+
#############################################################
|
7
27
|
## Change a user's password
|
8
28
|
##
|
9
29
|
## For detailed information around this API please visit:
|
10
30
|
## http://www.careerbuilder.com/api/UserInfo.aspx
|
11
31
|
#############################################################
|
12
32
|
def self.change_password external_id, old_password, new_password, test_mode = false
|
13
|
-
|
33
|
+
result = false
|
34
|
+
|
35
|
+
my_api = Cb::Utils::Api.new
|
36
|
+
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)
|
37
|
+
json_hash = JSON.parse cb_response.response.body
|
14
38
|
|
15
|
-
|
16
|
-
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)
|
17
|
-
json_hash = JSON.parse cb_response.response.body
|
39
|
+
my_api.append_api_responses result, json_hash['ResponseUserChangePW']
|
18
40
|
|
41
|
+
if result.cb_response.status.include? 'Success'
|
42
|
+
result = true
|
19
43
|
my_api.append_api_responses result, json_hash['ResponseUserChangePW']
|
44
|
+
end
|
20
45
|
|
21
|
-
|
22
|
-
result = true
|
23
|
-
my_api.append_api_responses result, json_hash['ResponseUserChangePW']
|
24
|
-
end
|
25
|
-
|
26
|
-
result
|
46
|
+
result
|
27
47
|
end
|
28
48
|
|
49
|
+
#############################################################
|
50
|
+
## De-activate a user
|
51
|
+
##
|
52
|
+
## For detailed information around this API please visit:
|
53
|
+
## http://www.careerbuilder.com/api/UserInfo.aspx
|
54
|
+
#############################################################
|
29
55
|
def self.delete external_id, password, test_mode = false
|
30
56
|
result = false
|
31
57
|
|
@@ -44,18 +70,30 @@ module Cb
|
|
44
70
|
end
|
45
71
|
|
46
72
|
private
|
73
|
+
def self.build_retrieve_request external_id, test_mode
|
74
|
+
builder = Nokogiri::XML::Builder.new do
|
75
|
+
Request {
|
76
|
+
ExternalID_ external_id
|
77
|
+
Test_ test_mode.to_s
|
78
|
+
DeveloperKey_ Cb.configuration.dev_key
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
builder.to_xml
|
83
|
+
end
|
84
|
+
|
47
85
|
def self.build_change_password_request external_id, old_password, new_password, test_mode
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
86
|
+
builder = Nokogiri::XML::Builder.new do
|
87
|
+
Request {
|
88
|
+
ExternalID_ external_id
|
89
|
+
OldPassword_ old_password
|
90
|
+
NewPassword_ new_password
|
91
|
+
Test_ test_mode.to_s
|
92
|
+
DeveloperKey_ Cb.configuration.dev_key
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
builder.to_xml
|
59
97
|
end
|
60
98
|
|
61
99
|
def self.build_delete_request external_id, password, test_mode
|
data/lib/cb/config.rb
CHANGED
@@ -8,7 +8,7 @@ module Cb
|
|
8
8
|
:uri_recommendation_for_company,
|
9
9
|
:uri_application, :uri_application_submit,
|
10
10
|
:uri_application_registered, :uri_user_change_password,
|
11
|
-
:uri_user_delete
|
11
|
+
:uri_user_delete, :uri_user_retrieve
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
Cb::Utils::Country.inject_convenience_methods
|
@@ -30,6 +30,7 @@ module Cb
|
|
30
30
|
@uri_application_registered ||= '/v3/Application/registered'
|
31
31
|
@uri_user_change_password ||= '/v2/User/ChangePW'
|
32
32
|
@uri_user_delete ||= '/v2/User/delete'
|
33
|
+
@uri_user_retrieve ||= '/v2/user/retrieve'
|
33
34
|
end
|
34
35
|
|
35
36
|
def to_hash
|
@@ -50,7 +51,8 @@ module Cb
|
|
50
51
|
:uri_application => @uri_application,
|
51
52
|
:uri_application_submit => @uri_application_submit,
|
52
53
|
:uri_application_registered => @uri_application_registered,
|
53
|
-
:uri_user_change_password => @uri_user_change_password
|
54
|
+
:uri_user_change_password => @uri_user_change_password,
|
55
|
+
:uri_user_retrieve => @uri_user_retrieve
|
54
56
|
}
|
55
57
|
end
|
56
58
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Cb
|
2
|
+
class CbUser
|
3
|
+
attr_accessor :user_status, :password, :email, :address_1, :address_2, :city, :state,
|
4
|
+
:province, :postal_code, :zip, :country_code, :first_name,
|
5
|
+
:last_name, :phone, :fax, :last_login, :created, :allow_partner_emails,
|
6
|
+
:allow_newsletter_emails, :allow_email_from_headhunter, :domain, :registration_path,
|
7
|
+
:user_type, :gender, :birth_date, :cobrand_code, :resume_stats, :custom_values
|
8
|
+
|
9
|
+
def initialize(args = {})
|
10
|
+
return if args.nil?
|
11
|
+
|
12
|
+
@user_status = args['UserStatus'] || ''
|
13
|
+
@password = ''
|
14
|
+
@email = args['Email'] || ''
|
15
|
+
@address_1 = args['Address1'] || ''
|
16
|
+
@address_2 = args['Address2'] || ''
|
17
|
+
@city = args['City'] || ''
|
18
|
+
@state = args['State'] || ''
|
19
|
+
@province = args['Province'] || ''
|
20
|
+
@postal_code = args['PostalCode'] || ''
|
21
|
+
@zip = args['Zip'] || ''
|
22
|
+
@country_code = args['CountryCode'] || ''
|
23
|
+
@first_name = args['FirstName'] || ''
|
24
|
+
@last_name = args['LastName'] || ''
|
25
|
+
@phone = args['Phone'] || ''
|
26
|
+
@fax = args['Fax'] || ''
|
27
|
+
@last_login = args['LastLogin'] || ''
|
28
|
+
@created = args['CreatedDT'] || ''
|
29
|
+
@allow_partner_emails = args['AllowPartnerEmails'] || ''
|
30
|
+
@allow_newsletter_emails = args['AllowNewsletterEmails'] || ''
|
31
|
+
@allow_email_from_headhunter = args['AllowEmailFromHeadHunter'] || ''
|
32
|
+
@domain = args['Domain'] || ''
|
33
|
+
@registration_path = args['RegistrationPath'] || ''
|
34
|
+
@user_type = args['UserType'] || ''
|
35
|
+
@gender = args['Gender'] || ''
|
36
|
+
@birth_date = args['BirthDate'] || ''
|
37
|
+
@cobrand_code = args['CoBrandCode'] || ''
|
38
|
+
@resume_stats = args['ResumeStats'] || ''
|
39
|
+
@custom_values = args['CustomValues'] || ''
|
40
|
+
end
|
41
|
+
|
42
|
+
def custom_value custom_value_key
|
43
|
+
custom_value_value = nil
|
44
|
+
|
45
|
+
@custom_values['CustomValue'].each do |custom_value|
|
46
|
+
custom_value_value = custom_value['Value'] if custom_value['Key'] == custom_value_key
|
47
|
+
end
|
48
|
+
|
49
|
+
return custom_value_value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/cb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cb-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,10 +10,11 @@ authors:
|
|
10
10
|
- Miriam Williams
|
11
11
|
- David Posey
|
12
12
|
- Kyle Bumpus
|
13
|
+
- Ben Schmaltz
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
|
-
date: 2013-
|
17
|
+
date: 2013-06-04 00:00:00.000000000 Z
|
17
18
|
dependencies:
|
18
19
|
- !ruby/object:Gem::Dependency
|
19
20
|
name: httparty
|
@@ -54,6 +55,7 @@ email:
|
|
54
55
|
- MiriamDeana@gmail.com
|
55
56
|
- David.Posey@Careerbuilder.com
|
56
57
|
- Kyle.Bumpus@Careerbuilder.com
|
58
|
+
- Ben.Schmaltz@Careerbuilder.com
|
57
59
|
executables: []
|
58
60
|
extensions: []
|
59
61
|
extra_rdoc_files: []
|
@@ -76,6 +78,7 @@ files:
|
|
76
78
|
- lib/cb/models/cb_education.rb
|
77
79
|
- lib/cb/models/cb_employee_type.rb
|
78
80
|
- lib/cb/models/cb_job.rb
|
81
|
+
- lib/cb/models/cb_user.rb
|
79
82
|
- lib/cb/utils/api.rb
|
80
83
|
- lib/cb/utils/country.rb
|
81
84
|
- lib/cb/utils/fluid_attributes.rb
|