cb-api 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cb/models/implementations/cb_saved_search.rb +9 -3
- data/lib/cb/utils/api.rb +12 -27
- data/lib/cb/version.rb +1 -1
- metadata +3 -3
@@ -3,10 +3,10 @@ module Cb
|
|
3
3
|
class CbSavedSearch
|
4
4
|
attr_accessor :hostsite, :cobrand, :site_id, :search_name, :boolean_operator, :category, :education_code, :specific_education,
|
5
5
|
:emp_type, :exclude_company_names, :exclude_job_titles, :exclude_national, :industry_codes,
|
6
|
-
:keywords, :order_by, :order_direction, :radius, :pay_high, :pay_low, :posted_within,
|
6
|
+
:keywords, :order_by, :order_direction, :radius, :pay_high, :pay_low, :posted_within,
|
7
7
|
:pay_info_only, :location, :job_category, :company, :city, :state, :is_daily_email, :external_id,
|
8
8
|
:external_user_id, :dev_key, :job_search_url, :jrdid, :errors, :browser_id, :session_id, :test, :email_address,
|
9
|
-
:saved_search_parameters
|
9
|
+
:saved_search_parameters, :country
|
10
10
|
|
11
11
|
def initialize(args={})
|
12
12
|
@hostsite = args['HostSite'] || ''
|
@@ -47,6 +47,7 @@ module Cb
|
|
47
47
|
@session_id = args['SessionID'] || ''
|
48
48
|
@test = args['Test'].to_s || false
|
49
49
|
@email_address = args['EmailAddress'] || ''
|
50
|
+
@country = args['Country'] || ''
|
50
51
|
if args.has_key?('SavedSearchParameters')
|
51
52
|
unless args['SavedSearchParameters'].empty?
|
52
53
|
@saved_search_parameters = CbSavedSearch.new(args['SavedSearchParameters'])
|
@@ -57,7 +58,8 @@ module Cb
|
|
57
58
|
class CbSavedSearchParameters
|
58
59
|
attr_accessor :boolean_operator, :category, :education_code, :emp_type, :exclude_company_names, :exclude_job_titles,
|
59
60
|
:exclude_keywords, :exclude_national, :industry_codes, :job_title, :keywords, :location, :order_by,
|
60
|
-
:order_direction, :pay_high, :pay_info_only, :pay_low, :posted_within, :radius, :specific_education
|
61
|
+
:order_direction, :pay_high, :pay_info_only, :pay_low, :posted_within, :radius, :specific_education,
|
62
|
+
:country
|
61
63
|
|
62
64
|
def initialize(args = {})
|
63
65
|
@boolean_operator = args['BooleanOperator'] || ''
|
@@ -80,6 +82,7 @@ module Cb
|
|
80
82
|
@posted_within = args['PostedWithin'] || 30
|
81
83
|
@radius = args['Radius'] || 30
|
82
84
|
@specific_education = args['SpecificEducation'] || false
|
85
|
+
@country = args['Country'] || ''
|
83
86
|
end
|
84
87
|
end #CbSavedSearchParameters
|
85
88
|
|
@@ -111,6 +114,7 @@ module Cb
|
|
111
114
|
ret += "<Company>#{@company}</Company>"
|
112
115
|
ret += "<City>#{@city}</City>"
|
113
116
|
ret += "<State>#{@state}</State>"
|
117
|
+
ret += "<Country>#{@country}</Country>"
|
114
118
|
ret += "</SearchParameters>"
|
115
119
|
ret += "<IsDailyEmail>#{@is_daily_email.upcase}</IsDailyEmail>"
|
116
120
|
ret += "<ExternalUserID>#{@external_user_id}</ExternalUserID>"
|
@@ -152,6 +156,7 @@ module Cb
|
|
152
156
|
ret += "<Company>#{@company}</Company>"
|
153
157
|
ret += "<City>#{@city}</City>"
|
154
158
|
ret += "<State>#{@state}</State>"
|
159
|
+
ret += "<Country>#{@country}</Country>"
|
155
160
|
ret += "</SearchParameters>"
|
156
161
|
ret += "<IsDailyEmail>#{@is_daily_email.upcase}</IsDailyEmail>"
|
157
162
|
ret += "<DeveloperKey>#{@dev_key}</DeveloperKey>"
|
@@ -188,6 +193,7 @@ module Cb
|
|
188
193
|
ret += "<Company>#{@company}</Company>"
|
189
194
|
ret += "<City>#{@city}</City>"
|
190
195
|
ret += "<State>#{@state}</State>"
|
196
|
+
ret += "<Country>#{@country}</Country>"
|
191
197
|
ret += "</SearchParameters>"
|
192
198
|
ret += "<IsDailyEmail>#{@is_daily_email}</IsDailyEmail>"
|
193
199
|
ret += "<ExternalID>#{@external_id}</ExternalID>"
|
data/lib/cb/utils/api.rb
CHANGED
@@ -20,8 +20,7 @@ module Cb
|
|
20
20
|
response = self.class.get(*args, &block)
|
21
21
|
validated_response = ResponseValidator.validate(response)
|
22
22
|
set_api_error(validated_response)
|
23
|
-
|
24
|
-
return validated_response
|
23
|
+
validated_response
|
25
24
|
end
|
26
25
|
|
27
26
|
def cb_post(*args, &block)
|
@@ -29,19 +28,14 @@ module Cb
|
|
29
28
|
response = self.class.post(*args, &block)
|
30
29
|
validated_response = ResponseValidator.validate(response)
|
31
30
|
set_api_error(validated_response)
|
32
|
-
|
33
|
-
return validated_response
|
31
|
+
validated_response
|
34
32
|
end
|
35
33
|
|
36
34
|
def append_api_responses(obj, resp)
|
37
|
-
|
38
|
-
meta_class = obj.cb_response
|
39
|
-
else
|
40
|
-
meta_class = Cb::Utils::MetaValues.new()
|
41
|
-
end
|
35
|
+
meta_class = obj.respond_to?('cb_response') ? obj.cb_response : Cb::Utils::MetaValues.new
|
42
36
|
|
43
|
-
resp.each do |
|
44
|
-
meta_name =
|
37
|
+
resp.each do |api_key, api_value|
|
38
|
+
meta_name = format_hash_key(api_key)
|
45
39
|
unless meta_name.empty?
|
46
40
|
if meta_name == 'errors' && api_value.is_a?(Hash)
|
47
41
|
api_value = api_value.values
|
@@ -76,7 +70,7 @@ module Cb
|
|
76
70
|
params["#{var_name_hash_safe}"] = criteria.instance_variable_get(var)
|
77
71
|
end
|
78
72
|
end
|
79
|
-
|
73
|
+
params
|
80
74
|
end
|
81
75
|
|
82
76
|
def self.is_numeric?(obj)
|
@@ -84,29 +78,20 @@ module Cb
|
|
84
78
|
end
|
85
79
|
|
86
80
|
private
|
87
|
-
|
81
|
+
|
88
82
|
def self.camelize(input)
|
89
83
|
input.sub!(/^[a-z\d]*/) { $&.capitalize }
|
90
84
|
input.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$2.capitalize}" }.gsub('/', '::')
|
91
85
|
end
|
92
86
|
|
93
87
|
def set_api_error(validated_response)
|
94
|
-
|
95
|
-
@api_error = false
|
96
|
-
else
|
97
|
-
@api_error = true
|
98
|
-
end
|
88
|
+
@api_error = validated_response.keys.empty?
|
99
89
|
end
|
100
90
|
|
101
|
-
def
|
102
|
-
|
103
|
-
|
104
|
-
'RecommendationsAvailable' => 'recs_available',
|
105
|
-
api_key => api_key.snakecase
|
106
|
-
}
|
107
|
-
|
108
|
-
key_map["#{api_key}"] ||= ''
|
91
|
+
def format_hash_key(api_hash_key)
|
92
|
+
return String.new unless api_hash_key.respond_to?(:snakecase)
|
93
|
+
api_hash_key.snakecase
|
109
94
|
end
|
110
95
|
end
|
111
96
|
end
|
112
|
-
end
|
97
|
+
end
|
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: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -19,7 +19,7 @@ authors:
|
|
19
19
|
autorequire:
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
|
-
date: 2013-11-
|
22
|
+
date: 2013-11-25 00:00:00.000000000 Z
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
name: httparty
|
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
248
|
version: '0'
|
249
249
|
requirements: []
|
250
250
|
rubyforge_project:
|
251
|
-
rubygems_version: 1.8.
|
251
|
+
rubygems_version: 1.8.24
|
252
252
|
signing_key:
|
253
253
|
specification_version: 3
|
254
254
|
summary: Ruby wrapper around Careerbuilder Public API.
|