spear-cb-api 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/spear.rb +5 -0
- data/lib/spear/configuration.rb +11 -7
- data/lib/spear/plugins/model/application.rb +12 -0
- data/lib/spear/plugins/model/job.rb +2 -0
- data/lib/spear/plugins/model/resume.rb +2 -0
- data/lib/spear/plugins/model/talent_network.rb +11 -0
- data/lib/spear/plugins/model/user.rb +2 -0
- data/lib/spear/request.rb +34 -25
- data/lib/spear/resource/application.rb +5 -6
- data/lib/spear/resource/job.rb +2 -4
- data/lib/spear/resource/resume.rb +12 -32
- data/lib/spear/resource/talent_network.rb +4 -17
- data/lib/spear/resource/user.rb +4 -25
- data/lib/spear/resources.rb +4 -5
- data/lib/spear/structure/application/create.rb +19 -0
- data/lib/spear/structure/application/history.rb +11 -0
- data/lib/spear/structure/base.rb +5 -1
- data/lib/spear/structure/job/embeded_class.rb +0 -1
- data/lib/spear/structure/job/retrieve.rb +4 -1
- data/lib/spear/structure/job/search.rb +4 -1
- data/lib/spear/structure/talent_network/create_member.rb +15 -0
- data/lib/spear/structure/talent_network/embeded_class.rb +36 -0
- data/lib/spear/structure/talent_network/join_form_question.rb +17 -0
- data/lib/spear/version.rb +1 -1
- data/spec/spear_spec.rb +26 -6
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99a2043f153e08a27aca5f2460d0c8e740f54820
|
4
|
+
data.tar.gz: b6860970868165b0524d84f8405e7ce141e99234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a0125557056f2a98096a3b604523e38259adfa5303c112bdfc2b2a27ac302f1e5291c61b3679ee1a1c04b43321a9ac60bf207cc1e71847c78312cd0700967e6
|
7
|
+
data.tar.gz: 4a62e65fe56416e23b67c06270f6f099f5f51bc7e6261816b4635b71da873fc42d01dbb44363efa2da8c2449be101b8140af49280e2e0b5681de4846e6fb7cdc
|
data/lib/spear.rb
CHANGED
@@ -36,6 +36,8 @@ module Spear
|
|
36
36
|
end
|
37
37
|
|
38
38
|
module Application
|
39
|
+
autoload :Create, 'spear/structure/application/create'
|
40
|
+
autoload :History, 'spear/structure/application/history'
|
39
41
|
end
|
40
42
|
|
41
43
|
module Job
|
@@ -45,6 +47,9 @@ module Spear
|
|
45
47
|
end
|
46
48
|
|
47
49
|
module TalentNetwork
|
50
|
+
autoload :EmbededClass, 'spear/structure/talent_network/embeded_class'
|
51
|
+
autoload :CreateMember, 'spear/structure/talent_network/create_member'
|
52
|
+
autoload :JoinFormQuestion, 'spear/structure/talent_network/join_form_question'
|
48
53
|
end
|
49
54
|
end
|
50
55
|
|
data/lib/spear/configuration.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
module Spear
|
2
2
|
module Configuration
|
3
|
-
include Resources
|
4
|
-
|
5
3
|
@@options = {}
|
6
4
|
|
7
5
|
# use https or http
|
8
6
|
def ssh?
|
9
|
-
@@options[:use_ssh]
|
7
|
+
@@options[:use_ssh].nil? ? true : @@options[:use_ssh]
|
10
8
|
end
|
11
9
|
|
12
10
|
def hostname
|
@@ -22,7 +20,7 @@ module Spear
|
|
22
20
|
end
|
23
21
|
|
24
22
|
def test?
|
25
|
-
@@options[:use_test]
|
23
|
+
@@options[:use_test].nil? ? false : @@options[:use_test]
|
26
24
|
end
|
27
25
|
|
28
26
|
def dev_key
|
@@ -31,11 +29,11 @@ module Spear
|
|
31
29
|
|
32
30
|
# need save api info
|
33
31
|
def save_api?
|
34
|
-
@@options[:saving_api]
|
32
|
+
@@options[:saving_api].nil? ? false : @@options[:saving_api]
|
35
33
|
end
|
36
34
|
|
37
35
|
def use_model?
|
38
|
-
@@options[:using_model]
|
36
|
+
@@options[:using_model].nil? ? false : @@options[:using_model]
|
39
37
|
end
|
40
38
|
|
41
39
|
def project
|
@@ -59,7 +57,13 @@ module Spear
|
|
59
57
|
private
|
60
58
|
def include_plugins
|
61
59
|
Request.include Plugins::SaveApis if save_api?
|
62
|
-
|
60
|
+
|
61
|
+
if use_model?
|
62
|
+
Spear.extend Plugins::Models
|
63
|
+
else
|
64
|
+
Spear.extend Resources
|
65
|
+
end
|
66
|
+
|
63
67
|
# Spear.extend Dummy if use_dummy?
|
64
68
|
end
|
65
69
|
|
@@ -2,6 +2,18 @@ module Spear
|
|
2
2
|
module Plugins
|
3
3
|
module Model
|
4
4
|
module Application
|
5
|
+
include Resource::Application
|
6
|
+
|
7
|
+
def history(user_external_id)
|
8
|
+
response = super(user_external_id)
|
9
|
+
Structure::Application::History.new(response)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Application Creation
|
13
|
+
def create_application(host_site, data={})
|
14
|
+
response = super(host_site, data)
|
15
|
+
Structure::Application::Create.new(response)
|
16
|
+
end
|
5
17
|
end
|
6
18
|
end
|
7
19
|
end
|
@@ -2,6 +2,17 @@ module Spear
|
|
2
2
|
module Plugins
|
3
3
|
module Model
|
4
4
|
module TalentNetwork
|
5
|
+
include Resource::TalentNetwork
|
6
|
+
|
7
|
+
def join_form_questions(talent_network_did)
|
8
|
+
response = super(talent_network_did)
|
9
|
+
Structure::TalentNetwork::JoinFormQuestion.new(response)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_member(data={})
|
13
|
+
response = super(data)
|
14
|
+
Structure::TalentNetwork::CreateMember.new(response)
|
15
|
+
end
|
5
16
|
end
|
6
17
|
end
|
7
18
|
end
|
data/lib/spear/request.rb
CHANGED
@@ -6,11 +6,21 @@ module Spear
|
|
6
6
|
extend ActiveModel::Callbacks
|
7
7
|
define_model_callbacks :execute, :only => [:before, :after]
|
8
8
|
|
9
|
+
attr_accessor :method, :query, :body, :api_options, :url
|
10
|
+
|
9
11
|
# params: {:body => {}, :query => {}, :api_options => {}}
|
10
12
|
# exp: api_options: {:path => "/v1"}
|
11
|
-
def
|
13
|
+
def initialize(method, endpoint, params={})
|
14
|
+
@method = method
|
15
|
+
@query = params[:query] || {}
|
16
|
+
@body = params[:body] || {}
|
17
|
+
@api_options = params[:api_options] || {}
|
18
|
+
@url = generate_resource + endpoint
|
19
|
+
end
|
20
|
+
|
21
|
+
def execute
|
12
22
|
run_callbacks(:execute) {
|
13
|
-
response = exec
|
23
|
+
response = exec
|
14
24
|
begin
|
15
25
|
self.api_response = response
|
16
26
|
rescue NoMethodError => e # if we don't use save api info plugin, it'll throw NoMethodError.
|
@@ -20,24 +30,19 @@ module Spear
|
|
20
30
|
end
|
21
31
|
|
22
32
|
private
|
23
|
-
def exec
|
24
|
-
query = params[:query] || {}
|
25
|
-
body = params[:body] || {}
|
26
|
-
api_options = params[:api_options] || {}
|
27
|
-
url = generate_resource(api_options) + endpoint
|
28
|
-
|
33
|
+
def exec
|
29
34
|
begin
|
30
|
-
case method
|
35
|
+
case @method
|
31
36
|
when :get
|
32
|
-
HTTParty.get(url, query: splice_query
|
37
|
+
HTTParty.get(@url, query: splice_query)
|
33
38
|
when :post
|
34
|
-
HTTParty.post(url, body: splice_body
|
39
|
+
HTTParty.post(@url, body: splice_body, query: @query)
|
35
40
|
when :upload_file
|
36
|
-
HTTParty.post(url, body: body, query: splice_query
|
41
|
+
HTTParty.post(@url, body: @body, query: splice_query)
|
37
42
|
when :parse_file
|
38
|
-
HTTParty.post(url, body: splice_body
|
43
|
+
HTTParty.post(@url, body: splice_body)
|
39
44
|
when :apply
|
40
|
-
HTTParty.post(url, body: to_xml(body), query: splice_query
|
45
|
+
HTTParty.post(@url, body: to_xml(@body), query: splice_query)
|
41
46
|
else
|
42
47
|
raise Spear::ParametersNotValid.new("#{method} is not support.")
|
43
48
|
end
|
@@ -47,27 +52,27 @@ module Spear
|
|
47
52
|
end
|
48
53
|
|
49
54
|
# generate cb api host and version
|
50
|
-
def generate_resource
|
55
|
+
def generate_resource
|
51
56
|
uri = URI("")
|
52
57
|
uri.scheme = Spear.ssh? ? 'https' : 'http'
|
53
58
|
uri.host = Spear.hostname
|
54
59
|
uri.port = Spear.port
|
55
60
|
|
56
61
|
# Some api endpoint have no version and fixed pattern.
|
57
|
-
if api_options[:path].nil?
|
62
|
+
if @api_options[:path].nil?
|
58
63
|
uri.path = "/#{Spear.version}"
|
59
64
|
else
|
60
|
-
uri.path = "
|
65
|
+
uri.path = "#{@api_options[:path]}"
|
61
66
|
end
|
62
67
|
|
63
68
|
uri.to_s
|
64
69
|
end
|
65
70
|
|
66
71
|
# splice request body
|
67
|
-
def splice_body
|
68
|
-
body[:DeveloperKey] = Spear.dev_key
|
69
|
-
body[:Test] = Spear.test?
|
70
|
-
|
72
|
+
def splice_body
|
73
|
+
@body[:DeveloperKey] = Spear.dev_key
|
74
|
+
@body[:Test] = Spear.test? if need_test_key?
|
75
|
+
to_xml(@body)
|
71
76
|
end
|
72
77
|
|
73
78
|
# parse body from hash to xml format
|
@@ -76,10 +81,14 @@ module Spear
|
|
76
81
|
end
|
77
82
|
|
78
83
|
# splice query(url params) {:query => {}} with DeveloperKey and Test
|
79
|
-
def splice_query
|
80
|
-
query[:DeveloperKey] = Spear.dev_key
|
81
|
-
query[:Test] = Spear.test?
|
82
|
-
query
|
84
|
+
def splice_query
|
85
|
+
@query[:DeveloperKey] = Spear.dev_key
|
86
|
+
@query[:Test] = Spear.test? if need_test_key?
|
87
|
+
@query
|
88
|
+
end
|
89
|
+
|
90
|
+
def need_test_key?
|
91
|
+
@api_options[:need_test_key].nil? ? true : @api_options[:need_test_key]
|
83
92
|
end
|
84
93
|
|
85
94
|
end
|
@@ -1,21 +1,20 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Spear
|
4
2
|
module Resource
|
5
3
|
module Application
|
6
4
|
def history(user_external_id)
|
7
5
|
raise Spear::ParametersRequired.new('UserExternalId') if user_external_id.blank?
|
8
6
|
|
9
|
-
Spear::Request.new
|
10
|
-
{query: {:ExternalID => user_external_id}, api_options: {path: 'v1'}})
|
7
|
+
Spear::Request.new(:get, "/application/history",
|
8
|
+
{query: {:ExternalID => user_external_id}, api_options: {path: '/v1'}}).execute
|
11
9
|
end
|
12
10
|
|
13
11
|
# Application Creation
|
14
12
|
def create_application(host_site, data={})
|
15
13
|
raise Spear::ParametersRequired.new('HostSite') if host_site.blank?
|
14
|
+
raise Spear::ParametersRequired.new(%w{JobID Resume Responses}) if data[:JobDID].blank? or data[:Resume].nil? or data[:Responses].nil?
|
16
15
|
|
17
|
-
Spear::Request.new
|
18
|
-
{query: {:HostSite => host_site}, body: data, api_options: {path: ""}})
|
16
|
+
Spear::Request.new(:apply, '',
|
17
|
+
{query: {:HostSite => host_site}, body: data, api_options: {path: "/cbapi/application"}}).execute
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
data/lib/spear/resource/job.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Spear
|
4
2
|
module Resource
|
5
3
|
module Job
|
6
4
|
def search_job(params={})
|
7
|
-
Spear::Request.new
|
5
|
+
Spear::Request.new(:get, "/jobsearch", {:query => params}).execute
|
8
6
|
end
|
9
7
|
|
10
8
|
# job_id:
|
@@ -13,7 +11,7 @@ module Spear
|
|
13
11
|
def retrieve_job(job_id)
|
14
12
|
raise Spear::ParametersRequired.new('JobID') if job_id.blank?
|
15
13
|
|
16
|
-
Spear::Request.new
|
14
|
+
Spear::Request.new(:get, "/job", {:query => {:DID => job_id}}).execute
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Spear
|
4
2
|
module Resource
|
5
3
|
module Resume
|
@@ -10,40 +8,22 @@ module Spear
|
|
10
8
|
end
|
11
9
|
|
12
10
|
file.rewind
|
13
|
-
Spear::Request.new
|
11
|
+
Spear::Request.new(:post, "/resume/parse", {
|
14
12
|
:body => {
|
15
13
|
:FileName => file.original_filename,
|
16
14
|
:FileBytes => Base64.encode64(file.read)
|
17
15
|
}
|
18
|
-
})
|
16
|
+
}).execute
|
19
17
|
end
|
20
18
|
|
21
|
-
# {
|
22
|
-
# ShowContactInfo: true,
|
23
|
-
# Title: 'asasdasdasd',
|
24
|
-
# ResumeText: 'albee009@gmail.com JobsCentral999',
|
25
|
-
# Visibility: true,
|
26
|
-
# CanRelocateNationally: false,
|
27
|
-
# CanRelocateInternationally: false,
|
28
|
-
# TotalYearsExperience: 1,
|
29
|
-
# HostSite: 'T3',
|
30
|
-
# DesiredJobTypes: 'ETFE',
|
31
|
-
# CompanyExperiences: [],
|
32
|
-
# Educations: [],
|
33
|
-
# Languages: [],
|
34
|
-
# CustomValues: []
|
35
|
-
# }
|
36
19
|
def create_resume(data={})
|
37
|
-
Spear::Request.new
|
20
|
+
Spear::Request.new(:post, "/resume/create", {body: data}).execute
|
38
21
|
end
|
39
22
|
|
40
|
-
# {
|
41
|
-
# ...
|
42
|
-
# # if editting, we should add this column
|
43
|
-
# ExternalID: 'asdasdsdaas'
|
44
|
-
# }
|
45
23
|
def edit_resume(data={})
|
46
|
-
Spear::
|
24
|
+
raise Spear::ParametersRequired.new('Resume ExternalId') if data[:ExternalID].blank?
|
25
|
+
|
26
|
+
Spear::Request.new(:post, "/resume/edit", {body: data}).execute
|
47
27
|
end
|
48
28
|
|
49
29
|
def upload_file(file, resume_external_id, user_external_id)
|
@@ -54,7 +34,7 @@ module Spear
|
|
54
34
|
raise Spear::ParametersRequired.new(%w{UserExternalId ResumeExternalId}) if user_external_id.blank? or resume_external_id.blank?
|
55
35
|
|
56
36
|
file.rewind
|
57
|
-
Spear::Request.new
|
37
|
+
Spear::Request.new(:upload_file, "/resume/upload", {
|
58
38
|
:body => {
|
59
39
|
:FileBytes => Base64.encode64(file.read)
|
60
40
|
},
|
@@ -63,22 +43,22 @@ module Spear
|
|
63
43
|
:ExternalID => resume_external_id,
|
64
44
|
:ExternalUserID => user_external_id
|
65
45
|
}
|
66
|
-
})
|
46
|
+
}).execute
|
67
47
|
end
|
68
48
|
|
69
49
|
# list all of my resumes
|
70
50
|
def own_all(user_external_id, host_site)
|
71
51
|
raise Spear::ParametersRequired.new(%w{UserExternalId HostSite}) if user_external_id.blank? or host_site.blank?
|
72
52
|
|
73
|
-
Spear::Request.new
|
74
|
-
:query => {:ExternalUserID => user_external_id, :HostSite => host_site}})
|
53
|
+
Spear::Request.new(:get, "/resume/ownall", {
|
54
|
+
:query => {:ExternalUserID => user_external_id, :HostSite => host_site}}).execute
|
75
55
|
end
|
76
56
|
|
77
57
|
def retrieve_resume(resume_external_id, user_external_id)
|
78
58
|
raise Spear::ParametersRequired.new(%w{UserExternalId ResumeExternalId}) if user_external_id.blank? or resume_external_id.blank?
|
79
59
|
|
80
|
-
Spear::Request.new
|
81
|
-
:query => {:ExternalUserID => user_external_id, :ExternalID => resume_external_id}})
|
60
|
+
Spear::Request.new(:get, "/resume/retrieve", {
|
61
|
+
:query => {:ExternalUserID => user_external_id, :ExternalID => resume_external_id}}).execute
|
82
62
|
end
|
83
63
|
end
|
84
64
|
end
|
@@ -1,29 +1,16 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Spear
|
4
2
|
module Resource
|
5
3
|
module TalentNetwork
|
6
4
|
def join_form_questions(talent_network_did)
|
7
5
|
raise Spear::ParametersRequired.new('TalentNetworkDID') if talent_network_did.blank?
|
8
6
|
|
9
|
-
Spear::Request.new
|
10
|
-
{api_options: {path: ""}})
|
7
|
+
Spear::Request.new(:get, '',
|
8
|
+
{api_options: {path: "/talentnetwork/config/join/questions/#{talent_network_did}/json"}}).execute
|
11
9
|
end
|
12
10
|
|
13
|
-
# {
|
14
|
-
# TalentNetworkDID: 'YourTalentNetworkDID',
|
15
|
-
# PreferredLanguage: 'USEnglish',
|
16
|
-
# AcceptPrivacy: '',
|
17
|
-
# AcceptTerms: '',
|
18
|
-
# ResumeWordDoc: '',
|
19
|
-
# JoinValues: [
|
20
|
-
# {Key: 'MxDOTalentNetworkMemberInfo_EmailAddress', Value: 'some.email@example.com'},
|
21
|
-
# {Key: 'JQ7I3CM6P9B09VCVD9YF', Value: 'AVAILABLENOW'}
|
22
|
-
# ]
|
23
|
-
# }
|
24
11
|
def create_member(data={})
|
25
|
-
Spear::Request.new
|
26
|
-
{
|
12
|
+
Spear::Request.new(:post, '', {api_options:
|
13
|
+
{path: "/talentnetwork/member/create/json", :need_test_key => false}, body: data}).execute
|
27
14
|
end
|
28
15
|
end
|
29
16
|
end
|
data/lib/spear/resource/user.rb
CHANGED
@@ -1,41 +1,20 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Spear
|
4
2
|
module Resource
|
5
3
|
module User
|
6
4
|
def check_existing(email, password='')
|
7
5
|
if password.blank?
|
8
|
-
Spear::Request.new
|
6
|
+
Spear::Request.new(:post, "/user/checkexisting", {body: {:Email => email}}).execute
|
9
7
|
else
|
10
|
-
Spear::Request.new
|
8
|
+
Spear::Request.new(:post, "/user/checkexisting", {body: {:Email => email, :Password => password}}).execute
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
14
|
-
# {
|
15
|
-
# FirstName: 'asdasdad',
|
16
|
-
# LastName: 'asdasdad',
|
17
|
-
# Email: 'ascacasc@sina.com.cn',
|
18
|
-
# Password: 'Qwer1234!',
|
19
|
-
# Phone: '+657777888999',
|
20
|
-
# City: 'Singapore',
|
21
|
-
# State: 'SG',
|
22
|
-
# CountryCode: 'SG',
|
23
|
-
# AllowNewsletterEmails: false,
|
24
|
-
# HostSite: 'T3',
|
25
|
-
# AllowPartnerEmails: false,
|
26
|
-
# AllowEventEmails: false,
|
27
|
-
# SendEmail: false,
|
28
|
-
# Gender: 'U',
|
29
|
-
# UserType: 'jobseeker',
|
30
|
-
# Status: 'active',
|
31
|
-
# Test: false
|
32
|
-
# }
|
33
12
|
def create_user(data={})
|
34
|
-
Spear::Request.new
|
13
|
+
Spear::Request.new(:post, "/user/create", {body: data}).execute
|
35
14
|
end
|
36
15
|
|
37
16
|
def retrieve_user(user_external_id, password)
|
38
|
-
Spear::Request.new
|
17
|
+
Spear::Request.new(:post, "/user/retrieve", {body: {:ExternalID => user_external_id, :Password => password}}).execute
|
39
18
|
end
|
40
19
|
end
|
41
20
|
end
|
data/lib/spear/resources.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Spear
|
4
2
|
module Resources
|
5
|
-
include Resource::User
|
6
|
-
include Resource::Resume
|
7
3
|
include Resource::Application
|
8
4
|
include Resource::Job
|
5
|
+
include Resource::Resume
|
6
|
+
include Resource::TalentNetwork
|
7
|
+
include Resource::User
|
9
8
|
end
|
10
|
-
end
|
9
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spear
|
2
|
+
module Structure
|
3
|
+
module Application
|
4
|
+
class Create < Structure::Base
|
5
|
+
attr_reader :total_results, :returned_results
|
6
|
+
|
7
|
+
attr_accessor :results
|
8
|
+
|
9
|
+
def initialize(response)
|
10
|
+
super(response)
|
11
|
+
|
12
|
+
@total_results = @root["TotalResults"]
|
13
|
+
@returned_results = @root["ReturnedResults"]
|
14
|
+
@results = @root["Results"]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/spear/structure/base.rb
CHANGED
@@ -9,7 +9,11 @@ module Spear
|
|
9
9
|
|
10
10
|
@response = response
|
11
11
|
# get the root keyvalue of the hash
|
12
|
-
|
12
|
+
if response.to_h.has_key?('Errors')
|
13
|
+
@root = response.to_h
|
14
|
+
else
|
15
|
+
@root = response.to_h.first.last
|
16
|
+
end
|
13
17
|
@status = @root["Status"]
|
14
18
|
@error_message = get_error_message(@root)
|
15
19
|
end
|
@@ -7,7 +7,10 @@ module Spear
|
|
7
7
|
|
8
8
|
def initialize(response)
|
9
9
|
super(response)
|
10
|
-
|
10
|
+
|
11
|
+
if response.kind_of?(HTTParty::Response)
|
12
|
+
@job_id = response.request.options[:query][:DID]
|
13
|
+
end
|
11
14
|
|
12
15
|
unless @root["Job"].nil?
|
13
16
|
@job_description = @root["Job"]["JobDescription"]
|
@@ -9,7 +9,10 @@ module Spear
|
|
9
9
|
|
10
10
|
def initialize(response)
|
11
11
|
super(response)
|
12
|
-
|
12
|
+
|
13
|
+
if response.kind_of?(HTTParty::Response)
|
14
|
+
@tn_did = response.request.options[:query][:TalentNetworkDID]
|
15
|
+
end
|
13
16
|
|
14
17
|
job_search_result = @root['Results'].nil? ? [] : @root['Results']['JobSearchResult']
|
15
18
|
@jobs = generate_jobs(job_search_result, @tn_did)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Spear
|
2
|
+
module Structure
|
3
|
+
module TalentNetwork
|
4
|
+
module EmbededClass
|
5
|
+
##################################################################
|
6
|
+
# Resume embeded class
|
7
|
+
##################################################################
|
8
|
+
class JoinQuestion
|
9
|
+
attr_accessor :text, :required, :form_value, :option_display_type, :order, :options
|
10
|
+
|
11
|
+
def initialize(question)
|
12
|
+
@text = question['Text']
|
13
|
+
@required = question['Required']
|
14
|
+
@form_value = question['FormValue']
|
15
|
+
@option_display_type = question['OptionDisplayType']
|
16
|
+
@order = question['Order']
|
17
|
+
@options = question['Options']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def generate_questions(questions)
|
22
|
+
if !questions.nil?
|
23
|
+
if questions.kind_of?(Array)
|
24
|
+
questions.map {|question| JoinQuestion.new(question)}
|
25
|
+
else # Hash
|
26
|
+
[JoinQuestion.new(questions)]
|
27
|
+
end
|
28
|
+
else
|
29
|
+
[]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Spear
|
2
|
+
module Structure
|
3
|
+
module TalentNetwork
|
4
|
+
class JoinFormQuestion < Structure::Base
|
5
|
+
include EmbededClass
|
6
|
+
|
7
|
+
attr_accessor :join_questions
|
8
|
+
|
9
|
+
def initialize(response)
|
10
|
+
super(response)
|
11
|
+
@join_questions = generate_questions(@root["JoinQuestions"])
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/spear/version.rb
CHANGED
data/spec/spear_spec.rb
CHANGED
@@ -5,26 +5,46 @@ describe Spear do
|
|
5
5
|
|
6
6
|
it "check user existing" do
|
7
7
|
s = Spear.check_existing('zhangfei@163.com.cn', '111111111')
|
8
|
-
puts s
|
8
|
+
puts s.response
|
9
9
|
end
|
10
10
|
|
11
11
|
it "application history" do
|
12
12
|
s = Spear.history('XRHR3NV6S8SK6DJ0GKSD')
|
13
|
-
puts s
|
13
|
+
puts s.response
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'search job' do
|
17
17
|
s = Spear.search_job({:TalentNetworkDID => 'TN818G76D6YWYNBXHB3Z', :SiteEntity => 'TalentNetworkJob', :CountryCode => 'IN'})
|
18
|
-
puts s.
|
18
|
+
puts s.response
|
19
19
|
end
|
20
20
|
|
21
21
|
it "retrieve job" do
|
22
22
|
s = Spear.retrieve_job('J3J4BP6MGVH2DJZ6MJH')
|
23
|
-
puts s.
|
23
|
+
puts s.response
|
24
24
|
end
|
25
25
|
|
26
26
|
it "create application" do
|
27
|
-
s = Spear.create_application('IN')
|
28
|
-
puts s
|
27
|
+
s = Spear.create_application('IN', {JobDID: 'xxx', Resume: {ResumeTitle: 'title'}, Responses: [{QuestionID: 'id', ResponseText: 'text'}]})
|
28
|
+
puts s.response
|
29
|
+
end
|
30
|
+
|
31
|
+
it "tn join form question" do
|
32
|
+
s = Spear.join_form_questions('TN818G76D6YWYNBXHB3Z')
|
33
|
+
puts s.response
|
34
|
+
end
|
35
|
+
|
36
|
+
it "tn create member" do
|
37
|
+
s = Spear.create_member({
|
38
|
+
TalentNetworkDID: 'TN818G76D6YWYNBXHB3Z',
|
39
|
+
PreferredLanguage: 'USEnglish',
|
40
|
+
AcceptPrivacy: false,
|
41
|
+
AcceptTerms: false,
|
42
|
+
ResumeWordDoc: '',
|
43
|
+
JoinValues: [
|
44
|
+
{Key: 'MxDOTalentNetworkMemberInfo_EmailAddress', Value: 'some.email@example.com'},
|
45
|
+
{Key: 'JQ7I3CM6P9B09VCVD9YF', Value: 'AVAILABLENOW'}
|
46
|
+
]
|
47
|
+
})
|
48
|
+
puts s.response
|
29
49
|
end
|
30
50
|
end
|
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.6
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -158,6 +158,8 @@ files:
|
|
158
158
|
- lib/spear/resource/talent_network.rb
|
159
159
|
- lib/spear/resource/user.rb
|
160
160
|
- lib/spear/resources.rb
|
161
|
+
- lib/spear/structure/application/create.rb
|
162
|
+
- lib/spear/structure/application/history.rb
|
161
163
|
- lib/spear/structure/base.rb
|
162
164
|
- lib/spear/structure/job/embeded_class.rb
|
163
165
|
- lib/spear/structure/job/retrieve.rb
|
@@ -169,6 +171,9 @@ files:
|
|
169
171
|
- lib/spear/structure/resume/parse.rb
|
170
172
|
- lib/spear/structure/resume/retrieve.rb
|
171
173
|
- lib/spear/structure/resume/upload.rb
|
174
|
+
- lib/spear/structure/talent_network/create_member.rb
|
175
|
+
- lib/spear/structure/talent_network/embeded_class.rb
|
176
|
+
- lib/spear/structure/talent_network/join_form_question.rb
|
172
177
|
- lib/spear/structure/user/check_existing.rb
|
173
178
|
- lib/spear/structure/user/create.rb
|
174
179
|
- lib/spear/structure/user/retrieve.rb
|