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
@@ -0,0 +1,57 @@
1
+ require 'json'
2
+
3
+ module Cb
4
+ module Clients
5
+ class Job
6
+
7
+ def self.search(*args)
8
+ args = args[0] if args.is_a?(Array) && args.count == 1
9
+ my_api = Cb::Utils::Api.new
10
+ json_hash = my_api.cb_get(Cb.configuration.uri_job_search, :query => args)
11
+
12
+ jobs = Array.new
13
+ if !json_hash['ResponseJobSearch'].nil? && !json_hash['ResponseJobSearch']['Results'].nil?
14
+ job_results = json_hash['ResponseJobSearch']['Results']['JobSearchResult']
15
+ job_results = [job_results] if !job_results.is_a?(Array)
16
+ job_results.each { |job_hash| jobs.push(Models::Job.new(job_hash)) }
17
+ my_api.append_api_responses(jobs, json_hash['ResponseJobSearch'])
18
+
19
+ if response_has_search_metadata?(json_hash['ResponseJobSearch'])
20
+ my_api.append_api_responses(jobs, json_hash['ResponseJobSearch']['SearchMetaData']['SearchLocations']['SearchLocation'])
21
+ end
22
+ end
23
+
24
+ my_api.append_api_responses(jobs, json_hash)
25
+ end
26
+
27
+ def self.find_by_criteria(criteria)
28
+ my_api = Cb::Utils::Api.new
29
+ params = my_api.class.criteria_to_hash(criteria)
30
+ json_hash = my_api.cb_get(Cb.configuration.uri_job_find, :query => params)
31
+
32
+ if json_hash.has_key?('ResponseJob')
33
+ if json_hash['ResponseJob'].has_key?('Job')
34
+ job = Models::Job.new(json_hash['ResponseJob']['Job'])
35
+ end
36
+ my_api.append_api_responses(job, json_hash['ResponseJob'])
37
+ end
38
+ my_api.append_api_responses(job, json_hash)
39
+ end
40
+
41
+ def self.find_by_did(did)
42
+ criteria = Cb::Criteria::Job::Details.new
43
+ criteria.did = did
44
+ criteria.show_custom_values = true
45
+ return find_by_criteria(criteria)
46
+ end
47
+
48
+ private
49
+
50
+ def self.response_has_search_metadata?(response_hash)
51
+ response_hash['SearchMetaData'] &&
52
+ response_hash['SearchMetaData']['SearchLocations'] &&
53
+ response_hash['SearchMetaData']['SearchLocations']['SearchLocation']
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,21 @@
1
+ require 'nori'
2
+
3
+ module Cb
4
+ module Clients
5
+ class JobBranding
6
+
7
+ def self.find_by_id id
8
+ my_api = Cb::Utils::Api.new
9
+ json_hash = my_api.cb_get Cb.configuration.uri_job_branding, :query => { :id => id }
10
+
11
+ if json_hash.has_key? 'Branding'
12
+ branding = Models::JobBranding.new json_hash['Branding']
13
+ my_api.append_api_responses(branding, json_hash['Branding'])
14
+ end
15
+
16
+ my_api.append_api_responses(branding, json_hash)
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,76 @@
1
+ require 'json'
2
+
3
+ module Cb
4
+ module Clients
5
+ class Recommendation
6
+
7
+ def self.for_job(did, countlimit = '25', site_id = '', co_brand = '')
8
+ my_api = Cb::Utils::Api.new
9
+ json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_job,
10
+ :query => {:JobDID => did, :CountLimit => countlimit, :SiteID => site_id,
11
+ :CoBrand => co_brand, :HostSite => Cb.configuration.host_site})
12
+
13
+ jobs = []
14
+ if json_hash.has_key?('ResponseRecommendJob')
15
+ if json_hash['ResponseRecommendJob'].has_key?('RecommendJobResults') &&
16
+ !json_hash['ResponseRecommendJob']['RecommendJobResults'].nil?
17
+
18
+ json_hash['ResponseRecommendJob']['RecommendJobResults']['RecommendJobResult'].each do |cur_job|
19
+ jobs << Models::Job.new(cur_job)
20
+ end
21
+
22
+ my_api.append_api_responses(jobs, json_hash['ResponseRecommendJob']['Request'])
23
+ end
24
+
25
+ my_api.append_api_responses(jobs, json_hash['ResponseRecommendJob'])
26
+ end
27
+
28
+ my_api.append_api_responses(jobs, json_hash)
29
+ end
30
+
31
+ def self.for_user(external_id, countlimit = '25', site_id = '', co_brand = '')
32
+ my_api = Cb::Utils::Api.new
33
+ json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_user,
34
+ :query => {:ExternalID => external_id, :CountLimit => countlimit, :SiteID => site_id, :CoBrand => co_brand,
35
+ :HostSite => Cb.configuration.host_site})
36
+
37
+ jobs = []
38
+ if json_hash.has_key?('ResponseRecommendUser')
39
+
40
+ if json_hash['ResponseRecommendUser'].has_key?('RecommendJobResults') &&
41
+ !json_hash['ResponseRecommendUser']['RecommendJobResults'].nil?
42
+
43
+ json_hash['ResponseRecommendUser']['RecommendJobResults']['RecommendJobResult'].each do |cur_job|
44
+ jobs << Models::Job.new(cur_job)
45
+ end
46
+ my_api.append_api_responses(jobs, json_hash['ResponseRecommendUser']['Request'])
47
+ end
48
+
49
+ my_api.append_api_responses(jobs, json_hash['ResponseRecommendUser'])
50
+ end
51
+
52
+ my_api.append_api_responses(jobs, json_hash)
53
+ end
54
+
55
+ def self.for_company(company_did)
56
+ my_api = Cb::Utils::Api.new
57
+ json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_company, :query => {:CompanyDID => company_did})
58
+
59
+ jobs = []
60
+ if json_hash.has_key?('Results')
61
+ if json_hash['Results'].has_key?('JobRecommendation')
62
+ json_hash['Results']['JobRecommendation']['Jobs'].each do |cur_job|
63
+ jobs << Models::Job.new(cur_job)
64
+ end
65
+ my_api.append_api_responses(jobs, json_hash['Results']['JobRecommendation'])
66
+ end
67
+
68
+ my_api.append_api_responses(jobs, json_hash['Results'])
69
+ end
70
+
71
+ my_api.append_api_responses(jobs, json_hash)
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,66 @@
1
+ module Cb
2
+ module Clients
3
+
4
+ class SavedSearch
5
+ def create(saved_search)
6
+ body = saved_search.create_to_xml
7
+ json = cb_client.cb_post(Cb.configuration.uri_saved_search_create, :body => body)
8
+ singular_model_response(json, saved_search.external_user_id)
9
+ end
10
+
11
+ def update(saved_search)
12
+ body = saved_search.update_to_xml
13
+ json = cb_client.cb_post(Cb.configuration.uri_saved_search_update, :body => body)
14
+ singular_model_response(json, saved_search.external_user_id, saved_search.external_id)
15
+ end
16
+
17
+ def delete(saved_search)
18
+ body = saved_search.delete_to_xml
19
+ json = cb_client.cb_post(Cb.configuration.uri_saved_search_delete, :body => body)
20
+ Responses::SavedSearch::Delete.new(json)
21
+ end
22
+
23
+ def retrieve(external_user_id, external_id, host_site)
24
+ query = retrieve_query(external_user_id, external_id, host_site)
25
+ json = cb_client.cb_get(Cb.configuration.uri_saved_search_retrieve, :query => query)
26
+ singular_model_response(json, external_user_id, external_id)
27
+ end
28
+
29
+ def list(external_user_id, host_site)
30
+ query = list_query(external_user_id, host_site)
31
+ json = cb_client.cb_get(Cb.configuration.uri_saved_search_list, :query => query)
32
+ Responses::SavedSearch::List.new(json)
33
+ end
34
+
35
+ private
36
+
37
+ def cb_client
38
+ @cb_client ||= Cb.api_client.new
39
+ end
40
+
41
+ def retrieve_query(external_user_id, external_id, host_site)
42
+ {
43
+ :developerkey => Cb.configuration.dev_key,
44
+ :externalid => external_id,
45
+ :externaluserid => external_user_id,
46
+ :hostsite => host_site
47
+ }
48
+ end
49
+
50
+ def list_query(external_user_id, host_site)
51
+ {
52
+ :developerkey => Cb.configuration.dev_key,
53
+ :externaluserid => external_user_id,
54
+ :hostsite => host_site
55
+ }
56
+ end
57
+
58
+ def singular_model_response(json_hash, external_user_id = nil, external_id = nil)
59
+ json_hash['ExternalUserID'] = external_user_id unless external_user_id.nil?
60
+ json_hash['ExternalID'] = external_id unless external_id.nil?
61
+ Responses::SavedSearch::Singular.new(json_hash)
62
+ end
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,27 @@
1
+ require 'json'
2
+
3
+ module Cb
4
+ module Clients
5
+ class Spot
6
+ class << self
7
+
8
+ def retrieve(criteria)
9
+ response = retrieve_api_response criteria
10
+ Cb::Responses::Spot::Retrieve.new(response)
11
+ end
12
+
13
+ private
14
+
15
+ def retrieve_api_response(criteria)
16
+ params = api_client.class.criteria_to_hash criteria
17
+ api_client.cb_get(Cb.configuration.uri_spot_retrieve, :query => params)
18
+ end
19
+
20
+ def api_client
21
+ @api ||= Cb::Utils::Api.new
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,51 @@
1
+ module Cb
2
+ module Clients
3
+ class TalentNetwork
4
+
5
+ def self.join_form_questions(tndid)
6
+ my_api = Cb::Utils::Api.new
7
+ json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_questions}/#{tndid}/json")
8
+ tn_questions_collection = Models::TalentNetwork.new(json_hash)
9
+ my_api.append_api_responses(tn_questions_collection, json_hash)
10
+ end
11
+
12
+ def self.join_form_branding(tndid)
13
+ my_api = Cb::Utils::Api.new
14
+ json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_form_branding}/#{tndid}/json")
15
+
16
+ if json_hash.has_key? 'Branding'
17
+ tn_join_form_branding = Models::TalentNetwork::JoinFormBranding.new(json_hash['Branding'])
18
+ end
19
+
20
+ my_api.append_api_responses(tn_join_form_branding, json_hash)
21
+ end
22
+
23
+ def self.join_form_geography(tnlanguage="USEnglish")
24
+ my_api = Cb::Utils::Api.new
25
+ json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_form_geo}", :query => {:TNLanguage => "#{tnlanguage}"})
26
+ geo_dropdown = Models::TalentNetwork::JoinFormGeo.new(json_hash)
27
+ my_api.append_api_responses(geo_dropdown, json_hash)
28
+ end
29
+
30
+ def self.member_create(args={})
31
+ my_api = Cb::Utils::Api.new
32
+ tn_member = Models::TalentNetwork::Member.new(args)
33
+ json_hash = my_api.cb_post("#{Cb.configuration.uri_tn_member_create}/json", :body => tn_member.to_xml )
34
+ my_api.append_api_responses(json_hash, json_hash)
35
+ end
36
+
37
+ def self.tn_job_information(job_did, join_form_intercept="true")
38
+ my_api = Cb::Utils::Api.new
39
+ json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_job_info}/#{job_did}/json", :query=> {
40
+ :RequestJoinFormIntercept => join_form_intercept})
41
+
42
+ if json_hash.has_key? 'Response'
43
+ tn_job_info = Models::TalentNetwork::JobInfo.new(json_hash['Response'])
44
+ end
45
+
46
+ my_api.append_api_responses(tn_job_info, json_hash)
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,94 @@
1
+ require 'json'
2
+ require 'nokogiri'
3
+
4
+ module Cb
5
+ module Clients
6
+ class User
7
+
8
+ def self.retrieve external_id, test_mode = false
9
+ my_api = Cb::Utils::Api.new
10
+ json_hash = my_api.cb_post Cb.configuration.uri_user_retrieve, :body => build_retrieve_request(external_id, true)
11
+
12
+ if json_hash.has_key? 'ResponseUserInfo'
13
+ if json_hash['ResponseUserInfo'].has_key? 'UserInfo'
14
+ user = Models::User.new json_hash['ResponseUserInfo']['UserInfo']
15
+ end
16
+ my_api.append_api_responses user, json_hash['ResponseUserInfo']
17
+ end
18
+
19
+ my_api.append_api_responses user, json_hash
20
+ end
21
+
22
+ def self.change_password external_id, old_password, new_password, test_mode = false
23
+ result = false
24
+ my_api = Cb::Utils::Api.new
25
+ 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)
26
+
27
+ if json_hash.has_key? 'ResponseUserChangePW'
28
+ if json_hash['ResponseUserChangePW'].has_key?('Status') && json_hash['ResponseUserChangePW']['Status'].include?('Success')
29
+ result = true
30
+ end
31
+ my_api.append_api_responses result, json_hash['ResponseUserChangePW']
32
+ end
33
+
34
+ my_api.append_api_responses result, json_hash
35
+ end
36
+
37
+ def self.delete external_id, password, test_mode = false
38
+ result = false
39
+ my_api = Cb::Utils::Api.new
40
+ json_hash = my_api.cb_post Cb.configuration.uri_user_delete, :body => build_delete_request(external_id, password, test_mode)
41
+
42
+ if json_hash.has_key? 'ResponseUserDelete'
43
+ if json_hash['ResponseUserDelete'].has_key?('Status') && json_hash['ResponseUserDelete']['Status'].include?('Success')
44
+ result = true
45
+ end
46
+ my_api.append_api_responses result, json_hash['ResponseUserDelete']
47
+ end
48
+
49
+ my_api.append_api_responses result, json_hash
50
+ end
51
+
52
+ private
53
+ def self.build_retrieve_request external_id, test_mode
54
+ builder = Nokogiri::XML::Builder.new do
55
+ Request {
56
+ ExternalID_ external_id
57
+ Test_ test_mode.to_s
58
+ DeveloperKey_ Cb.configuration.dev_key
59
+ }
60
+ end
61
+
62
+ builder.to_xml
63
+ end
64
+
65
+ def self.build_change_password_request external_id, old_password, new_password, test_mode
66
+ builder = Nokogiri::XML::Builder.new do
67
+ Request {
68
+ ExternalID_ external_id
69
+ OldPassword_ old_password
70
+ NewPassword_ new_password
71
+ Test_ test_mode.to_s
72
+ DeveloperKey_ Cb.configuration.dev_key
73
+ }
74
+ end
75
+
76
+ builder.to_xml
77
+ end
78
+
79
+ def self.build_delete_request external_id, password, test_mode
80
+ builder = Nokogiri::XML::Builder.new do
81
+ Request {
82
+ ExternalID_ external_id
83
+ Password_ password
84
+ Test_ test_mode.to_s
85
+ DeveloperKey_ Cb.configuration.dev_key
86
+ }
87
+ end
88
+
89
+ builder.to_xml
90
+ end
91
+
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,83 @@
1
+ module Cb
2
+ module Convenience
3
+ module ClassMethods
4
+
5
+ def api_client
6
+ Cb::Utils::Api
7
+ end
8
+
9
+ def job
10
+ Cb::Clients::Job
11
+ end
12
+
13
+ def job_search_criteria
14
+ Cb::Criteria::Job::Search.new
15
+ end
16
+
17
+ def job_details_criteria
18
+ Cb::Criteria::Job::Details.new
19
+ end
20
+
21
+ def category
22
+ Cb::Clients::Category
23
+ end
24
+
25
+ def company
26
+ Cb::Clients::Company
27
+ end
28
+
29
+ def education_code
30
+ Cb::Clients::Education
31
+ end
32
+
33
+ def employee_types
34
+ Cb::Clients::EmployeeTypes
35
+ end
36
+
37
+ def recommendation
38
+ Cb::Clients::Recommendation
39
+ end
40
+
41
+ def application
42
+ Cb::Clients::Application
43
+ end
44
+
45
+ def application_external
46
+ Cb::Clients::ApplicationExternal
47
+ end
48
+
49
+ def country
50
+ Cb::Utils::Country
51
+ end
52
+
53
+ def user
54
+ Cb::Clients::User
55
+ end
56
+
57
+ def job_branding
58
+ Cb::Clients::JobBranding
59
+ end
60
+
61
+ def email_subscription
62
+ Cb::Clients::EmailSubscription
63
+ end
64
+
65
+ def saved_search
66
+ Cb::Clients::SavedSearch
67
+ end
68
+
69
+ def talent_network
70
+ Cb::Clients::TalentNetwork
71
+ end
72
+
73
+ def anon_saved_search
74
+ Cb::Clients::AnonSavedSearch
75
+ end
76
+
77
+ def spot
78
+ Cb::Clients::Spot
79
+ end
80
+
81
+ end
82
+ end
83
+ end