spear-cb-api 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spear.rb +1 -0
- data/lib/spear/plugins/model/application.rb +2 -2
- data/lib/spear/plugins/save_apis.rb +20 -17
- data/lib/spear/resource/application.rb +9 -3
- data/lib/spear/structure/application/blank.rb +3 -27
- data/lib/spear/structure/application/embeded_class.rb +37 -0
- data/lib/spear/structure/base.rb +5 -3
- data/lib/spear/structure/job/retrieve.rb +6 -4
- data/lib/spear/structure/job/search.rb +1 -1
- data/lib/spear/structure/resume/create.rb +1 -0
- data/lib/spear/structure/resume/edit.rb +1 -0
- data/lib/spear/structure/resume/ownall.rb +1 -1
- data/lib/spear/structure/resume/parse.rb +4 -3
- data/lib/spear/structure/resume/retrieve.rb +3 -3
- data/lib/spear/structure/talent_network/create_member.rb +1 -0
- data/lib/spear/structure/talent_network/join_form_question.rb +2 -1
- data/lib/spear/structure/user/create.rb +1 -1
- data/lib/spear/structure/user/retrieve.rb +1 -1
- data/lib/spear/version.rb +1 -1
- data/spear-cb-api.gemspec +1 -1
- data/spec/spear_spec.rb +3 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5a83f4e7f44a51494f4a66f6e65008d434cf192
|
4
|
+
data.tar.gz: bfcee02c377283f02f3b23608d960e0cf50d066b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2439d407f3f09937d0307bff8ac13d0603437d8bdb3cc1e4c378a51e1ae8bbd92bc9b1865c2dc5073600771b3fca245371924e0edad10452edde231f4adfc55
|
7
|
+
data.tar.gz: 93433b301c71030366271b41b86a805ef68cac41027b89b24fd3f89cbf24ba1602282d0982932e933837fd26129004cdb87725ae067394ee47851dff53d1dd39
|
data/lib/spear.rb
CHANGED
@@ -36,6 +36,7 @@ module Spear
|
|
36
36
|
end
|
37
37
|
|
38
38
|
module Application
|
39
|
+
autoload :EmbededClass, 'spear/structure/application/embeded_class'
|
39
40
|
autoload :Create, 'spear/structure/application/create'
|
40
41
|
autoload :History, 'spear/structure/application/history'
|
41
42
|
autoload :State, 'spear/structure/application/state'
|
@@ -15,8 +15,8 @@ module Spear
|
|
15
15
|
Structure::Application::Create.new(response)
|
16
16
|
end
|
17
17
|
|
18
|
-
def application_status(
|
19
|
-
response = super(
|
18
|
+
def application_status(ids, email=nil)
|
19
|
+
response = super(ids, email)
|
20
20
|
Structure::Application::State.new(response)
|
21
21
|
end
|
22
22
|
|
@@ -6,7 +6,7 @@ module Spear
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
9
|
-
class_attribute :api_response, :api_started_at, :
|
9
|
+
class_attribute :api_response, :api_started_at, :api_async_job
|
10
10
|
|
11
11
|
before_execute :record_started_time
|
12
12
|
after_execute :save_infos
|
@@ -17,7 +17,7 @@ module Spear
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def save_infos
|
20
|
-
self.
|
20
|
+
self.api_async_job ||= AsyncSaveApi.new
|
21
21
|
|
22
22
|
params = {
|
23
23
|
project: Spear.project,
|
@@ -28,38 +28,41 @@ module Spear
|
|
28
28
|
duration: ((Time.now - self.api_started_at).to_f * 1000.0).to_i
|
29
29
|
}
|
30
30
|
|
31
|
-
params[:request] = self.api_response.request.options[:body]
|
31
|
+
params[:request] = self.api_response.request.options[:body] || self.api_response.request.options[:query]
|
32
32
|
if params[:request].kind_of?(String)
|
33
|
-
params[:request]
|
34
33
|
# parse file api
|
35
|
-
.gsub!(/<FileBytes>(.*?)<\/FileBytes>/m, '<FileBytes>...</FileBytes>')
|
34
|
+
params[:request].gsub!(/<FileBytes>(.*?)<\/FileBytes>/m, '<FileBytes>...</FileBytes>')
|
36
35
|
# apply job api
|
37
|
-
.gsub!(/<ResumeData>(.*?)<\/ResumeData>/m, '<ResumeData>...</ResumeData>')
|
36
|
+
params[:request].gsub!(/<ResumeData>(.*?)<\/ResumeData>/m, '<ResumeData>...</ResumeData>')
|
38
37
|
elsif params[:request].kind_of?(Hash)
|
39
38
|
# upload file api
|
40
39
|
params[:request][:FileBytes] = '...'
|
41
40
|
end
|
42
41
|
|
43
|
-
self.
|
42
|
+
self.api_async_job.async.perform(params)
|
44
43
|
end
|
45
44
|
|
46
45
|
class AsyncSaveApi
|
47
46
|
include SuckerPunch::Job
|
47
|
+
workers 4
|
48
48
|
|
49
49
|
def perform(options={})
|
50
50
|
HTTParty.post(
|
51
51
|
%q{http://ciws.hilotus.com/api/v1/api-info},
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
}
|
60
|
-
|
61
|
-
) rescue options
|
52
|
+
body: {
|
53
|
+
project: options[:project],
|
54
|
+
url: options[:url],
|
55
|
+
method: options[:method],
|
56
|
+
request: options[:request],
|
57
|
+
response: options[:response],
|
58
|
+
duration: options[:duration] }.to_json,
|
59
|
+
options: {headers: {'Content-Type' => 'application/json'}}
|
60
|
+
) rescue nil
|
62
61
|
end
|
62
|
+
|
63
|
+
# def later(sec, data)
|
64
|
+
# after(sec) { perform(data) }
|
65
|
+
# end
|
63
66
|
end
|
64
67
|
|
65
68
|
end
|
@@ -20,9 +20,15 @@ module Spear
|
|
20
20
|
header: {:HostSite => host_site}, body: data}).execute
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
# ids: application_did array, or job_did
|
24
|
+
def application_status(ids, email=nil)
|
25
|
+
if ids.kind_of?(String) and !email.blank?
|
26
|
+
Spear::Request.new(:get, Spear.uri_application_status, {query: {JobDID: ids, Email: email}}).execute
|
27
|
+
elsif ids.kind_of?(Array)
|
28
|
+
Spear::Request.new(:get, Spear.uri_application_status, {query: {AppDID: ids.join(',')}}).execute
|
29
|
+
else
|
30
|
+
raise Spear::ParametersNotValid.new('')
|
31
|
+
end
|
26
32
|
end
|
27
33
|
|
28
34
|
def application_blank(job_did)
|
@@ -2,6 +2,8 @@ module Spear
|
|
2
2
|
module Structure
|
3
3
|
module Application
|
4
4
|
class Blank < Structure::Base
|
5
|
+
include EmbededClass
|
6
|
+
|
5
7
|
attr_reader :job_did, :job_title, :total_questions, :total_required_questions,
|
6
8
|
:application_submit_service_url, :apply_url
|
7
9
|
attr_accessor :questions
|
@@ -19,36 +21,10 @@ module Spear
|
|
19
21
|
@application_submit_service_url = blank_application['ApplicationSubmitServiceURL']
|
20
22
|
@apply_url = blank_application['ApplyURL']
|
21
23
|
|
22
|
-
@questions = generate_questions(blank_application['Questions']['Question'])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class Question
|
27
|
-
attr_accessor :id, :type, :required, :text
|
28
|
-
|
29
|
-
def initialize(id, type, required, text)
|
30
|
-
@id = id
|
31
|
-
@type = type
|
32
|
-
@required = required
|
33
|
-
@text = text
|
24
|
+
@questions = generate_questions(blank_application['Questions']['Question']) rescue nil
|
34
25
|
end
|
35
26
|
end
|
36
27
|
|
37
|
-
private
|
38
|
-
def generate_questions(questions)
|
39
|
-
if !questions.nil?
|
40
|
-
if questions.kind_of?(Array)
|
41
|
-
questions.map {|q|
|
42
|
-
Question.new(q['QuestionID'], q['QuestionType'], q['IsRequired'], q['QuestionText'])
|
43
|
-
}
|
44
|
-
else # Hash
|
45
|
-
[] << Question.new(questions['QuestionID'],
|
46
|
-
questions['QuestionType'], questions['IsRequired'], questions['QuestionText'])
|
47
|
-
end
|
48
|
-
else
|
49
|
-
[]
|
50
|
-
end
|
51
|
-
end
|
52
28
|
end
|
53
29
|
end
|
54
30
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Spear
|
2
|
+
module Structure
|
3
|
+
module Application
|
4
|
+
module EmbededClass
|
5
|
+
##################################################################
|
6
|
+
# Resume embeded class
|
7
|
+
##################################################################
|
8
|
+
class Question
|
9
|
+
attr_accessor :id, :type, :required, :text
|
10
|
+
|
11
|
+
def initialize(id, type, required, text)
|
12
|
+
@id = id
|
13
|
+
@type = type
|
14
|
+
@required = 'true'.eql?(required)
|
15
|
+
@text = text
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_questions(questions)
|
20
|
+
if !questions.nil?
|
21
|
+
if questions.kind_of?(Array)
|
22
|
+
questions.map {|q|
|
23
|
+
Question.new(q['QuestionID'], q['QuestionType'], q['IsRequired'], q['QuestionText'])
|
24
|
+
}
|
25
|
+
else # Hash
|
26
|
+
[] << Question.new(questions['QuestionID'],
|
27
|
+
questions['QuestionType'], questions['IsRequired'], questions['QuestionText'])
|
28
|
+
end
|
29
|
+
else
|
30
|
+
[]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/spear/structure/base.rb
CHANGED
@@ -9,7 +9,7 @@ module Spear
|
|
9
9
|
|
10
10
|
@response = response
|
11
11
|
|
12
|
-
# Application Form
|
12
|
+
# Note: <b>Application Form API</b> return html string.
|
13
13
|
|
14
14
|
if response.kind_of?(Hash)
|
15
15
|
# get the root keyvalue of the hash
|
@@ -19,14 +19,14 @@ module Spear
|
|
19
19
|
@root = response.to_h.first.last
|
20
20
|
end
|
21
21
|
|
22
|
-
# Application
|
22
|
+
# Note: <b>Application Status API</b> is different.
|
23
23
|
@status = @root["Status"] || @root['ApplicationStatus']
|
24
24
|
@error_message = get_error_message(@root)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def success?
|
29
|
-
@status.nil? ? @error_message.nil? : @status.include?('Success')
|
29
|
+
@status.nil? ? @error_message.nil? : (@status.include?('Success') or @status.include?('Complete'))
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
@@ -47,6 +47,8 @@ module Spear
|
|
47
47
|
end
|
48
48
|
elsif hash["Errors"].kind_of?(Array)
|
49
49
|
return hash["Errors"].first
|
50
|
+
elsif hash["Errors"].kind_of?(String)
|
51
|
+
return hash["Errors"]
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
@@ -2,20 +2,22 @@ module Spear
|
|
2
2
|
module Structure
|
3
3
|
module Job
|
4
4
|
class Retrieve < Structure::Base
|
5
|
-
attr_reader :
|
6
|
-
attr_accessor :job_description, :job_requirements, :job_title
|
5
|
+
attr_reader :job_did
|
6
|
+
attr_accessor :job_description, :job_requirements, :job_title, :required_experience, :job_categories
|
7
7
|
|
8
8
|
def initialize(response)
|
9
9
|
super(response)
|
10
10
|
|
11
11
|
if response.class == HTTParty::Response
|
12
|
-
@
|
12
|
+
@job_did = response.request.options[:query][:DID]
|
13
13
|
end
|
14
14
|
|
15
15
|
unless @root["Job"].nil?
|
16
|
+
@job_title = @root["Job"]["JobTitle"]
|
16
17
|
@job_description = @root["Job"]["JobDescription"]
|
17
18
|
@job_requirements = @root["Job"]["JobRequirements"]
|
18
|
-
@
|
19
|
+
@experience_required = @root["Job"]["ExperienceRequired"]
|
20
|
+
@job_categories = @root["Job"]["Categories"]
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -12,13 +12,14 @@ module Spear
|
|
12
12
|
|
13
13
|
def initialize(response)
|
14
14
|
super(response)
|
15
|
+
|
15
16
|
@resume = @root['Resume'] || {}
|
16
17
|
@hrxml_resume = @resume['HRXMLResume']
|
17
18
|
|
18
19
|
@resume_text = @resume['ResumeText'] || ''
|
19
|
-
@total_years_experience =
|
20
|
-
@educations = generate_educations(@resume['Educations'])
|
21
|
-
@company_experiences = generate_experiences(@resume['CompanyExperiences'])
|
20
|
+
@total_years_experience = @resume['TotalYearsExperience'].to_i rescue 0
|
21
|
+
@educations = generate_educations(@resume['Educations']) rescue nil
|
22
|
+
@company_experiences = generate_experiences(@resume['CompanyExperiences']) rescue nil
|
22
23
|
end
|
23
24
|
|
24
25
|
def hash_for_create(external_user_id, host_site)
|
@@ -11,9 +11,9 @@ module Spear
|
|
11
11
|
|
12
12
|
@resume = @root['Resume']
|
13
13
|
@title = @resume['Title']
|
14
|
-
@total_years_experience =
|
15
|
-
@educations = generate_educations(@resume['Educations'])
|
16
|
-
@company_experiences = generate_experiences(@resume['CompanyExperiences'])
|
14
|
+
@total_years_experience = @resume['TotalYearsExperience'].to_i rescue 0
|
15
|
+
@educations = generate_educations(@resume['Educations']) rescue nil
|
16
|
+
@company_experiences = generate_experiences(@resume['CompanyExperiences']) rescue nil
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -5,9 +5,9 @@ module Spear
|
|
5
5
|
attr_reader :external_id
|
6
6
|
attr_accessor :email, :first_name, :last_name, :phone
|
7
7
|
|
8
|
-
# http://api.careerbuilder.com/UserInfo.aspx
|
9
8
|
def initialize(response)
|
10
9
|
super(response)
|
10
|
+
|
11
11
|
@user_info = @root['UserInfo']
|
12
12
|
@external_id = @root['Request']['ExternalID']
|
13
13
|
@email = @user_info['Email']
|
data/lib/spear/version.rb
CHANGED
data/spear-cb-api.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.add_dependency "builder", "~> 3.2"
|
19
19
|
spec.add_dependency "activesupport", "~> 4.2"
|
20
20
|
spec.add_dependency "activemodel", "~> 4.2"
|
21
|
-
spec.add_dependency "sucker_punch", "~> 1.
|
21
|
+
spec.add_dependency "sucker_punch", "~> 1.4"
|
22
22
|
spec.add_dependency "httparty", "~> 0.13"
|
23
23
|
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.2"
|
data/spec/spear_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
describe Spear do
|
2
2
|
before :each do
|
3
|
-
Spear.config({dev_key: 'xxx', project: '
|
3
|
+
Spear.config({dev_key: 'xxx', project: 'ExampleApp', use_model: true})
|
4
4
|
end
|
5
5
|
|
6
6
|
it "check user existing" do
|
@@ -49,7 +49,8 @@ describe Spear do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "get application status" do
|
52
|
-
s = Spear.application_status(['JAWS4L16LFXD7ZL87LLC', 'JAWW63876DWNQGSWZ384', 'JA4M44C77CDSR0QHTRJ6'])
|
52
|
+
# s = Spear.application_status(['JAWS4L16LFXD7ZL87LLC', 'JAWW63876DWNQGSWZ384', 'JA4M44C77CDSR0QHTRJ6'])
|
53
|
+
s = Spear.application_status('JAWW63876DWNQGSWZ384', 'fei.zhang@sina.com.cn')
|
53
54
|
puts s.response
|
54
55
|
end
|
55
56
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spear-cb-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CBluowei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.4'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: httparty
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- lib/spear/resources.rb
|
197
197
|
- lib/spear/structure/application/blank.rb
|
198
198
|
- lib/spear/structure/application/create.rb
|
199
|
+
- lib/spear/structure/application/embeded_class.rb
|
199
200
|
- lib/spear/structure/application/history.rb
|
200
201
|
- lib/spear/structure/application/state.rb
|
201
202
|
- lib/spear/structure/application/submit.rb
|