cb-api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cb.rb +2 -0
- data/lib/cb/clients/application_api.rb +10 -5
- data/lib/cb/models/cb_application.rb +21 -0
- data/lib/cb/utils/api.rb +2 -1
- data/lib/cb/version.rb +1 -1
- metadata +2 -2
data/lib/cb.rb
CHANGED
@@ -12,6 +12,8 @@ Dir[File.dirname(__FILE__) + '/cb/criteria/*.rb'].each {| file| require file }
|
|
12
12
|
Dir[File.dirname(__FILE__) + '/cb/models/*.rb'].each {| file| require file }
|
13
13
|
|
14
14
|
module Cb
|
15
|
+
class IncomingParamIsWrongTypeException < StandardError; end
|
16
|
+
|
15
17
|
def self.configure
|
16
18
|
yield configuration
|
17
19
|
end
|
@@ -11,6 +11,7 @@ module Cb
|
|
11
11
|
#############################################################
|
12
12
|
def self.for_job(job)
|
13
13
|
did = job.did if job.is_a?(Cb::CbJob) else did = job
|
14
|
+
|
14
15
|
my_api = Cb::Utils::Api.new()
|
15
16
|
cb_response = my_api.cb_get(Cb.configuration.uri_application, :query => {:JobDID => did})
|
16
17
|
json_hash = JSON.parse(cb_response.response.body)
|
@@ -27,12 +28,13 @@ module Cb
|
|
27
28
|
## http://api.careerbuilder.com/ApplicationInfo.aspx
|
28
29
|
#############################################################
|
29
30
|
def self.submit_registered_app(app)
|
31
|
+
raise Cb::IncomingParamIsWrongTypeException unless app.is_a?(Cb::CbApplication)
|
32
|
+
|
30
33
|
my_api = Cb::Utils::Api.new()
|
31
|
-
cb_response = my_api.cb_post(Cb.configuration.uri_application_registered, :body => app)
|
34
|
+
cb_response = my_api.cb_post(Cb.configuration.uri_application_registered, :body => app.to_xml)
|
32
35
|
|
33
36
|
json_hash = JSON.parse(cb_response.response.body)
|
34
37
|
begin
|
35
|
-
json_hash = JSON.parse(cb_response.response.body)
|
36
38
|
status = json_hash['ResponseApplication']['ApplicationStatus'] == 'Complete (Test)' unless json_hash.empty?
|
37
39
|
rescue
|
38
40
|
status = false
|
@@ -48,10 +50,13 @@ module Cb
|
|
48
50
|
## http://api.careerbuilder.com/ApplicationInfo.aspx
|
49
51
|
#############################################################
|
50
52
|
def self.submit_app(app)
|
53
|
+
raise Cb::IncomingParamIsWrongTypeException unless app.is_a?(Cb::CbApplication)
|
54
|
+
|
51
55
|
my_api = Cb::Utils::Api.new()
|
52
|
-
|
53
|
-
|
54
|
-
|
56
|
+
xml_hash = my_api.cb_post(Cb.configuration.uri_application_submit, :body => app.to_xml)
|
57
|
+
my_api.append_api_responses(app, xml_hash['ResponseApplication'])
|
58
|
+
|
59
|
+
return app
|
55
60
|
end
|
56
61
|
end
|
57
62
|
end
|
@@ -19,7 +19,24 @@ module Cb
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_xml
|
22
|
+
ret = '<RequestApplication>'
|
22
23
|
|
24
|
+
ret = "#{ret}<DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>"
|
25
|
+
ret = "#{ret}<JobDID>#{@job_did}</JobDID>"
|
26
|
+
ret = "#{ret}<Test>#{@test}</Test>"
|
27
|
+
ret = "#{ret}<SiteID>#{@site_id}</SiteID>"
|
28
|
+
ret = "#{ret}<CoBrand>#{@co_brand}</CoBrand>"
|
29
|
+
ret = "#{ret}<Resume><ResumeFileName>#{@resume_file_name}</ResumeFileName><ResumeData>#{@resume}</ResumeData></Resume>" unless @resume.nil?
|
30
|
+
|
31
|
+
unless @answers.count == 0
|
32
|
+
ret = "#{ret}<Responses>"
|
33
|
+
@answers.each do | ans |
|
34
|
+
ret = "#{ret}#{ans.to_xml}"
|
35
|
+
end
|
36
|
+
ret = "#{ret}</Responses>"
|
37
|
+
end
|
38
|
+
|
39
|
+
"#{ret}</RequestApplication>"
|
23
40
|
end
|
24
41
|
end # CbApplication
|
25
42
|
|
@@ -31,5 +48,9 @@ module Cb
|
|
31
48
|
@id = id
|
32
49
|
@text = text
|
33
50
|
end
|
51
|
+
|
52
|
+
def to_xml
|
53
|
+
"<Response><QuestionID>#{@id}</QuestionID><ResponseText>#{@text}</ResponseText></Response>"
|
54
|
+
end
|
34
55
|
end # CbAnswer
|
35
56
|
end # Cb
|
data/lib/cb/utils/api.rb
CHANGED
@@ -87,7 +87,8 @@ module Cb::Utils
|
|
87
87
|
'CoBrand' => 'co_brand',
|
88
88
|
'CountLimit' => 'count_limit',
|
89
89
|
'MinQualityLimit' => 'min_quality',
|
90
|
-
'RecommendationsAvailable' => 'recs_available'
|
90
|
+
'RecommendationsAvailable' => 'recs_available',
|
91
|
+
'ApplicationStatus' => 'application_status'
|
91
92
|
}
|
92
93
|
|
93
94
|
key_map["#{api_key}"] ||= ''
|
data/lib/cb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cb-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-05-
|
14
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|