cb-api 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cb.rb +2 -2
- data/lib/cb/clients/application_api.rb +61 -0
- data/lib/cb/config.rb +9 -6
- data/lib/cb/models/cb_app.rb +39 -0
- data/lib/cb/utils/api.rb +5 -0
- data/lib/cb/version.rb +1 -1
- metadata +6 -3
- data/lib/cb/clients/job_application_api.rb +0 -35
data/lib/cb.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module Cb
|
5
|
+
class ApplicationApi
|
6
|
+
#############################################################
|
7
|
+
## Get an application for a job
|
8
|
+
##
|
9
|
+
## For detailed information around this API please visit:
|
10
|
+
## http://api.careerbuilder.com/ApplicationInfo.aspx
|
11
|
+
#############################################################
|
12
|
+
def self.for_job(did)
|
13
|
+
my_api = Cb::Utils::Api.new()
|
14
|
+
cb_response = my_api.cb_get(Cb.configuration.uri_application, :query => {:JobDID => did})
|
15
|
+
json_hash = JSON.parse(cb_response.response.body)
|
16
|
+
app_info = CbApp.new(json_hash['ResponseBlankApplication']['BlankApplication']['Questions'])
|
17
|
+
my_api.append_api_responses(app_info, json_hash['ResponseBlankApplication'])
|
18
|
+
return {:json_hash => json_hash, :app_info => app_info}
|
19
|
+
end
|
20
|
+
|
21
|
+
#############################################################
|
22
|
+
## Submit a job application for a registered user
|
23
|
+
##
|
24
|
+
## For detailed information around this API please visit:
|
25
|
+
## http://api.careerbuilder.com/ApplicationInfo.aspx
|
26
|
+
#############################################################
|
27
|
+
|
28
|
+
def self.submit_registered_app(request_xml)
|
29
|
+
my_api = Cb::Utils::Api.new()
|
30
|
+
cb_response = my_api.cb_post(Cb.configuration.uri_application_registered, :body => request_xml)
|
31
|
+
|
32
|
+
json_hash = JSON.parse(cb_response.response.body)
|
33
|
+
status = false
|
34
|
+
begin
|
35
|
+
json_hash = JSON.parse(cb_response.response.body)
|
36
|
+
if json_hash.empty? == false
|
37
|
+
status = json_hash['ResponseApplication']['ApplicationStatus'] == 'Complete (Test)'
|
38
|
+
end
|
39
|
+
rescue
|
40
|
+
status = false
|
41
|
+
end
|
42
|
+
|
43
|
+
return status
|
44
|
+
end
|
45
|
+
|
46
|
+
#############################################################
|
47
|
+
## Submit a job application
|
48
|
+
##
|
49
|
+
## For detailed information around this API please visit:
|
50
|
+
## http://api.careerbuilder.com/ApplicationInfo.aspx
|
51
|
+
#############################################################
|
52
|
+
|
53
|
+
def self.submit_app(request_xml)
|
54
|
+
my_api = Cb::Utils::Api.new()
|
55
|
+
cb_response = my_api.cb_post(Cb.configuration.uri_application_submit, :body => request_xml)
|
56
|
+
json_hash = cb_response.parsed_response
|
57
|
+
status = json_hash['ResponseApplication']['ApplicationStatus'] == 'Complete (Test)'
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/cb/config.rb
CHANGED
@@ -6,8 +6,8 @@ module Cb
|
|
6
6
|
:uri_education_code, :uri_employee_types,
|
7
7
|
:uri_recommendation_for_job, :uri_recommendation_for_user,
|
8
8
|
:uri_recommendation_for_company,
|
9
|
-
:
|
10
|
-
|
9
|
+
:uri_application, :uri_application_submit,
|
10
|
+
:uri_application_registered, :job_did
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
Cb::Utils::Country.inject_convenience_methods
|
@@ -24,8 +24,9 @@ module Cb
|
|
24
24
|
@uri_recommendation_for_job ||= '/v1/Recommendations/ForJob'
|
25
25
|
@uri_recommendation_for_user ||= '/v1/Recommendations/ForUser'
|
26
26
|
@uri_recommendation_for_company ||= '/Employer/JobRecommendation'
|
27
|
-
@
|
28
|
-
|
27
|
+
@uri_application ||= '/v1/application/blank'
|
28
|
+
@uri_application_submit ||= '/v1/Application/submit'
|
29
|
+
@uri_application_registered ||= '/v3/Application/registered'
|
29
30
|
end
|
30
31
|
|
31
32
|
def to_hash
|
@@ -43,8 +44,10 @@ module Cb
|
|
43
44
|
:uri_recommendation_for_job => @uri_recommendation_for_job,
|
44
45
|
:uri_recommendation_for_user => @uri_recommendation_for_user,
|
45
46
|
:uri_recommendation_for_company => @uri_recommendation_for_company,
|
46
|
-
:
|
47
|
-
|
47
|
+
:uri_application => @uri_application,
|
48
|
+
:uri_application_submit => @uri_application_submit,
|
49
|
+
:uri_application_registered => @uri_application_registered,
|
50
|
+
:job_did => @job_did
|
48
51
|
}
|
49
52
|
end
|
50
53
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Cb
|
2
|
+
class CbApp
|
3
|
+
attr_accessor :response_blank_app, :blank_app, :did, :submit_service_url,
|
4
|
+
:apply_url, :title,
|
5
|
+
:total_questions, :total_required_questions,
|
6
|
+
:question_id, :is_required, :question_type, :expected_response_format,
|
7
|
+
:question_text
|
8
|
+
#################################################################
|
9
|
+
## This general purpose object stores anything having to do with
|
10
|
+
## an application. The API objects dealing with application,
|
11
|
+
## will populate one or many of this object.
|
12
|
+
#################################################################
|
13
|
+
|
14
|
+
def initialize(args = {})
|
15
|
+
|
16
|
+
# App related
|
17
|
+
@response_blank_app = args['ResponseBlankApplication'] || ''
|
18
|
+
@blank_app = args['BlankApplication'] || ''
|
19
|
+
|
20
|
+
# Job Info related
|
21
|
+
@did = args['DID'] || args['JobDID'] || ''
|
22
|
+
@title = args['JobTitle'] || ''
|
23
|
+
|
24
|
+
# Job Details related
|
25
|
+
@submit_service_url = args['ApplicationSubmitServiceURL'] || ''
|
26
|
+
@apply_url = args['ApplyURL'] || ''
|
27
|
+
|
28
|
+
|
29
|
+
# Question related
|
30
|
+
@total_questions = args['TotalQuestions'] || ''
|
31
|
+
@total_required_questions = args['TotalRequiredQuestions'] || ''
|
32
|
+
@question_id = args['QuestionID'] || ''
|
33
|
+
@is_required = args['IsRequired'] || ''
|
34
|
+
@question_type = args['QuestionType'] || ''
|
35
|
+
@question_text = args['QuestionText'] || ''
|
36
|
+
@expected_response_format = args['ExpectedResponseFormat'] || ''
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/cb/utils/api.rb
CHANGED
@@ -17,6 +17,11 @@ module Cb::Utils
|
|
17
17
|
self.class.get(*args, &block)
|
18
18
|
end
|
19
19
|
|
20
|
+
def cb_post(*args, &block)
|
21
|
+
self.class.base_uri 'https://api.careerbuilder.com'
|
22
|
+
self.class.post(*args, &block)
|
23
|
+
end
|
24
|
+
|
20
25
|
def append_api_responses(obj, resp)
|
21
26
|
if obj.respond_to?('cb_response')
|
22
27
|
meta_class = obj.cb_response
|
data/lib/cb/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cb-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jesse Retchko
|
9
9
|
- Chris Little
|
10
|
+
- Miriam Williams
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2013-05-
|
14
|
+
date: 2013-05-07 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: httparty
|
@@ -48,19 +49,21 @@ description: Ruby wrapper for Careerbuilder Public API.
|
|
48
49
|
email:
|
49
50
|
- Jesse.Retchko@Careerbuilder.com
|
50
51
|
- Chris.Little@Careerbuilder.com
|
52
|
+
- MiriamDeana@gmail.com
|
51
53
|
executables: []
|
52
54
|
extensions: []
|
53
55
|
extra_rdoc_files: []
|
54
56
|
files:
|
57
|
+
- lib/cb/clients/application_api.rb
|
55
58
|
- lib/cb/clients/category_api.rb
|
56
59
|
- lib/cb/clients/company_api.rb
|
57
60
|
- lib/cb/clients/education_api.rb
|
58
61
|
- lib/cb/clients/employee_types_api.rb
|
59
62
|
- lib/cb/clients/job_api.rb
|
60
|
-
- lib/cb/clients/job_application_api.rb
|
61
63
|
- lib/cb/clients/recommendation_api.rb
|
62
64
|
- lib/cb/config.rb
|
63
65
|
- lib/cb/job_search_criteria.rb
|
66
|
+
- lib/cb/models/cb_app.rb
|
64
67
|
- lib/cb/models/cb_category.rb
|
65
68
|
- lib/cb/models/cb_company.rb
|
66
69
|
- lib/cb/models/cb_education.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module Cb
|
4
|
-
class JobApplicationApi
|
5
|
-
#############################################################
|
6
|
-
## Get job application information
|
7
|
-
##
|
8
|
-
## For detailed information around this API please visit:
|
9
|
-
## http://api.careerbuilder.com/ApplicationInfo.aspx
|
10
|
-
#############################################################
|
11
|
-
|
12
|
-
def self.get_for(job_did, site_id = '', co_brand = '')
|
13
|
-
my_api = Cb::Utils::Api.new()
|
14
|
-
cb_response = my_api.cb_get(Cb.configuration.uri_job_application, :query => {:JobDID => job_did, :SiteID => site_id, :CoBrand => co_brand})
|
15
|
-
json_hash = JSON.parse(cb_response.response.body)
|
16
|
-
|
17
|
-
job_application = CbJobApplication.new(json_hash['ResponseBlankApplication']['BlankApplication'])
|
18
|
-
my_api.append_api_responses(job_application, json_hash['ResponseBlankApplication'])
|
19
|
-
|
20
|
-
return job_application
|
21
|
-
end
|
22
|
-
|
23
|
-
#############################################################
|
24
|
-
## Submit a job application
|
25
|
-
##
|
26
|
-
## For detailed information around this API please visit:
|
27
|
-
## http://api.careerbuilder.com/ApplicationInfo.aspx
|
28
|
-
#############################################################
|
29
|
-
|
30
|
-
# def self.submit(did)
|
31
|
-
|
32
|
-
# end
|
33
|
-
|
34
|
-
end # JobApplicationApi
|
35
|
-
end # Cb
|