cb-api 5.5.0 → 5.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cb/clients/application.rb +1 -1
- data/lib/cb/clients/application_external.rb +1 -1
- data/lib/cb/clients/category.rb +2 -2
- data/lib/cb/clients/company.rb +1 -1
- data/lib/cb/clients/education.rb +1 -1
- data/lib/cb/clients/email_subscription.rb +2 -2
- data/lib/cb/clients/job.rb +1 -1
- data/lib/cb/clients/job_branding.rb +1 -1
- data/lib/cb/clients/recommendation.rb +3 -3
- data/lib/cb/clients/spot.rb +1 -1
- data/lib/cb/clients/talent_network.rb +5 -5
- data/lib/cb/clients/user.rb +4 -4
- data/lib/cb/config.rb +2 -2
- data/lib/cb/models/api_call_model.rb +7 -0
- data/lib/cb/utils/api.rb +28 -2
- data/lib/cb/utils/console_observer.rb +10 -0
- data/lib/cb/version.rb +1 -1
- metadata +5 -3
@@ -7,7 +7,7 @@ module Cb
|
|
7
7
|
def self.submit_app(app)
|
8
8
|
raise Cb::IncomingParamIsWrongTypeException unless app.is_a?(Cb::Models::ApplicationExternal)
|
9
9
|
|
10
|
-
my_api = Cb::Utils::Api.
|
10
|
+
my_api = Cb::Utils::Api.instance
|
11
11
|
xml_hash = my_api.cb_post(Cb.configuration.uri_application_external, :body => app.to_xml)
|
12
12
|
|
13
13
|
if xml_hash.has_key? 'ApplyUrl'
|
data/lib/cb/clients/category.rb
CHANGED
@@ -5,7 +5,7 @@ module Cb
|
|
5
5
|
class Category
|
6
6
|
|
7
7
|
def self.search
|
8
|
-
my_api = Cb::Utils::Api.
|
8
|
+
my_api = Cb::Utils::Api.instance
|
9
9
|
json_hash = my_api.cb_get(Cb.configuration.uri_job_category_search)
|
10
10
|
categoryList = []
|
11
11
|
|
@@ -23,7 +23,7 @@ module Cb
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.search_by_host_site(host_site)
|
26
|
-
my_api = Cb::Utils::Api.
|
26
|
+
my_api = Cb::Utils::Api.instance
|
27
27
|
json_hash = my_api.cb_get(Cb.configuration.uri_job_category_search, :query => {:CountryCode => host_site})
|
28
28
|
categoryList = []
|
29
29
|
|
data/lib/cb/clients/company.rb
CHANGED
@@ -5,7 +5,7 @@ module Cb
|
|
5
5
|
class Company
|
6
6
|
|
7
7
|
def self.find_by_did(did)
|
8
|
-
my_api = Cb::Utils::Api.
|
8
|
+
my_api = Cb::Utils::Api.instance
|
9
9
|
json_hash = my_api.cb_get(Cb.configuration.uri_company_find, :query => {:CompanyDID => did, :hostsite=> Cb.configuration.host_site})
|
10
10
|
|
11
11
|
if json_hash.has_key?('Results')
|
data/lib/cb/clients/education.rb
CHANGED
@@ -6,7 +6,7 @@ module Cb
|
|
6
6
|
|
7
7
|
def self.get_for(country)
|
8
8
|
Cb::Utils::Country.is_valid? country ? country : 'US'
|
9
|
-
my_api = Cb::Utils::Api.
|
9
|
+
my_api = Cb::Utils::Api.instance
|
10
10
|
json_hash = my_api.cb_get(Cb.configuration.uri_education_code, :query => {:countrycode => country})
|
11
11
|
|
12
12
|
codes = []
|
@@ -5,7 +5,7 @@ module Cb
|
|
5
5
|
class EmailSubscription
|
6
6
|
|
7
7
|
def self.retrieve_by_did(did, host_site = '')
|
8
|
-
my_api = Cb::Utils::Api.
|
8
|
+
my_api = Cb::Utils::Api.instance
|
9
9
|
json_hash = my_api.cb_get(Cb.configuration.uri_subscription_retrieve, :query => {:ExternalID => did, :Hostsite => host_site})
|
10
10
|
|
11
11
|
if json_hash.has_key?('SubscriptionValues') && !json_hash['SubscriptionValues'].nil?
|
@@ -26,7 +26,7 @@ module Cb
|
|
26
26
|
job_recs = job_recs.nil? ? 'false' : job_recs
|
27
27
|
unsubscribe_all = unsubscribe_all.nil? ? 'false' : unsubscribe_all
|
28
28
|
|
29
|
-
my_api = Cb::Utils::Api.
|
29
|
+
my_api = Cb::Utils::Api.instance
|
30
30
|
|
31
31
|
xml_body = "<Request>"
|
32
32
|
xml_body += "<DeveloperKey>" + Cb.configuration.dev_key.to_s + "</DeveloperKey>"
|
data/lib/cb/clients/job.rb
CHANGED
@@ -5,7 +5,7 @@ module Cb
|
|
5
5
|
class Recommendation
|
6
6
|
|
7
7
|
def self.for_job(*args)
|
8
|
-
my_api = Cb::Utils::Api.
|
8
|
+
my_api = Cb::Utils::Api.instance
|
9
9
|
hash = normalize_args(args)
|
10
10
|
hash = set_hash_defaults(hash)
|
11
11
|
json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_job,
|
@@ -30,7 +30,7 @@ module Cb
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.for_user(*args)
|
33
|
-
my_api = Cb::Utils::Api.
|
33
|
+
my_api = Cb::Utils::Api.instance
|
34
34
|
hash = normalize_args(args)
|
35
35
|
hash = set_hash_defaults(hash)
|
36
36
|
json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_user,
|
@@ -55,7 +55,7 @@ module Cb
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.for_company(company_did)
|
58
|
-
my_api = Cb::Utils::Api.
|
58
|
+
my_api = Cb::Utils::Api.instance
|
59
59
|
json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_company, :query => {:CompanyDID => company_did})
|
60
60
|
|
61
61
|
jobs = []
|
data/lib/cb/clients/spot.rb
CHANGED
@@ -3,14 +3,14 @@ module Cb
|
|
3
3
|
class TalentNetwork
|
4
4
|
|
5
5
|
def self.join_form_questions(tndid)
|
6
|
-
my_api = Cb::Utils::Api.
|
6
|
+
my_api = Cb::Utils::Api.instance
|
7
7
|
json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_questions}/#{tndid}/json")
|
8
8
|
tn_questions_collection = Models::TalentNetwork.new(json_hash)
|
9
9
|
my_api.append_api_responses(tn_questions_collection, json_hash)
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.join_form_branding(tndid)
|
13
|
-
my_api = Cb::Utils::Api.
|
13
|
+
my_api = Cb::Utils::Api.instance
|
14
14
|
json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_form_branding}/#{tndid}/json")
|
15
15
|
|
16
16
|
if json_hash.has_key? 'Branding'
|
@@ -21,21 +21,21 @@ module Cb
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.join_form_geography(tnlanguage="USEnglish")
|
24
|
-
my_api = Cb::Utils::Api.
|
24
|
+
my_api = Cb::Utils::Api.instance
|
25
25
|
json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_form_geo}", :query => {:TNLanguage => "#{tnlanguage}"})
|
26
26
|
geo_dropdown = Models::TalentNetwork::JoinFormGeo.new(json_hash)
|
27
27
|
my_api.append_api_responses(geo_dropdown, json_hash)
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.member_create(args={})
|
31
|
-
my_api = Cb::Utils::Api.
|
31
|
+
my_api = Cb::Utils::Api.instance
|
32
32
|
tn_member = Models::TalentNetwork::Member.new(args)
|
33
33
|
json_hash = my_api.cb_post("#{Cb.configuration.uri_tn_member_create}/json", :body => tn_member.to_xml )
|
34
34
|
my_api.append_api_responses(json_hash, json_hash)
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.tn_job_information(job_did, join_form_intercept="true")
|
38
|
-
my_api = Cb::Utils::Api.
|
38
|
+
my_api = Cb::Utils::Api.instance
|
39
39
|
json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_job_info}/#{job_did}/json", :query=> {
|
40
40
|
:RequestJoinFormIntercept => join_form_intercept})
|
41
41
|
|
data/lib/cb/clients/user.rb
CHANGED
@@ -18,7 +18,7 @@ module Cb
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def retrieve(external_id, test_mode = false)
|
21
|
-
my_api = Cb::Utils::Api.
|
21
|
+
my_api = Cb::Utils::Api.instance
|
22
22
|
json_hash = my_api.cb_post Cb.configuration.uri_user_retrieve, :body => build_retrieve_request(external_id, true)
|
23
23
|
if json_hash.has_key? 'ResponseUserInfo'
|
24
24
|
if json_hash['ResponseUserInfo'].has_key? 'UserInfo'
|
@@ -32,7 +32,7 @@ module Cb
|
|
32
32
|
|
33
33
|
def change_password(external_id, old_password, new_password, test_mode = false)
|
34
34
|
result = false
|
35
|
-
my_api = Cb::Utils::Api.
|
35
|
+
my_api = Cb::Utils::Api.instance
|
36
36
|
json_hash = my_api.cb_post Cb.configuration.uri_user_change_password, :body => build_change_password_request(external_id, old_password, new_password, test_mode)
|
37
37
|
|
38
38
|
if json_hash.has_key? 'ResponseUserChangePW'
|
@@ -47,7 +47,7 @@ module Cb
|
|
47
47
|
|
48
48
|
def delete(external_id, password, test_mode = false)
|
49
49
|
result = false
|
50
|
-
my_api = Cb::Utils::Api.
|
50
|
+
my_api = Cb::Utils::Api.instance
|
51
51
|
json_hash = my_api.cb_post Cb.configuration.uri_user_delete, :body => build_delete_request(external_id, password, test_mode)
|
52
52
|
|
53
53
|
if json_hash.has_key? 'ResponseUserDelete'
|
@@ -107,7 +107,7 @@ module Cb
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def api_client
|
110
|
-
Cb::Utils::Api.
|
110
|
+
Cb::Utils::Api.instance
|
111
111
|
end
|
112
112
|
|
113
113
|
end
|
data/lib/cb/config.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Cb
|
2
2
|
class Config
|
3
|
-
attr_accessor :dev_key, :base_uri, :debug_api, :time_out, :use_json, :host_site, :test_resources,
|
3
|
+
attr_accessor :dev_key, :base_uri, :debug_api, :time_out, :use_json, :host_site, :test_resources, :observers,
|
4
4
|
:uri_job_search, :uri_job_find,
|
5
5
|
:uri_company_find, :uri_job_category_search,
|
6
6
|
:uri_education_code, :uri_employee_types,
|
@@ -127,7 +127,7 @@ module Cb
|
|
127
127
|
@use_json = true
|
128
128
|
@host_site = Cb.country.US
|
129
129
|
@test_resources = false
|
130
|
-
|
130
|
+
@observers = Array.new
|
131
131
|
set_default_api_uris
|
132
132
|
end
|
133
133
|
end
|
data/lib/cb/utils/api.rb
CHANGED
@@ -1,14 +1,25 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'observer'
|
2
3
|
|
3
4
|
module Cb
|
4
5
|
module Utils
|
5
6
|
class Api
|
6
|
-
include HTTParty
|
7
|
+
include HTTParty, Observable
|
7
8
|
|
8
9
|
base_uri 'https://api.careerbuilder.com'
|
9
10
|
|
11
|
+
def self.instance
|
12
|
+
api = Cb::Utils::Api.new
|
13
|
+
Cb.configuration.observers.each do |class_name|
|
14
|
+
api.add_observer(class_name.new)
|
15
|
+
end
|
16
|
+
if Cb.configuration.debug_api && !Cb.configuration.observers.include?(Cb::Utils::ConsoleObserver)
|
17
|
+
api.add_observer(Cb::Utils::ConsoleObserver.new)
|
18
|
+
end
|
19
|
+
api
|
20
|
+
end
|
21
|
+
|
10
22
|
def initialize
|
11
|
-
self.class.debug_output $stderr if Cb.configuration.debug_api
|
12
23
|
self.class.default_params :developerkey => Cb.configuration.dev_key,
|
13
24
|
:outputjson => Cb.configuration.use_json.to_s
|
14
25
|
|
@@ -18,7 +29,9 @@ module Cb
|
|
18
29
|
|
19
30
|
def cb_get(path, options={})
|
20
31
|
self.class.base_uri Cb.configuration.base_uri
|
32
|
+
cb_event(:cb_get_before, path, options, nil)
|
21
33
|
response = self.class.get(path, options)
|
34
|
+
cb_event(:cb_get_after, path, options, response)
|
22
35
|
validated_response = ResponseValidator.validate(response)
|
23
36
|
set_api_error(validated_response)
|
24
37
|
validated_response
|
@@ -26,7 +39,9 @@ module Cb
|
|
26
39
|
|
27
40
|
def cb_post(path, options={})
|
28
41
|
self.class.base_uri Cb.configuration.base_uri
|
42
|
+
cb_event(:cb_post_before, path, options, nil)
|
29
43
|
response = self.class.post(path, options)
|
44
|
+
cb_event(:cb_post_after, path, options, response)
|
30
45
|
validated_response = ResponseValidator.validate(response)
|
31
46
|
set_api_error(validated_response)
|
32
47
|
validated_response
|
@@ -34,7 +49,9 @@ module Cb
|
|
34
49
|
|
35
50
|
def cb_put(path, options={})
|
36
51
|
self.class.base_uri Cb.configuration.base_uri
|
52
|
+
cb_event(:cb_put_before, path, options, nil)
|
37
53
|
response = self.class.put(path, options)
|
54
|
+
cb_event(:cb_put_after, path, options, response)
|
38
55
|
validated_response = ResponseValidator.validate(response)
|
39
56
|
set_api_error(validated_response)
|
40
57
|
validated_response
|
@@ -88,6 +105,15 @@ module Cb
|
|
88
105
|
|
89
106
|
private
|
90
107
|
|
108
|
+
def api_call_model(api_call_type, path, options, response)
|
109
|
+
Cb::Models::ApiCall.new(api_call_type, path, options, response)
|
110
|
+
end
|
111
|
+
|
112
|
+
def cb_event(api_call_type, path, options, response)
|
113
|
+
changed(true)
|
114
|
+
notify_observers(api_call_model(api_call_type, path, options, response))
|
115
|
+
end
|
116
|
+
|
91
117
|
def ensure_non_nil_metavalues(obj)
|
92
118
|
if obj.respond_to?('cb_response') && !obj.cb_response.nil?
|
93
119
|
obj.cb_response
|
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: 5.5.
|
4
|
+
version: 5.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - ! '>='
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '2.
|
123
|
+
version: '2.14'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,7 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '2.
|
131
|
+
version: '2.14'
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
133
|
name: rdoc
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,6 +258,7 @@ files:
|
|
258
258
|
- lib/cb/models/implementations/talent_network.rb
|
259
259
|
- lib/cb/models/implementations/spot.rb
|
260
260
|
- lib/cb/models/implementations/email_subscription.rb
|
261
|
+
- lib/cb/models/api_call_model.rb
|
261
262
|
- lib/cb/convenience.rb
|
262
263
|
- lib/cb/clients/job_branding.rb
|
263
264
|
- lib/cb/clients/recommendation.rb
|
@@ -278,6 +279,7 @@ files:
|
|
278
279
|
- lib/cb/utils/country.rb
|
279
280
|
- lib/cb/utils/validator.rb
|
280
281
|
- lib/cb/utils/meta_values.rb
|
282
|
+
- lib/cb/utils/console_observer.rb
|
281
283
|
- lib/cb/utils/api.rb
|
282
284
|
- lib/cb/utils/fluid_attributes.rb
|
283
285
|
- README.md
|