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,11 @@
1
+ module Cb
2
+ module Criteria
3
+ module Job
4
+ class Details
5
+ extend Cb::Utils::FluidAttributes
6
+
7
+ fluid_attr_accessor :did, :show_job_skin, :site_id, :lhs, :cobrand, :show_apply_requirements, :show_custom_values
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ module Cb
2
+ module Criteria
3
+ module Job
4
+ class Search
5
+ extend Cb::Utils::FluidAttributes
6
+
7
+ fluid_attr_accessor :advanced_grouping_mode, :boolean_operator, :category, :co_brand, :company_did,
8
+ :company_did_csv, :company_name, :company_name_boost_params, :country_code,
9
+ :education_code, :emp_type, :enable_company_collapse, :exclude_company_names,
10
+ :exclude_job_titles, :exclude_keywords, :exclude_national, :exclude_non_traditional_jobs,
11
+ :exclude_product_id, :facet_category, :facet_company, :facet_city, :facet_state,
12
+ :facet_city_state, :facet_pay, :facet_normalized_company_did, :host_site,
13
+ :include_company_children, :industry_codes, :job_title, :keywords, :location,
14
+ :normalized_company_did, :normalized_company_did_boost_params,
15
+ :normalized_company_name, :onet_code, :order_by, :order_direction, :page_number,
16
+ :partner_id, :pay_high, :pay_info_only, :pay_low, :per_page, :posted_within,
17
+ :product_id, :radius, :records_per_group, :relocate_jobs, :soc_code, :school_site_id,
18
+ :search_all_countries, :search_view, :show_categories, :show_apply_requirements,
19
+ :apply_requirements, :exclude_apply_requirements, :single_onet_search, :site_entity, :site_id, :skills, :specific_education,
20
+ :spoken_language, :tags, :talent_network_did, :url_compression_service, :use_facets,
21
+ :str_crit
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ module Cb
2
+ module Criteria
3
+ module Spot
4
+ class Retrieve
5
+ extend Cb::Utils::FluidAttributes
6
+
7
+ fluid_attr_accessor :contenttype, :language, :sortfield, :sortdirection, :maxitems
8
+ (1..8).each { |num| fluid_attr_accessor "field#{num.to_s}".to_sym }
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,4 +1,5 @@
1
1
  module Cb
2
2
  class IncomingParamIsWrongTypeException < StandardError; end
3
- class ExpectedResponseFieldMissing < StandardError; end
3
+ class ExpectedResponseFieldMissing < StandardError; end
4
+ class ApiResponseError < StandardError; end
4
5
  end
@@ -0,0 +1,92 @@
1
+ module Cb
2
+ module Models
3
+ class Application
4
+ #request params
5
+ attr_accessor :job_did, :site_id, :ipath, :co_brand, :test,
6
+ :resume_file_name, :resume,
7
+ :user_external_id, :user_external_resume_id,
8
+ :answers
9
+
10
+ #response params
11
+ #redirect_url is returned from the api for shared apply applications.
12
+ attr_accessor :redirect_url
13
+
14
+ def initialize(args = {})
15
+ @job_did = args[:job_did]
16
+ @site_id = args[:site_id] || 'cbnsv'
17
+ @ipath = args[:ipath] || ''
18
+ @co_brand = args[:co_brand] || ''
19
+ @test = args[:test] || 'false'
20
+ @resume_file_name = args[:resume_file_name] || ''
21
+ @resume = args[:resume] || ''
22
+ @user_external_id = args[:user_external_id] || ''
23
+ @user_external_resume_id = args[:user_external_resume_id] || ''
24
+ @answers = []
25
+ @redirect_url = ''
26
+ end
27
+
28
+ def submit
29
+ if is_registered?
30
+ Cb.application.submit_registered_app(self)
31
+ else
32
+ Cb.application.submit_app(self)
33
+ end
34
+ end
35
+
36
+ def is_registered?
37
+ !@user_external_id.blank? && @resume.blank?
38
+ end
39
+
40
+ def is_unregistered?
41
+ !is_registered?
42
+ end
43
+
44
+ def complete?
45
+ cb_response.application_status == 'Complete' || cb_response.application_status == 'Complete (Test)'
46
+ end
47
+
48
+ def add_answer(id, text)
49
+ @answers << Application::Answer.new(id, text)
50
+ end
51
+
52
+ def to_xml
53
+ ret = '<RequestApplication>'
54
+
55
+ ret = "#{ret}<DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>"
56
+ ret = "#{ret}<JobDID>#{@job_did}</JobDID>"
57
+ ret = "#{ret}<Test>#{@test}</Test>" unless @test.blank?
58
+ ret = "#{ret}<SiteID>#{@site_id}</SiteID>" unless @site_id.blank?
59
+ #ret = "#{ret}<IPath>#{@ipath}</IPath>" unless @ipath.blank? #this has to be passed by query string because the api is lame.
60
+ ret = "#{ret}<CoBrand>#{@co_brand}</CoBrand>" unless @co_brand.blank?
61
+ ret = "#{ret}<HostSite>#{Cb.configuration.host_site}</HostSite>"
62
+ ret = "#{ret}<Resume><ResumeFileName>#{@resume_file_name}</ResumeFileName><ResumeData>#{@resume}</ResumeData></Resume>" if is_unregistered?
63
+
64
+ unless @answers.count == 0
65
+ ret = "#{ret}<Responses>"
66
+ @answers.each do | ans |
67
+ ret = "#{ret}#{ans.to_xml}"
68
+ end
69
+ ret = "#{ret}</Responses>"
70
+ end
71
+
72
+ ret = "#{ret}<ExternalUserID>#{@user_external_id}</ExternalUserID>" if is_registered?
73
+ ret = "#{ret}<ExternalResumeID>#{@user_external_resume_id}</ExternalResumeID>" if is_registered?
74
+
75
+ "#{ret}</RequestApplication>"
76
+ end # to_xml
77
+ end # CbApplication
78
+
79
+ class Application::Answer
80
+ attr_accessor :id, :text
81
+
82
+ def initialize(id, text)
83
+ @id = id
84
+ @text = text
85
+ end
86
+
87
+ def to_xml
88
+ "<Response><QuestionID>#{@id}</QuestionID><ResponseText>#{@text}</ResponseText></Response>"
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,28 @@
1
+ module Cb
2
+ module Models
3
+ class ApplicationExternal
4
+ attr_accessor :job_did, :email, :site_id, :ipath, :apply_url
5
+
6
+ def initialize(args = {})
7
+ @job_did = args[:job_did] || ''
8
+ @email = args[:email] || ''
9
+ @site_id = args[:site_id] || 'cbnsv'
10
+ @ipath = args[:ipath] || ''
11
+ @apply_url = ''
12
+ end
13
+
14
+ def to_xml
15
+ ret = "<Request>"
16
+ ret += "<DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>"
17
+ ret += "<EmailAddress>#{@email}</EmailAddress>"
18
+ ret += "<JobDID>#{@job_did}</JobDID>"
19
+ ret += "<SiteID>#{@site_id}</SiteID>"
20
+ ret += "<IPath>#{@ipath}</IPath>"
21
+ ret += "<IsExternalLinkApply>false</IsExternalLinkApply>"
22
+ ret += "<HostSite>#{Cb.configuration.host_site}</HostSite>"
23
+ ret += "</Request>"
24
+ ret
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,75 @@
1
+ module Cb
2
+ module Models
3
+ class ApplicationSchema
4
+ attr_accessor :did, :title, :requirements,
5
+ :apply_url, :submit_service_url, :is_shared_apply,
6
+ :total_questions, :total_required_questions, :questions
7
+
8
+ def initialize(args = {})
9
+ return if args.nil?
10
+
11
+ # Job Info related
12
+ @did = args['JobDID'] || ''
13
+ @title = args['JobTitle'] || ''
14
+ @requirements = args['Requirements'] || ''
15
+
16
+ # Apply URL related
17
+ @submit_service_url = args['ApplicationSubmitServiceURL'] || ''
18
+ @apply_url = args['ApplyURL'] || ''
19
+ @is_shared_apply = (args['IsSharedApply'].downcase == 'true')
20
+
21
+ # Question related
22
+ @total_questions = args['TotalQuestions'] || ''
23
+ @total_required_questions = args['TotalRequiredQuestions'] || ''
24
+ @total_questions = @total_questions.to_i if Cb::Utils::Api.is_numeric? @total_questions
25
+ @total_required_questions = @total_required_questions.to_i if Cb::Utils::Api.is_numeric? @total_required_questions
26
+
27
+ @questions = []
28
+ if args.has_key?('Questions')
29
+ unless args['Questions'].empty?
30
+ args['Questions']['Question'].each do | qq |
31
+ @questions << ApplicationSchema::QuestionSchema.new(qq)
32
+ end
33
+ end
34
+ end
35
+ end # Initialize
36
+ end # CbApplicationSchema
37
+
38
+ #################################################################
39
+ class ApplicationSchema::QuestionSchema
40
+ attr_accessor :id, :type, :required, :format, :text, :answers
41
+
42
+ def initialize(args = {})
43
+ return if args.nil?
44
+
45
+ @id = args['QuestionID'] || ''
46
+ @type = args['QuestionType'] || ''
47
+ @required = (args['IsRequired'].downcase == 'true')
48
+ @format = args['ExpectedResponseFormat'] || ''
49
+ @text = args['QuestionText'] || ''
50
+
51
+ @answers = []
52
+ if args.has_key?('Answers')
53
+ unless args['Answers'].empty?
54
+ args['Answers']['Answer'].each do | aa |
55
+ @answers << ApplicationSchema::AnswerSchema.new(aa)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end # CbQuestionSchema
61
+
62
+ #################################################################
63
+ class ApplicationSchema::AnswerSchema
64
+ attr_accessor :question_id, :id, :text
65
+
66
+ def initialize(args = {})
67
+ return if args.nil?
68
+
69
+ @question_id = args['QuestionID']
70
+ @id = args['AnswerID']
71
+ @text = args['AnswerText']
72
+ end
73
+ end # CbAnswerSchema
74
+ end
75
+ end
@@ -1,20 +1,20 @@
1
1
  module Cb
2
- module Branding
2
+ module Models
3
+ module Branding
3
4
 
4
- class Media
5
+ class Media
6
+ attr_accessor :header, :header_type, :tablet_banner, :mobile_logo, :footer, :is_multi_video
5
7
 
6
- attr_accessor :header, :header_type, :tablet_banner, :mobile_logo, :footer, :video, :is_multi_video
7
-
8
- def initialize args = {}
9
- @header = args['Header'] || ''
10
- @header_type = args['HeaderType'] || ''
11
- @tablet_banner = args['TabletBanner'] || ''
12
- @mobile_logo = args['MobileLogo'] || ''
13
- @footer = args['Footer'] || ''
14
- @video = args['Video'] || ''
15
- @is_multi_video = args['IsMultiVideo'] == true
8
+ def initialize(args = {})
9
+ @header = args['Header'] || ''
10
+ @header_type = args['HeaderType'] || ''
11
+ @tablet_banner = args['TabletBanner'] || ''
12
+ @mobile_logo = args['MobileLogo'] || ''
13
+ @footer = args['Footer'] || ''
14
+ @is_multi_video = args['IsMultiVideo'] == 'true'
15
+ end
16
16
  end
17
17
 
18
18
  end
19
- end
20
- end
19
+ end
20
+ end
@@ -1,22 +1,21 @@
1
1
  module Cb
2
- module Branding
2
+ module Models
3
+ module Branding
3
4
 
4
- class Section
5
- # Might be changing?
6
- attr_accessor :type, :section_1, :section_2, :section_3, :description, :requirements, :snapshot
5
+ class Section
6
+ attr_accessor :type, :section_1, :section_2, :section_3, :description, :requirements, :snapshot
7
7
 
8
- def initialize type, args = {}
9
- @type = type
10
-
11
- @section_1 = args['Section1'] || ''
12
- @section_2 = args['Section2'] || ''
13
- @section_3 = args['Section3'] || ''
14
- @description = args['Description'] || ''
15
- @requirements = args['Requirements'] || ''
16
- @snapshot = args['Snapshot'] || ''
8
+ def initialize(type, args = {})
9
+ @type = type
10
+ @section_1 = args['Section1'] || ''
11
+ @section_2 = args['Section2'] || ''
12
+ @section_3 = args['Section3'] || ''
13
+ @description = args['Description'] || ''
14
+ @requirements = args['Requirements'] || ''
15
+ @snapshot = args['Snapshot'] || ''
16
+ end
17
17
  end
18
18
 
19
19
  end
20
20
  end
21
-
22
- end
21
+ end
@@ -1,17 +1,17 @@
1
1
  module Cb
2
- module Branding
2
+ module Models
3
+ module Branding
3
4
 
4
- class Style
5
+ class Style
6
+ attr_accessor :page, :job_details, :company_info
5
7
 
6
- attr_accessor :page, :job_details, :company_info
7
-
8
- def initialize args = {}
9
- @page = Cb::Branding::Styles::Page.new args['Page']
10
- @job_details = Cb::Branding::Styles::JobDetails.new args['JobDetails']
11
- @company_info = Cb::Branding::Styles::CompanyInfo.new args['CompanyInfo']
8
+ def initialize(args = {})
9
+ @page = Styles::Page.new args['Page']
10
+ @job_details = Styles::JobDetails.new args['JobDetails']
11
+ @company_info = Styles::CompanyInfo.new args['CompanyInfo']
12
+ end
12
13
  end
13
14
 
14
15
  end
15
-
16
16
  end
17
- end
17
+ end
@@ -1,19 +1,21 @@
1
1
  module Cb
2
- module Branding
3
- module Styles
2
+ module Models
3
+ module Branding
4
+ module Styles
4
5
 
5
- class Base
6
- attr_writer :styles
6
+ class Base
7
+ attr_writer :styles
7
8
 
8
- def initialize args = {}
9
- @styles = args
10
- end
9
+ def initialize args = {}
10
+ @styles = args
11
+ end
11
12
 
12
- def raw
13
- @styles
13
+ def raw
14
+ @styles
15
+ end
14
16
  end
17
+
15
18
  end
16
19
  end
17
20
  end
18
-
19
21
  end
@@ -1,12 +1,13 @@
1
1
  module Cb
2
- module Branding
3
- module Styles
2
+ module Models
3
+ module Branding
4
+ module Styles
4
5
 
5
- class Buttons < Base
6
- include Cb::Branding::Styles::CssAdapter
6
+ class Buttons < Base
7
+ include CssAdapter
8
+ end
7
9
 
8
10
  end
9
11
  end
10
12
  end
11
-
12
- end
13
+ end
@@ -1,19 +1,21 @@
1
1
  module Cb
2
- module Branding
3
- module Styles
2
+ module Models
3
+ module Branding
4
+ module Styles
4
5
 
5
- class CompanyInfo < Base
6
- attr_accessor :buttons, :container, :content, :headings
6
+ class CompanyInfo < Base
7
+ attr_accessor :buttons, :container, :content, :headings
7
8
 
8
- def initialize args = {}
9
- super
10
-
11
- @buttons = Buttons.new args['Buttons']
12
- @container = Container.new args['Container']
13
- @content = Content.new args['Content']
14
- @headings = Headings.new args['Headings']
9
+ def initialize args = {}
10
+ super
11
+ @buttons = Buttons.new args['Buttons']
12
+ @container = Container.new args['Container']
13
+ @content = Content.new args['Content']
14
+ @headings = Headings.new args['Headings']
15
+ end
15
16
  end
17
+
16
18
  end
17
19
  end
18
20
  end
19
- end
21
+ end