cb-api 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjYzZmVmOWRlMjViZjM5ZTU2MmViYzExY2NiMDczMWYzNzQxNzg3ZQ==
4
+ NzI1MWYyNThkYmJlYWQ1ZjRkZjYwM2RhMDA4NDg1ODRiODhhNDJlYQ==
5
5
  data.tar.gz: !binary |-
6
- NmU0Yzc4ZGYzMTM4OTI1MDc3ZTMyY2FhMWIzNjliMTMyM2VkYTM3YQ==
6
+ ZGZhYTA3M2RmOTAzNWMzN2Y2ZjU5YzEyNTQwMjZhNjdlMGJhYmI5MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2Q4MmI3ZDBhZDM1ZjY5ZTg1YWRkNmJjMjdkYzdmODM4NTc2ZjJmNDMyNTBl
10
- YTM2MTRmNzNmZmQ3ZmFkOTdiZjlmYjExZmYwOTAxMDdmYzMzYmMxZDg2MjFj
11
- ZThlNGM3NDE1NGQwMGQ2NWQ3YTQ3YTI4OWQ0NTIzNjcxYzc4NjA=
9
+ YTFhMzg0NjgyYTJjN2M4MzdjN2QxMDRhNmJmN2FkYWNkMTNhYjQ1MjQwZTkz
10
+ OWJiZjg2ZmY5NjcyYjc4MjRhNzNjZDk2NzFkZTBlYzJkOGRjNWE4NTc3YzA0
11
+ MGVjYjg1NTdlODZkYTRmZWRkMTAxNTNhNTEyNWY3NTE0ZjFiMTQ=
12
12
  data.tar.gz: !binary |-
13
- OWQ5NDMwN2E0MmFiZjhlZDhjYjc1MTA5YThkNmM0NTU4MWE0MTk5ZjdhNzlj
14
- NGE3ZGIxOWRjYjg3MzVkZjIwM2NiMzZmNDUyNzRkMzgyMTI1NDUwMzQ1OGRk
15
- Y2Y1ZGE4ODFmNmY5N2U1ZDMxYTk5Nzk0NmRiN2UxN2Q4YzI4OWY=
13
+ YTE1OTY2YmI0NWQzODM5NDhlZWY2Y2Q1ZDVmOWI0Yzk2YTU3OTU0N2NiYWJk
14
+ OTEyNjlmNjE1NWQ5NDU5NmQ0YjI0MWViYzUyODI2YjY3ZjYwNGM4ZjgzYWQ0
15
+ ODVjOTliYTkwZDUwNmYzMTkzNjA0ODY4Zjc5NGRjZWRkNjk4OWY=
@@ -1,52 +1,52 @@
1
- require 'json'
2
-
3
1
  module Cb
4
2
  module Clients
5
3
  class Application
4
+ class << self
6
5
 
7
- def self.for_job(job)
8
- job.is_a?(Cb::Models::Job) ? did = job.did : did = job
9
- my_api = Cb::Utils::Api.new
10
- json_hash = my_api.cb_get(Cb.configuration.uri_application, :query => {:JobDID => did})
11
-
12
- if json_hash.has_key?('ResponseBlankApplication')
13
- if json_hash['ResponseBlankApplication'].has_key?('BlankApplication')
14
- app = Cb::Models::ApplicationSchema.new(json_hash['ResponseBlankApplication']['BlankApplication'])
15
- end
6
+ def get(criteria)
7
+ response cb_call(:get, criteria)
8
+ end
16
9
 
17
- my_api.append_api_responses(app, json_hash['ResponseBlankApplication'])
10
+ def create(criteria)
11
+ response cb_call(:post, criteria)
18
12
  end
19
13
 
20
- my_api.append_api_responses(app, json_hash)
21
- end
14
+ def update(criteria)
15
+ response cb_call(:put, criteria)
16
+ end
22
17
 
23
- def self.submit_registered_app(app)
24
- return send_to_api(Cb.configuration.uri_application_registered, app)
25
- end
18
+ private
26
19
 
27
- def self.submit_app(app)
28
- return send_to_api(Cb.configuration.uri_application_submit, app)
29
- end
20
+ def cb_call(http_method, criteria)
21
+ options = { headers: headers }
22
+ if [:post, :put].include? http_method
23
+ options[:body] = criteria.to_json
24
+ end
30
25
 
31
- def self.send_to_api(uri, app)
32
- raise Cb::IncomingParamIsWrongTypeException unless app.is_a?(Cb::Models::Application)
26
+ uri = uri(criteria)
27
+ api_client.method(:"cb_#{http_method}").call uri, options
28
+ end
33
29
 
34
- my_api = Cb::Utils::Api.new
35
- json_hash = my_api.cb_post("#{uri}?ipath=#{app.ipath}", :body => app.to_xml)
30
+ def response(response_hash)
31
+ Responses::Application.new response_hash
32
+ end
36
33
 
37
- if json_hash.has_key? 'ResponseApplication'
38
- if json_hash['ResponseApplication'].has_key? 'RedirectURL'
39
- app.redirect_url = json_hash['ResponseApplication']['RedirectURL']
40
- else
41
- app.redirect_url = ''
42
- end
34
+ def uri(criteria)
35
+ did = criteria.respond_to?(:application_did) ? criteria.application_did : ''
36
+ Cb.configuration.uri_application.sub ':did', did
37
+ end
43
38
 
44
- my_api.append_api_responses(app, json_hash['ResponseApplication'])
45
- else
46
- app.redirect_url = ''
39
+ def headers
40
+ {
41
+ 'DeveloperKey' => Cb.configuration.dev_key,
42
+ 'HostSite' => Cb.configuration.host_site,
43
+ 'Content-Type' => 'application/json'
44
+ }
47
45
  end
48
46
 
49
- my_api.append_api_responses(app, json_hash)
47
+ def api_client
48
+ Cb::Utils::Api.new
49
+ end
50
50
  end
51
51
  end
52
52
  end
@@ -4,11 +4,12 @@ module Cb
4
4
  module Clients
5
5
  class Recommendation
6
6
 
7
- def self.for_job(did, countlimit = '25', site_id = '', co_brand = '')
7
+ def self.for_job(*args)
8
8
  my_api = Cb::Utils::Api.new
9
+ hash = normalize_args(args)
10
+ hash = set_hash_defaults(hash)
9
11
  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
+ :query => hash)
12
13
 
13
14
  jobs = []
14
15
  if json_hash.has_key?('ResponseRecommendJob')
@@ -28,11 +29,12 @@ module Cb
28
29
  my_api.append_api_responses(jobs, json_hash)
29
30
  end
30
31
 
31
- def self.for_user(external_id, countlimit = '25', site_id = '', co_brand = '')
32
+ def self.for_user(*args)
32
33
  my_api = Cb::Utils::Api.new
34
+ hash = normalize_args(args)
35
+ hash = set_hash_defaults(hash)
33
36
  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})
37
+ :query => hash)
36
38
 
37
39
  jobs = []
38
40
  if json_hash.has_key?('ResponseRecommendUser')
@@ -71,6 +73,28 @@ module Cb
71
73
  my_api.append_api_responses(jobs, json_hash)
72
74
  end
73
75
 
76
+ private
77
+
78
+ def self.normalize_args(args)
79
+ return args[0] if args[0].class == Hash
80
+ {
81
+ :ExternalID => args[0],
82
+ :JobDID => args[0],
83
+ :CountLimit => args[1] || '25',
84
+ :SiteID => args[2] || "",
85
+ :CoBrand => args[3] || ""
86
+ }
87
+ end
88
+
89
+ def self.set_hash_defaults(hash)
90
+ hash[:CountLimit] ||= '25'
91
+ hash[:HostSite] ||= Cb.configuration.host_site
92
+ hash
93
+ end
94
+
74
95
  end
96
+
97
+
98
+
75
99
  end
76
100
  end
data/lib/cb/config.rb CHANGED
@@ -36,7 +36,7 @@ module Cb
36
36
  @uri_recommendation_for_job ||= '/v1/Recommendations/ForJob'
37
37
  @uri_recommendation_for_user ||= '/v1/Recommendations/ForUser'
38
38
  @uri_recommendation_for_company ||= '/Employer/JobRecommendation'
39
- @uri_application ||= '/v1/application/blank'
39
+ @uri_application ||= '/cbapi/application/:did'
40
40
  @uri_application_submit ||= '/v1/Application/submit'
41
41
  @uri_application_registered ||= '/v3/application/registered'
42
42
  @uri_application_external ||= '/v1/application/external'
@@ -0,0 +1,10 @@
1
+ module Cb
2
+ module Criteria
3
+ module Application
4
+ class CoverLetter
5
+ extend Cb::Utils::FluidAttributes
6
+ fluid_attr_accessor :cover_letter_id, :cover_letter_text, :cover_letter_title
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,42 @@
1
+ module Cb
2
+ module Criteria
3
+ module Application
4
+ class Create
5
+ extend Cb::Utils::FluidAttributes
6
+ fluid_attr_accessor :job_did, :is_submitted, :external_user_id, :vid, :bid, :sid, :site_id, :ipath_id, :tn_did, :resume,
7
+ :cover_letter, :responses
8
+
9
+ def to_json
10
+ {
11
+ JobDID: job_did,
12
+ IsSubmitted: is_submitted,
13
+ ExternalUserID: external_user_id,
14
+ BID: bid,
15
+ SID: sid,
16
+ SiteID: site_id,
17
+ IPathID: ipath_id,
18
+ TNDID: tn_did,
19
+ Resume: {
20
+ ExternalResumeID: resume.external_resume_id,
21
+ ResumeFileName: resume.resume_file_name,
22
+ ResumeData: resume.resume_data,
23
+ ResumeExtension: resume.resume_extension,
24
+ ResumeTitle: resume.resume_title
25
+ },
26
+ CoverLetter: {
27
+ CoverLetterID: cover_letter.cover_letter_id,
28
+ CoverLetterText: cover_letter.cover_letter_text,
29
+ CoverLetterTitle: cover_letter.cover_letter_title
30
+ },
31
+ Responses: responses.map do |response|
32
+ {
33
+ QuestionID: response.question_id,
34
+ ResponseText: response.response_text
35
+ }
36
+ end
37
+ }.to_json
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,10 @@
1
+ module Cb
2
+ module Criteria
3
+ module Application
4
+ class Get
5
+ extend Cb::Utils::FluidAttributes
6
+ fluid_attr_accessor :application_did
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Cb
2
+ module Criteria
3
+ module Application
4
+ class Response
5
+ extend Cb::Utils::FluidAttributes
6
+ fluid_attr_accessor :question_id, :response_text
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Cb
2
+ module Criteria
3
+ module Application
4
+ class Resume
5
+ extend Cb::Utils::FluidAttributes
6
+ fluid_attr_accessor :external_resume_id, :resume_file_name, :resume_data, :resume_extension, :resume_title
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,43 @@
1
+ module Cb
2
+ module Criteria
3
+ module Application
4
+ class Update
5
+ extend Cb::Utils::FluidAttributes
6
+ fluid_attr_accessor :application_did, :job_did, :is_submitted, :external_user_id, :vid, :bid, :sid, :site_id,
7
+ :ipath_id, :tn_did, :resume, :cover_letter, :responses
8
+
9
+ def to_json
10
+ {
11
+ ApplicationDID: application_did,
12
+ JobDID: job_did,
13
+ IsSubmitted: is_submitted,
14
+ ExternalUserID: external_user_id,
15
+ BID: bid,
16
+ SID: sid,
17
+ SiteID: site_id,
18
+ IPathID: ipath_id,
19
+ TNDID: tn_did,
20
+ Resume: {
21
+ ExternalResumeID: resume.external_resume_id,
22
+ ResumeFileName: resume.resume_file_name,
23
+ ResumeData: resume.resume_data,
24
+ ResumeExtension: resume.resume_extension,
25
+ ResumeTitle: resume.resume_title
26
+ },
27
+ CoverLetter: {
28
+ CoverLetterID: cover_letter.cover_letter_id,
29
+ CoverLetterText: cover_letter.cover_letter_text,
30
+ CoverLetterTitle: cover_letter.cover_letter_title
31
+ },
32
+ Responses: responses.map do |response|
33
+ {
34
+ QuestionID: response.question_id,
35
+ ResponseText: response.response_text
36
+ }
37
+ end
38
+ }.to_json
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,92 +1,47 @@
1
1
  module Cb
2
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
3
+ class Application < ApiResponseModel
4
+ attr_accessor :resume, :is_submitted, :vid, :bid, :sid, :site_id, :ipath_id, :application_did, :cover_letter,
5
+ :responses, :tn_did, :external_user_id, :redirect_url
9
6
 
10
- #response params
11
- #redirect_url is returned from the api for shared apply applications.
12
- attr_accessor :redirect_url
7
+ protected
13
8
 
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 = ''
9
+ def required_fields
10
+ %w(Resume IsSubmitted BID ApplicationDID CoverLetter Responses)
26
11
  end
27
12
 
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?
13
+ def set_model_properties
14
+ @resume = extract_resume
15
+ @is_submitted = api_response['IsSubmitted'].to_s == 'true'
16
+ @vid = api_response['VID']
17
+ @bid = api_response['BID']
18
+ @sid = api_response['SID']
19
+ @site_id = api_response['SiteID']
20
+ @ipath_id = api_response['IPathID']
21
+ @application_did = api_response['ApplicationDID']
22
+ @cover_letter = extract_cover_letter
23
+ @responses = extract_responses
24
+ @tn_did = api_response['TNDID']
25
+ @external_user_id = api_response['ExternalUserID']
26
+ @redirect_url = api_response['redirectURL']
38
27
  end
39
28
 
40
- def is_unregistered?
41
- !is_registered?
42
- end
29
+ private
43
30
 
44
- def complete?
45
- cb_response.application_status == 'Complete' || cb_response.application_status == 'Complete (Test)'
31
+ def extract_resume
32
+ Resume.new api_response['Resume']
46
33
  end
47
34
 
48
- def add_answer(id, text)
49
- @answers << Application::Answer.new(id, text)
35
+ def extract_cover_letter
36
+ CoverLetter.new api_response['CoverLetter']
50
37
  end
51
38
 
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>"
39
+ def extract_responses
40
+ api_response['Responses'].map do |response_hash|
41
+ Response.new response_hash
70
42
  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
43
  end
86
44
 
87
- def to_xml
88
- "<Response><QuestionID>#{@id}</QuestionID><ResponseText>#{@text}</ResponseText></Response>"
89
- end
90
45
  end
91
46
  end
92
47
  end
@@ -0,0 +1,22 @@
1
+ module Cb
2
+ module Models
3
+ class Application < ApiResponseModel
4
+ class CoverLetter < ApiResponseModel
5
+ attr_accessor :cover_letter_id, :cover_letter_text, :cover_letter_title
6
+
7
+ protected
8
+
9
+ def required_fields
10
+ []
11
+ end
12
+
13
+ def set_model_properties
14
+ @cover_letter_id = api_response['CoverLetterID']
15
+ @cover_letter_text = api_response['CoverLetterText']
16
+ @cover_letter_title = api_response['CoverLetterTitle']
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ module Cb
2
+ module Models
3
+ class Application < ApiResponseModel
4
+ class Response < ApiResponseModel
5
+ attr_accessor :question_id, :response_text
6
+
7
+ protected
8
+
9
+ def required_fields
10
+ %w(QuestionID ResponseText)
11
+ end
12
+
13
+ def set_model_properties
14
+ @question_id = api_response['QuestionID']
15
+ @response_text = api_response['ResponseText']
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ module Cb
2
+ module Models
3
+ class Application < ApiResponseModel
4
+ class Resume < ApiResponseModel
5
+ attr_accessor :external_resume_id, :resume_file_name, :resume_data, :resume_extension, :resume_title
6
+
7
+ protected
8
+
9
+ def required_fields
10
+ %w(ExternalResumeID)
11
+ end
12
+
13
+ def set_model_properties
14
+ @external_resume_id = api_response['ExternalResumeID']
15
+ @resume_file_name = api_response['ResumeFileName']
16
+ @resume_data = api_response['ResumeData']
17
+ @resume_extension = api_response['ResumeExtension']
18
+ @resume_title = api_response['ResumeTitle']
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -110,6 +110,9 @@ module Cb
110
110
  @company_details_url = figure_out_company_info(args['CompanyDetailsURL'],args['Company'],'CompanyDetailsURL')
111
111
 
112
112
 
113
+ load_extra_fields(args)
114
+
115
+
113
116
  end
114
117
 
115
118
  def find_company
@@ -162,6 +165,12 @@ module Cb
162
165
  end
163
166
  end
164
167
 
168
+ protected
169
+
170
+ def load_extra_fields(args)
171
+ #for internal use only :)
172
+ end
173
+
165
174
  private
166
175
 
167
176
  def figure_out_company_info(job_search, recommendation, rec_key)
@@ -0,0 +1,23 @@
1
+ require 'cb/responses/api_response'
2
+
3
+ module Cb
4
+ module Responses
5
+ class Application < ApiResponse
6
+
7
+ protected
8
+
9
+ def hash_containing_metadata
10
+ response
11
+ end
12
+
13
+ def validate_api_hash
14
+ required_response_field('Results', response)
15
+ end
16
+
17
+ def extract_models
18
+ response['Results'].map { |application_data| Cb::Models::Application.new(application_data) }
19
+ end
20
+
21
+ end
22
+ end
23
+ end
data/lib/cb/utils/api.rb CHANGED
@@ -31,6 +31,14 @@ module Cb
31
31
  validated_response
32
32
  end
33
33
 
34
+ def cb_put(*args, &block)
35
+ self.class.base_uri Cb.configuration.base_uri
36
+ response = self.class.put(*args, &block)
37
+ validated_response = ResponseValidator.validate(response)
38
+ set_api_error(validated_response)
39
+ validated_response
40
+ end
41
+
34
42
  def append_api_responses(obj, resp)
35
43
  meta_class = obj.respond_to?('cb_response') ? obj.cb_response : Cb::Utils::MetaValues.new
36
44
 
data/lib/cb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cb
2
- VERSION = '3.1.1'
2
+ VERSION = '3.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cb-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The CareerBuilder.com Niche and Consumer Development teams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-28 00:00:00.000000000 Z
11
+ date: 2014-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -201,13 +201,21 @@ files:
201
201
  - lib/cb/clients/user.rb
202
202
  - lib/cb/config.rb
203
203
  - lib/cb/convenience.rb
204
+ - lib/cb/criteria/application/cover_letter.rb
205
+ - lib/cb/criteria/application/create.rb
206
+ - lib/cb/criteria/application/get.rb
207
+ - lib/cb/criteria/application/response.rb
208
+ - lib/cb/criteria/application/resume.rb
209
+ - lib/cb/criteria/application/update.rb
204
210
  - lib/cb/criteria/job/details.rb
205
211
  - lib/cb/criteria/spot/retrieve.rb
206
212
  - lib/cb/exceptions.rb
207
213
  - lib/cb/models/api_response_model.rb
214
+ - lib/cb/models/implementations/application/cover_letter.rb
215
+ - lib/cb/models/implementations/application/response.rb
216
+ - lib/cb/models/implementations/application/resume.rb
208
217
  - lib/cb/models/implementations/application.rb
209
218
  - lib/cb/models/implementations/application_external.rb
210
- - lib/cb/models/implementations/application_schema.rb
211
219
  - lib/cb/models/implementations/branding/media.rb
212
220
  - lib/cb/models/implementations/branding/section.rb
213
221
  - lib/cb/models/implementations/branding/style.rb
@@ -235,6 +243,7 @@ files:
235
243
  - lib/cb/responses/anonymous_saved_search/create.rb
236
244
  - lib/cb/responses/anonymous_saved_search/delete.rb
237
245
  - lib/cb/responses/api_response.rb
246
+ - lib/cb/responses/application.rb
238
247
  - lib/cb/responses/employee_types/search.rb
239
248
  - lib/cb/responses/errors.rb
240
249
  - lib/cb/responses/job/singular.rb
@@ -1,75 +0,0 @@
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