cb-api 1.3.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/lib/cb.rb +7 -99
  2. data/lib/cb/clients/anon_saved_search.rb +42 -0
  3. data/lib/cb/clients/application.rb +53 -0
  4. data/lib/cb/clients/application_external.rb +24 -0
  5. data/lib/cb/clients/category.rb +49 -0
  6. data/lib/cb/clients/company.rb +34 -0
  7. data/lib/cb/clients/education.rb +28 -0
  8. data/lib/cb/clients/email_subscription.rb +55 -0
  9. data/lib/cb/clients/employee_types.rb +31 -0
  10. data/lib/cb/clients/job.rb +57 -0
  11. data/lib/cb/clients/job_branding.rb +21 -0
  12. data/lib/cb/clients/recommendation.rb +76 -0
  13. data/lib/cb/clients/saved_search.rb +66 -0
  14. data/lib/cb/clients/spot.rb +27 -0
  15. data/lib/cb/clients/talent_network.rb +51 -0
  16. data/lib/cb/clients/user.rb +94 -0
  17. data/lib/cb/convenience.rb +83 -0
  18. data/lib/cb/criteria/job/details.rb +11 -0
  19. data/lib/cb/criteria/job/search.rb +25 -0
  20. data/lib/cb/criteria/spot/retrieve.rb +12 -0
  21. data/lib/cb/exceptions.rb +2 -1
  22. data/lib/cb/models/implementations/application.rb +92 -0
  23. data/lib/cb/models/implementations/application_external.rb +28 -0
  24. data/lib/cb/models/implementations/application_schema.rb +75 -0
  25. data/lib/cb/models/implementations/branding/media.rb +14 -14
  26. data/lib/cb/models/implementations/branding/section.rb +14 -15
  27. data/lib/cb/models/implementations/branding/style.rb +10 -10
  28. data/lib/cb/models/implementations/branding/styles/base.rb +12 -10
  29. data/lib/cb/models/implementations/branding/styles/buttons.rb +7 -6
  30. data/lib/cb/models/implementations/branding/styles/company_info.rb +14 -12
  31. data/lib/cb/models/implementations/branding/styles/container.rb +7 -6
  32. data/lib/cb/models/implementations/branding/styles/content.rb +7 -5
  33. data/lib/cb/models/implementations/branding/styles/css_adapter.rb +39 -41
  34. data/lib/cb/models/implementations/branding/styles/headings.rb +7 -5
  35. data/lib/cb/models/implementations/branding/styles/job_details.rb +12 -11
  36. data/lib/cb/models/implementations/branding/styles/page.rb +7 -5
  37. data/lib/cb/models/implementations/branding/widget.rb +9 -7
  38. data/lib/cb/models/implementations/category.rb +24 -0
  39. data/lib/cb/models/implementations/company.rb +135 -0
  40. data/lib/cb/models/implementations/education.rb +17 -0
  41. data/lib/cb/models/implementations/email_subscription.rb +17 -0
  42. data/lib/cb/models/implementations/employee_type.rb +13 -0
  43. data/lib/cb/models/implementations/job.rb +167 -0
  44. data/lib/cb/models/implementations/job_branding.rb +34 -0
  45. data/lib/cb/models/implementations/saved_search.rb +159 -0
  46. data/lib/cb/models/implementations/spot.rb +30 -0
  47. data/lib/cb/models/implementations/talent_network.rb +156 -0
  48. data/lib/cb/models/implementations/user.rb +58 -0
  49. data/lib/cb/responses/anonymous_saved_search/create.rb +36 -0
  50. data/lib/cb/responses/anonymous_saved_search/delete.rb +23 -0
  51. data/lib/cb/responses/api_response.rb +64 -0
  52. data/lib/cb/responses/employee_types/search.rb +48 -0
  53. data/lib/cb/responses/errors.rb +47 -0
  54. data/lib/cb/responses/metadata.rb +27 -0
  55. data/lib/cb/responses/saved_search/delete.rb +28 -0
  56. data/lib/cb/responses/saved_search/list.rb +43 -0
  57. data/lib/cb/responses/saved_search/singular.rb +50 -0
  58. data/lib/cb/responses/spot/retrieve_response.rb +31 -20
  59. data/lib/cb/responses/timing.rb +37 -0
  60. data/lib/cb/utils/api.rb +2 -2
  61. data/lib/cb/utils/response_array_extractor.rb +14 -4
  62. data/lib/cb/version.rb +1 -1
  63. metadata +114 -69
  64. data/lib/cb/clients/anon_saved_search_api.rb +0 -41
  65. data/lib/cb/clients/application_api.rb +0 -78
  66. data/lib/cb/clients/application_external_api.rb +0 -30
  67. data/lib/cb/clients/category_api.rb +0 -51
  68. data/lib/cb/clients/company_api.rb +0 -39
  69. data/lib/cb/clients/education_api.rb +0 -37
  70. data/lib/cb/clients/email_subscription_api.rb +0 -68
  71. data/lib/cb/clients/employee_types_api.rb +0 -48
  72. data/lib/cb/clients/job_api.rb +0 -70
  73. data/lib/cb/clients/job_branding_api.rb +0 -24
  74. data/lib/cb/clients/recommendation_api.rb +0 -98
  75. data/lib/cb/clients/resume_api.rb +0 -185
  76. data/lib/cb/clients/saved_search_api.rb +0 -139
  77. data/lib/cb/clients/spot_api.rb +0 -25
  78. data/lib/cb/clients/talent_network_api.rb +0 -70
  79. data/lib/cb/clients/user_api.rb +0 -118
  80. data/lib/cb/criteria/job_details_criteria.rb +0 -11
  81. data/lib/cb/criteria/job_search_criteria.rb +0 -29
  82. data/lib/cb/criteria/spot_retrieve_criteria.rb +0 -12
  83. data/lib/cb/models/implementations/cb_application.rb +0 -91
  84. data/lib/cb/models/implementations/cb_application_external.rb +0 -31
  85. data/lib/cb/models/implementations/cb_application_schema.rb +0 -78
  86. data/lib/cb/models/implementations/cb_category.rb +0 -22
  87. data/lib/cb/models/implementations/cb_company.rb +0 -133
  88. data/lib/cb/models/implementations/cb_education.rb +0 -25
  89. data/lib/cb/models/implementations/cb_email_subscription.rb +0 -19
  90. data/lib/cb/models/implementations/cb_employee_type.rb +0 -12
  91. data/lib/cb/models/implementations/cb_job.rb +0 -175
  92. data/lib/cb/models/implementations/cb_job_branding.rb +0 -33
  93. data/lib/cb/models/implementations/cb_resume.rb +0 -221
  94. data/lib/cb/models/implementations/cb_saved_search.rb +0 -228
  95. data/lib/cb/models/implementations/cb_spot.rb +0 -32
  96. data/lib/cb/models/implementations/cb_talent_network.rb +0 -155
  97. data/lib/cb/models/implementations/cb_user.rb +0 -56
  98. data/lib/cb/responses/raw_api_response.rb +0 -34
@@ -1,39 +0,0 @@
1
- require 'json'
2
-
3
- module Cb
4
- class CompanyApi
5
- #############################################################
6
- ## Retrieve a company by did
7
- ##
8
- ## For detailed information around this API please visit:
9
- ## http://api.careerbuilder.com/CompanyDetailsInfo.aspx
10
- #############################################################
11
- def self.find_by_did(did)
12
- my_api = Cb::Utils::Api.new()
13
- json_hash = my_api.cb_get(Cb.configuration.uri_company_find, :query => {:CompanyDID => did, :hostsite=> Cb.configuration.host_site})
14
-
15
- if json_hash.has_key?('Results')
16
- if json_hash['Results'].has_key?('CompanyProfileDetail')
17
- company = CbCompany.new(json_hash['Results']['CompanyProfileDetail'])
18
- end
19
- my_api.append_api_responses(company, json_hash['Results'])
20
- end
21
-
22
- my_api.append_api_responses(company, json_hash)
23
-
24
-
25
- return company
26
- end
27
-
28
- def self.find_for(obj)
29
- if obj.is_a?(String)
30
- did = obj
31
- elsif obj.is_a?(Cb::CbJob)
32
- did = obj.company_did
33
- end
34
- did ||= ''
35
-
36
- find_by_did did unless did.empty?
37
- end
38
- end
39
- end
@@ -1,37 +0,0 @@
1
- require 'json'
2
-
3
- module Cb
4
- class EducationApi
5
- #############################################################
6
- ## Retrieve Education codes by country code
7
- ##
8
- ## For detailed information around this API please visit:
9
- ## http://api.careerbuilder.com/EducationCodes.aspx
10
- #############################################################
11
- def self.get_for(country)
12
- Cb::Utils::Country.is_valid? country ? country : 'US'
13
-
14
- my_api = Cb::Utils::Api.new()
15
-
16
- json_hash = my_api.cb_get(Cb.configuration.uri_education_code, :query => {:countrycode => country})
17
-
18
- codes = []
19
- if json_hash.has_key?('ResponseEducationCodes')
20
-
21
- if json_hash['ResponseEducationCodes'].has_key?('EducationCodes') &&
22
- json_hash['ResponseEducationCodes']['EducationCodes'].has_key?('Education')
23
-
24
- json_hash['ResponseEducationCodes']['EducationCodes']['Education'].each do | education |
25
- codes << Cb::CbEducation.new(education)
26
- end
27
- end
28
-
29
- my_api.append_api_responses(codes, json_hash['ResponseEducationCodes'])
30
- end
31
-
32
- my_api.append_api_responses(codes, json_hash)
33
-
34
- return codes
35
- end
36
- end
37
- end
@@ -1,68 +0,0 @@
1
- require 'json'
2
-
3
- module Cb
4
- class EmailSubscriptionApi
5
- #############################################################
6
- ## Retrieve subscription values for a user
7
- ##
8
- ## For detailed information around this API please visit:
9
- ## http://api.careerbuilder.com/usersubscriptionretrieve.aspx
10
- #############################################################
11
- def self.retrieve_by_did(did, host_site = '')
12
- my_api = Cb::Utils::Api.new()
13
- json_hash = my_api.cb_get(Cb.configuration.uri_subscription_retrieve, :query => {:ExternalID => did, :Hostsite => host_site})
14
-
15
- if json_hash.has_key?('SubscriptionValues') && !json_hash['SubscriptionValues'].nil?
16
- subscription = CbEmailSubscription.new(json_hash['SubscriptionValues'])
17
- my_api.append_api_responses(subscription, json_hash['SubscriptionValues'])
18
- end
19
- my_api.append_api_responses(subscription, json_hash)
20
-
21
- return subscription
22
- end
23
-
24
-
25
- #############################################################
26
- ## Update subscription values for a user
27
- ##
28
- ## For detailed information around this API please visit:
29
- ## http://api.careerbuilder.com/usersubscriptionretrieve.aspx
30
- #############################################################
31
- def self.modify_subscription ext_id, host_site, career_resources, product_sponsor_info, applicant_survey_invites, job_recs, unsubscribe_all
32
- if unsubscribe_all && unsubscribe_all != 'false'
33
- career_resources = product_sponsor_info = applicant_survey_invites = job_recs = false.to_s
34
- end
35
-
36
- career_resources = career_resources.nil? ? 'false' : career_resources
37
- product_sponsor_info = product_sponsor_info.nil? ? 'false' : product_sponsor_info
38
- applicant_survey_invites = applicant_survey_invites.nil? ? 'false' : applicant_survey_invites
39
- job_recs = job_recs.nil? ? 'false' : job_recs
40
- unsubscribe_all = unsubscribe_all.nil? ? 'false' : unsubscribe_all
41
-
42
- my_api = Cb::Utils::Api.new()
43
-
44
- xml_body = "<Request>"
45
- xml_body += "<DeveloperKey>" + Cb.configuration.dev_key.to_s + "</DeveloperKey>"
46
- xml_body += "<ExternalID>" + ext_id.to_s + "</ExternalID>"
47
- xml_body += "<Hostsite>" + host_site.to_s + "</Hostsite>"
48
- xml_body += "<CareerResources>" + career_resources.to_s + "</CareerResources>"
49
- xml_body += "<ProductSponsorInfo>" + product_sponsor_info.to_s + "</ProductSponsorInfo>"
50
- xml_body += "<ApplicantSurveyInvites>" + applicant_survey_invites.to_s + "</ApplicantSurveyInvites>"
51
- xml_body += "<JobRecs>" + job_recs.to_s + "</JobRecs>"
52
- xml_body += "<UnsubscribeAll>" + unsubscribe_all.to_s + "</UnsubscribeAll>"
53
- xml_body += "</Request>"
54
-
55
-
56
- json_hash = my_api.cb_post(Cb.configuration.uri_subscription_modify,
57
- :body => xml_body)
58
-
59
- if json_hash.has_key?('SubscriptionValues') && !json_hash['SubscriptionValues'].nil?
60
- subscription = CbEmailSubscription.new(json_hash['SubscriptionValues'])
61
- my_api.append_api_responses(subscription, json_hash['SubscriptionValues'])
62
- end
63
- my_api.append_api_responses(subscription, json_hash)
64
- return subscription
65
- end
66
-
67
- end
68
- end
@@ -1,48 +0,0 @@
1
- require "json"
2
-
3
- module Cb
4
- class EmployeeTypesApi
5
-
6
- def self.search
7
- my_api = Cb::Utils::Api.new()
8
- json_hash = my_api.cb_get(Cb.configuration.uri_employee_types)
9
-
10
- return array_of_objects_from_hash(json_hash, my_api)
11
- end
12
-
13
- def self.search_by_host_site(hostsite)
14
- my_api = Cb::Utils::Api.new()
15
- json_hash = my_api.cb_get(Cb.configuration.uri_employee_types, :query => {:CountryCode => hostsite})
16
-
17
- return array_of_objects_from_hash(json_hash, my_api)
18
- end
19
-
20
- private
21
- def self.array_of_objects_from_hash(json_hash, my_api)
22
-
23
- employee_types = []
24
- if json_hash.has_key?('ResponseEmployeeTypes')
25
- if json_hash['ResponseEmployeeTypes'].has_key?('EmployeeTypes') &&
26
- !json_hash['ResponseEmployeeTypes']['EmployeeTypes'].nil?
27
-
28
- if json_hash['ResponseEmployeeTypes']['EmployeeTypes']['EmployeeType'].is_a?(Array)
29
-
30
- json_hash['ResponseEmployeeTypes']['EmployeeTypes']['EmployeeType'].each do |et|
31
- employee_types << CbEmployeeType.new(et)
32
- end
33
-
34
- elsif json_hash['ResponseEmployeeTypes']['EmployeeTypes']['EmployeeType'].is_a?(Hash) && json_hash.length < 2
35
- employee_types << CbEmployeeType.new(json_hash['ResponseEmployeeTypes']['EmployeeTypes']['EmployeeType'])
36
- end
37
-
38
- end
39
- my_api.append_api_responses(employee_types, json_hash['ResponseEmployeeTypes'])
40
- end
41
-
42
- my_api.append_api_responses(employee_types, json_hash)
43
-
44
- return employee_types
45
- end
46
-
47
- end
48
- end
@@ -1,70 +0,0 @@
1
- require 'json'
2
-
3
- module Cb
4
- class JobApi
5
-
6
- #############################################################
7
- ## Run a job search against the given criteria
8
- ##
9
- ## For detailed information around this API please visit:
10
- ##
11
- #############################################################
12
- def self.search(*args)
13
- args = args[0] if args.is_a?(Array) && args.count == 1
14
- my_api = Cb::Utils::Api.new()
15
- json_hash = my_api.cb_get(Cb.configuration.uri_job_search, :query => args)
16
-
17
- jobs = Array.new
18
- if !json_hash['ResponseJobSearch'].nil? && !json_hash['ResponseJobSearch']['Results'].nil?
19
- job_results = json_hash['ResponseJobSearch']['Results']['JobSearchResult']
20
- job_results = [job_results] if !job_results.is_a?(Array)
21
- job_results.each { |job_hash| jobs.push(CbJob.new(job_hash)) }
22
- my_api.append_api_responses(jobs, json_hash['ResponseJobSearch'])
23
-
24
- if response_has_search_metadata?(json_hash['ResponseJobSearch'])
25
- my_api.append_api_responses(jobs, json_hash['ResponseJobSearch']['SearchMetaData']['SearchLocations']['SearchLocation'])
26
- end
27
- end
28
-
29
- my_api.append_api_responses(jobs, json_hash)
30
-
31
- return jobs
32
- end
33
-
34
- #############################################################
35
- ## Retrieve a job by did
36
- ##
37
- ## For detailed information around this API please visit:
38
- ## http://api.careerbuilder.com/JobInfo.aspx
39
- #############################################################
40
- def self.find_by_criteria(criteria)
41
- my_api = Cb::Utils::Api.new()
42
- params = my_api.class.criteria_to_hash(criteria)
43
- json_hash = my_api.cb_get(Cb.configuration.uri_job_find, :query => params)
44
-
45
- if json_hash.has_key?('ResponseJob')
46
- if json_hash['ResponseJob'].has_key?('Job')
47
- job = CbJob.new(json_hash['ResponseJob']['Job'])
48
- end
49
- my_api.append_api_responses(job, json_hash['ResponseJob'])
50
- end
51
- my_api.append_api_responses(job, json_hash)
52
-
53
- return job
54
- end
55
-
56
- def self.find_by_did(did)
57
- criteria = Cb::JobDetailsCriteria.new()
58
- criteria.did = did
59
- return find_by_criteria(criteria)
60
- end
61
-
62
- private
63
-
64
- def self.response_has_search_metadata?(response_hash)
65
- response_hash['SearchMetaData'] &&
66
- response_hash['SearchMetaData']['SearchLocations'] &&
67
- response_hash['SearchMetaData']['SearchLocations']['SearchLocation']
68
- end
69
- end # JobApi
70
- end # Cb
@@ -1,24 +0,0 @@
1
- require 'nori'
2
-
3
- module Cb
4
-
5
- class JobBrandingApi
6
-
7
- def self.find_by_id id
8
- my_api = Cb::Utils::Api.new
9
-
10
- json_hash = my_api.cb_get Cb.configuration.uri_job_branding, :query => { :id => id }
11
-
12
- if json_hash.has_key? 'Branding'
13
- branding = CbJobBranding.new json_hash['Branding']
14
- my_api.append_api_responses(branding, json_hash['Branding'])
15
- end
16
-
17
- my_api.append_api_responses(branding, json_hash)
18
-
19
- return branding
20
- end
21
-
22
- end
23
-
24
- end
@@ -1,98 +0,0 @@
1
- require 'json'
2
-
3
- module Cb
4
- class RecommendationApi
5
- #############################################################
6
- ## Get recommendations for a job
7
- ##
8
- ## For detailed information around this API please visit:
9
- ## http://api.careerbuilder.com/Recommendations.aspx
10
- #############################################################
11
- def self.for_job(did, countlimit = '25', site_id = '', co_brand = '')
12
- my_api = Cb::Utils::Api.new()
13
- json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_job,
14
- :query => {:JobDID => did, :CountLimit => countlimit, :SiteID => site_id,
15
- :CoBrand => co_brand, :HostSite => Cb.configuration.host_site})
16
-
17
- jobs = []
18
- if json_hash.has_key?('ResponseRecommendJob')
19
- if json_hash['ResponseRecommendJob'].has_key?('RecommendJobResults') &&
20
- !json_hash['ResponseRecommendJob']['RecommendJobResults'].nil?
21
-
22
- json_hash['ResponseRecommendJob']['RecommendJobResults']['RecommendJobResult'].each do |cur_job|
23
- jobs << CbJob.new(cur_job)
24
- end
25
- my_api.append_api_responses(jobs, json_hash['ResponseRecommendJob']['Request'])
26
- end
27
- my_api.append_api_responses(jobs, json_hash['ResponseRecommendJob'])
28
- end
29
- my_api.append_api_responses(jobs, json_hash)
30
-
31
- return jobs
32
- end
33
-
34
- #############################################################
35
- ## Get recommendations for a user
36
- ##
37
- ## For detailed information around this API please visit:
38
- ## http://api.careerbuilder.com/Recommendations.aspx
39
- #############################################################
40
- def self.for_user(external_id, countlimit = '25', site_id = '', co_brand = '')
41
- my_api = Cb::Utils::Api.new()
42
- json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_user,
43
- :query => {:ExternalID => external_id, :CountLimit => countlimit, :SiteID => site_id, :CoBrand => co_brand,
44
- :HostSite => Cb.configuration.host_site})
45
-
46
- jobs = []
47
- if json_hash.has_key?('ResponseRecommendUser')
48
-
49
- if json_hash['ResponseRecommendUser'].has_key?('RecommendJobResults') &&
50
- !json_hash['ResponseRecommendUser']['RecommendJobResults'].nil?
51
-
52
- json_hash['ResponseRecommendUser']['RecommendJobResults']['RecommendJobResult'].each do |cur_job|
53
- jobs << CbJob.new(cur_job)
54
- end
55
-
56
- my_api.append_api_responses(jobs, json_hash['ResponseRecommendUser']['Request'])
57
- end
58
-
59
- my_api.append_api_responses(jobs, json_hash['ResponseRecommendUser'])
60
- end
61
-
62
- my_api.append_api_responses(jobs, json_hash)
63
-
64
- return jobs
65
- end
66
-
67
- #############################################################
68
- ## Get recommendations for a company
69
- ##
70
- ## For detailed information around this API please visit:
71
- ## http://api.careerbuilder.com/Recommendations.aspx
72
- #############################################################
73
- def self.for_company(company_did)
74
- my_api = Cb::Utils::Api.new()
75
- json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_company,
76
- :query => {:CompanyDID => company_did})
77
-
78
- jobs = []
79
- if json_hash.has_key?('Results')
80
-
81
- if json_hash['Results'].has_key?('JobRecommendation')
82
-
83
- json_hash['Results']['JobRecommendation']['Jobs'].each do |cur_job|
84
- jobs << CbJob.new(cur_job)
85
- end
86
-
87
- my_api.append_api_responses(jobs, json_hash['Results']['JobRecommendation'])
88
- end
89
-
90
- my_api.append_api_responses(jobs, json_hash['Results'])
91
-
92
- end
93
- my_api.append_api_responses(jobs, json_hash)
94
-
95
- return jobs
96
- end
97
- end
98
- end
@@ -1,185 +0,0 @@
1
- require 'json'
2
-
3
- module Cb
4
- class ResumeApi
5
- #############################################################
6
- ## Retrieve resumes a user owns.
7
- ##
8
- ## Returns an array of resumes with external id and
9
- ## title set.
10
- ##
11
- ## Note: This does not load the resume, a subsequent resume
12
- ## retrieve is required.
13
- ##
14
- ## For detailed information around this API please visit:
15
- ## http://www.careerbuilder.com/api/ResumeInfo.aspx
16
- #############################################################
17
- def self.own_all(external_user_id, ignore_host_site = false)
18
- my_api = Cb::Utils::Api.new
19
- params = {"ExternalUserID" => external_user_id}
20
- if ignore_host_site
21
- params['IgnoreHostSite'] = 'true'
22
- end
23
- json_hash = my_api.cb_get(Cb.configuration.uri_resume_own_all, :query => params)
24
-
25
- resumes = []
26
-
27
- if json_hash.has_key?('ResponseOwnResumes') && json_hash['ResponseOwnResumes'].has_key?('Resumes')
28
- json_hash['ResponseOwnResumes']['Resumes']['Resume'].each do |resume_hash|
29
- resume = Cb::CbResume.new resume_hash
30
- resume.external_resume_id = resume_hash['ExternalID']
31
- resume.external_user_id = external_user_id
32
- resumes << resume
33
- end
34
- end
35
-
36
- return resumes
37
- end
38
-
39
- #############################################################
40
- ## Retrieve the contents of a resume by external id.
41
- ##
42
- ## For detailed information around this API please visit:
43
- ## http://www.careerbuilder.com/api/ResumeInfo.aspx
44
- #############################################################
45
- def self.retrieve_by_id resume_external_id, external_user_id
46
- my_api = Cb::Utils::Api.new
47
- params = {"ExternalID" => external_id, "ExternalUserID" => external_user_id}
48
- json_hash = my_api.cb_get(Cb.configuration.uri_resume_retrieve, :query => params)
49
-
50
- if json_hash.has_key?('ResponseRetrieve') && json_hash['ResponseRetrieve'].has_key?('Resume')
51
- resume = Cb::CbResume.new json_hash['ResponseRetrieve']['Resume']
52
- my_api.append_api_responses resume, json_hash['ResponseRetrieve']
53
- end
54
-
55
- return resume
56
- end
57
-
58
- #############################################################
59
- ## Retrieve the contents of a resume.
60
- ##
61
- ## For detailed information around this API please visit:
62
- ## http://www.careerbuilder.com/api/ResumeInfo.aspx
63
- #############################################################
64
- def self.retrieve resume
65
- my_api = Cb::Utils::Api.new
66
- params = {"ExternalID" => resume.external_resume_id, "ExternalUserID" => resume.external_user_id}
67
- json_hash = my_api.cb_get(Cb.configuration.uri_resume_retrieve, :query => params)
68
-
69
- if json_hash.has_key?('ResponseRetrieve') && json_hash['ResponseRetrieve'].has_key?('Resume')
70
- resume = resume.set_attributes json_hash['ResponseRetrieve']['Resume']
71
- my_api.append_api_responses resume, json_hash['ResponseRetrieve']
72
- end
73
-
74
- return resume
75
- end
76
-
77
- #############################################################
78
- ## TODO: Create a resume
79
- ##
80
- ## For detailed information around this API please visit:
81
- ## http://www.careerbuilder.com/api/ResumeInfo.aspx
82
- #############################################################
83
- def self.create resume
84
- my_api = Cb::Utils::Api.new
85
- json_hash = my_api.cb_post(Cb.configuration.uri_resume_create, :body => make_create_xml(resume))
86
- end
87
-
88
- #############################################################
89
- ## TODO: Update a resume
90
- ##
91
- ## For detailed information around this API please visit:
92
- ## http://www.careerbuilder.com/api/ResumeInfo.aspx
93
- #############################################################
94
- def self.update resume
95
- my_api = Cb::Utils::Api.new
96
- json_hash = my_api.cb_post(Cb.configuration.uri_resume_update, :body => make_update_xml(resume))
97
- end
98
-
99
- #############################################################
100
- ## TODO: Delete a resume
101
- ##
102
- ## For detailed information around this API please visit:
103
- ## http://www.careerbuilder.com/api/ResumeInfo.aspx
104
- #############################################################
105
- def self.delete resume
106
- my_api = Cb::Utils::Api.new
107
- json_hash = my_api.cb_post(Cb.configuration.uri_resume_delete, :body => make_delete_xml(resume))
108
- end
109
-
110
- private
111
- def make_create_xml(resume)
112
- xml = "<Request>"
113
- xml += "<DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>"
114
- xml += "<ExternalID>#{resume.resume_external_id}</ExternalID>"
115
- xml += "<Test>false</Test>"
116
- xml += "<ExternalUserID>#{resume.user_external_id}</ExternalUserID>"
117
- cd = self.new_record? ? Date.current : self.created_at
118
- md = self.new_record? ? Date.current : self.updated_at
119
- xml += "<CreatedDT>#{cd.xmlschema}</CreatedDT>"
120
- xml += "<ModifiedDT>#{md.xmlschema}</ModifiedDT>"
121
- xml += "<Certifications>#{resume.certifications * ','}</Certifications>"
122
- xml += "<ShowContactInfo>#{resume.show_contact_info}</ShowContactInfo>"
123
- xml += "<Title>#{resume.title.xmlsafe}</Title>"
124
- xml += "<ResumeText>#{resume.resume_text.xmlsafe}</ResumeText>"
125
- xml += "<Visibility>#{resume.visibility.to_s.downcase}</Visibility>"
126
- xml += "<CanRelocateNationally>#{resume.can_relocate_nationally.to_s.downcase}</CanRelocateNationally>"
127
- xml += "<CanRelocateInternationally>#{resume.can_relocate_internationally.to_s.downcase}</CanRelocateInternationally>"
128
- xml += "<TotalYearsExperience>#{resume.total_years_experience.to_i}</TotalYearsExperience>"
129
- xml += "<HostSite>#{Cb.configuration.host_site}</HostSite>"
130
- xml += "<DesiredJobTypes>#{resume.desired_job_type}</DesiredJobTypes>" unless resume.desired_job_type.blank?
131
- xml += "<DesiredJobTypes>ETFE</DesiredJobTypes>" if resume.desired_job_type.blank?
132
- xml += "<RecentPayAmount>#{resume.recent_pay_amount.money_to_string}</RecentPayAmount>" unless resume.recent_pay_amount.blank?
133
- xml += "<RecentPayType>#{resume.recent_pay_type.downcase}</RecentPayType>" unless resume.recent_pay_type.blank?
134
-
135
- xml += "<CompanyExperiences>"
136
- resumes.company_experiences.each do |experience|
137
- xml += "<CompanyExperience>"
138
- xml += "<CompanyName>#{experience.company_name.xmlsafe}</CompanyName>"
139
- xml += "<JobTitle>#{experience.job_title.xmlsafe}</JobTitle>"
140
- xml += "<StartDate>#{experience.start_date.to_s}</StartDate>" unless experience.start_date.blank?
141
- xml += "<EndDate>#{experience.end_date.to_s}</EndDate>" unless experience.end_date.blank?
142
- xml += "<EndDate>1970-01-01</EndDate>" if experience.end_date.blank?
143
- xml += "<Details>#{experience.details.xmlsafe}</Details>"
144
- xml += "</CompanyExperience>"
145
- end
146
- xml += "</CompanyExperiences>"
147
- xml += "<Educations>"
148
- resume.educations.each do |education|
149
- xml += "<Education>"
150
- xml += "<SchoolName>#{education.school_name.xmlsafe}</SchoolName>"
151
- xml += "<Major>#{education.major.xmlsafe}</Major>"
152
- xml += "<DegreeCode>#{education.degree_code}</DegreeCode>"
153
- xml += "<GraduationDate>#{education.graduation_date.to_s}</GraduationDate>" unless education.graduation_date.blank?
154
- #Never actually needed:
155
- #xml += "<GPA>#{education.gpa.to_i}</GPA>"
156
- xml += "</Education>"
157
- end
158
- xml += "</Educations>"
159
- xml += "<Languages>"
160
- resume.languages.each do |language|
161
- xml += "<Language>#{language}</Language>"
162
- end
163
- xml += "</Languages>"
164
- xml += "</Request>"
165
- xml
166
- end
167
-
168
- def make_update_xml(resume)
169
- make_create_xml resume
170
- end
171
-
172
- def make_delete_xml(resume)
173
- raise "external_resume_id is undefined in CbResume." if resume.external_resume_id.blank?
174
- raise "external_user_id is undefined in CbResume." if resume.external_user_id.blank?
175
-
176
- xml = '<Request>'
177
- xml += "<DeveloperKey></DeveloperKey>"
178
- xml += "<ExternalID>#{resume.external_resume_id}</ExternalID>"
179
- xml += "<Test>#{resume.test}</Test>"
180
- xml += "<ExternalUserID>#{resume.external_user_id}</ExternalUserID>"
181
- xml += '</Request>'
182
- xml
183
- end
184
- end
185
- end