cb-api 17.4.0 → 18.0.0
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/CHANGELOG.md +1 -0
- data/CONTRIBUTING.md +18 -0
- data/LICENSE +202 -0
- data/README.md +3 -1
- data/lib/cb.rb +12 -2
- data/lib/cb/client.rb +10 -0
- data/lib/cb/clients/anon_saved_search.rb +12 -4
- data/lib/cb/clients/application.rb +10 -2
- data/lib/cb/clients/application_external.rb +13 -5
- data/lib/cb/clients/category.rb +16 -8
- data/lib/cb/clients/company.rb +16 -8
- data/lib/cb/clients/education.rb +17 -9
- data/lib/cb/clients/employee_types.rb +11 -3
- data/lib/cb/clients/industry.rb +12 -3
- data/lib/cb/clients/job.rb +10 -2
- data/lib/cb/clients/job_branding.rb +13 -5
- data/lib/cb/clients/recommendation.rb +27 -18
- data/lib/cb/clients/saved_search.rb +21 -15
- data/lib/cb/clients/talent_network.rb +20 -12
- data/lib/cb/clients/user.rb +22 -14
- data/lib/cb/config.rb +64 -54
- data/lib/cb/convenience.rb +22 -13
- data/lib/cb/criteria/application/cover_letter.rb +10 -0
- data/lib/cb/criteria/application/create.rb +11 -1
- data/lib/cb/criteria/application/get.rb +10 -0
- data/lib/cb/criteria/application/response.rb +10 -0
- data/lib/cb/criteria/application/resume.rb +10 -0
- data/lib/cb/criteria/application/update.rb +10 -0
- data/lib/cb/criteria/job/details.rb +11 -1
- data/lib/cb/criteria/resumes/get_by_hash.rb +12 -2
- data/lib/cb/criteria/user/change_password.rb +21 -11
- data/lib/cb/criteria/user/delete.rb +18 -11
- data/lib/cb/exceptions.rb +14 -4
- data/lib/cb/models/api_call_model.rb +10 -1
- data/lib/cb/models/api_response_model.rb +15 -7
- data/lib/cb/models/implementations/application.rb +10 -1
- data/lib/cb/models/implementations/application/cover_letter.rb +10 -1
- data/lib/cb/models/implementations/application/form.rb +13 -5
- data/lib/cb/models/implementations/application/response.rb +10 -1
- data/lib/cb/models/implementations/application/resume.rb +10 -1
- data/lib/cb/models/implementations/application_external.rb +12 -3
- data/lib/cb/models/implementations/branding/media.rb +10 -2
- data/lib/cb/models/implementations/branding/section.rb +10 -2
- data/lib/cb/models/implementations/branding/style.rb +10 -2
- data/lib/cb/models/implementations/branding/styles/base.rb +12 -4
- data/lib/cb/models/implementations/branding/styles/buttons.rb +10 -2
- data/lib/cb/models/implementations/branding/styles/company_info.rb +11 -3
- data/lib/cb/models/implementations/branding/styles/container.rb +11 -3
- data/lib/cb/models/implementations/branding/styles/content.rb +10 -2
- data/lib/cb/models/implementations/branding/styles/css_adapter.rb +10 -2
- data/lib/cb/models/implementations/branding/styles/headings.rb +10 -2
- data/lib/cb/models/implementations/branding/styles/job_details.rb +10 -2
- data/lib/cb/models/implementations/branding/styles/page.rb +10 -2
- data/lib/cb/models/implementations/branding/widget.rb +10 -2
- data/lib/cb/models/implementations/category.rb +17 -7
- data/lib/cb/models/implementations/collapsed_job_results.rb +10 -1
- data/lib/cb/models/implementations/collapsed_jobs.rb +10 -0
- data/lib/cb/models/implementations/company.rb +17 -10
- data/lib/cb/models/implementations/data_lists/resume_data_list.rb +11 -1
- data/lib/cb/models/implementations/education.rb +10 -0
- data/lib/cb/models/implementations/email_subscription.rb +10 -0
- data/lib/cb/models/implementations/employee_type.rb +14 -4
- data/lib/cb/models/implementations/industry.rb +14 -6
- data/lib/cb/models/implementations/job.rb +24 -20
- data/lib/cb/models/implementations/job_branding.rb +13 -5
- data/lib/cb/models/implementations/job_results.rb +10 -2
- data/lib/cb/models/implementations/job_results_v3.rb +11 -1
- data/lib/cb/models/implementations/recommended_job.rb +10 -0
- data/lib/cb/models/implementations/resume.rb +11 -1
- data/lib/cb/models/implementations/resume_document.rb +10 -0
- data/lib/cb/models/implementations/resume_listing.rb +11 -1
- data/lib/cb/models/implementations/resumes/country_code.rb +10 -0
- data/lib/cb/models/implementations/resumes/education.rb +11 -1
- data/lib/cb/models/implementations/resumes/government_and_military.rb +11 -1
- data/lib/cb/models/implementations/resumes/language_code.rb +12 -2
- data/lib/cb/models/implementations/resumes/relocation.rb +11 -1
- data/lib/cb/models/implementations/resumes/salary_information.rb +11 -2
- data/lib/cb/models/implementations/resumes/skills_and_qualifications.rb +10 -0
- data/lib/cb/models/implementations/resumes/work_experience.rb +11 -1
- data/lib/cb/models/implementations/saved_search.rb +83 -73
- data/lib/cb/models/implementations/state.rb +11 -2
- data/lib/cb/models/implementations/talent_network.rb +44 -36
- data/lib/cb/models/implementations/user.rb +12 -2
- data/lib/cb/models/implementations/work_status.rb +12 -3
- data/lib/cb/requests/anonymous_saved_search/create.rb +10 -2
- data/lib/cb/requests/anonymous_saved_search/delete.rb +10 -2
- data/lib/cb/requests/application/create.rb +10 -1
- data/lib/cb/requests/application/form.rb +10 -2
- data/lib/cb/requests/application/get.rb +10 -1
- data/lib/cb/requests/application/update.rb +10 -1
- data/lib/cb/requests/application/utils.rb +10 -1
- data/lib/cb/requests/application_external/submit_application.rb +10 -2
- data/lib/cb/requests/base.rb +13 -5
- data/lib/cb/requests/category/search.rb +10 -2
- data/lib/cb/requests/company/find.rb +12 -4
- data/lib/cb/requests/data_lists/countries.rb +10 -0
- data/lib/cb/requests/data_lists/data_list_base.rb +11 -1
- data/lib/cb/requests/data_lists/desired_job_type.rb +10 -0
- data/lib/cb/requests/data_lists/education_codes.rb +10 -0
- data/lib/cb/requests/data_lists/languages.rb +10 -0
- data/lib/cb/requests/data_lists/state.rb +12 -2
- data/lib/cb/requests/education/get.rb +10 -2
- data/lib/cb/requests/email_subscription/modify.rb +13 -5
- data/lib/cb/requests/email_subscription/retrieve.rb +10 -2
- data/lib/cb/requests/job_search/get.rb +12 -3
- data/lib/cb/requests/recommendations/resume_recs.rb +12 -4
- data/lib/cb/requests/resumes/delete.rb +10 -0
- data/lib/cb/requests/resumes/get.rb +10 -0
- data/lib/cb/requests/resumes/language_codes.rb +12 -2
- data/lib/cb/requests/resumes/list.rb +12 -2
- data/lib/cb/requests/resumes/post.rb +11 -1
- data/lib/cb/requests/resumes/put.rb +11 -3
- data/lib/cb/requests/user/change_password.rb +10 -2
- data/lib/cb/requests/user/check_existing.rb +10 -2
- data/lib/cb/requests/user/delete.rb +10 -2
- data/lib/cb/requests/user/retrieve.rb +10 -2
- data/lib/cb/requests/user/temporary_password.rb +11 -3
- data/lib/cb/requests/work_status/list.rb +10 -2
- data/lib/cb/responses/Recommendation/recommendations.rb +10 -1
- data/lib/cb/responses/anonymous_saved_search/create.rb +10 -2
- data/lib/cb/responses/anonymous_saved_search/delete.rb +10 -2
- data/lib/cb/responses/api_response.rb +19 -9
- data/lib/cb/responses/application.rb +10 -2
- data/lib/cb/responses/application/application_form.rb +10 -2
- data/lib/cb/responses/application_external/submit_application.rb +11 -2
- data/lib/cb/responses/category/search.rb +13 -4
- data/lib/cb/responses/company/find.rb +12 -3
- data/lib/cb/responses/data_list/state.rb +10 -1
- data/lib/cb/responses/data_lists/resume_data_list.rb +10 -1
- data/lib/cb/responses/education/get.rb +13 -4
- data/lib/cb/responses/email_subscription/response.rb +11 -2
- data/lib/cb/responses/employee_types/search.rb +10 -3
- data/lib/cb/responses/errors.rb +14 -5
- data/lib/cb/responses/industry/search.rb +11 -4
- data/lib/cb/responses/job/search.rb +10 -1
- data/lib/cb/responses/job/search_v3.rb +10 -1
- data/lib/cb/responses/job/singular.rb +13 -4
- data/lib/cb/responses/metadata.rb +11 -2
- data/lib/cb/responses/resumes/language_codes.rb +11 -0
- data/lib/cb/responses/resumes/resume.rb +10 -1
- data/lib/cb/responses/resumes/resume_document.rb +10 -0
- data/lib/cb/responses/resumes/resume_list.rb +10 -0
- data/lib/cb/responses/saved_search/delete.rb +11 -3
- data/lib/cb/responses/saved_search/list.rb +10 -2
- data/lib/cb/responses/saved_search/retrieve.rb +10 -2
- data/lib/cb/responses/saved_search/singular.rb +10 -2
- data/lib/cb/responses/saved_search/update.rb +11 -3
- data/lib/cb/responses/timing.rb +15 -6
- data/lib/cb/responses/user/change_password.rb +12 -4
- data/lib/cb/responses/user/check_existing.rb +11 -3
- data/lib/cb/responses/user/delete.rb +11 -3
- data/lib/cb/responses/user/retrieve.rb +10 -3
- data/lib/cb/responses/user/temporary_password.rb +10 -3
- data/lib/cb/responses/work_status/list.rb +12 -4
- data/lib/cb/utils/api.rb +22 -12
- data/lib/cb/utils/console_observer.rb +11 -2
- data/lib/cb/utils/country.rb +14 -4
- data/lib/cb/utils/fluid_attributes.rb +11 -4
- data/lib/cb/utils/meta_values.rb +10 -0
- data/lib/cb/utils/response_array_extractor.rb +14 -6
- data/lib/cb/utils/response_map.rb +12 -3
- data/lib/cb/utils/validator.rb +21 -19
- data/lib/cb/version.rb +11 -1
- data/lib/tasks/cb.rake +11 -1
- data/lib/tasks/doc.rake +15 -5
- metadata +5 -3
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
module Cb
|
|
2
12
|
module Responses
|
|
3
13
|
module User
|
|
4
|
-
|
|
5
14
|
class Delete < ApiResponse
|
|
6
|
-
class Model < Struct.new(:status)
|
|
15
|
+
class Model < Struct.new(:status); end
|
|
7
16
|
|
|
8
17
|
protected
|
|
9
18
|
|
|
@@ -36,7 +45,6 @@ module Cb
|
|
|
36
45
|
'Status'
|
|
37
46
|
end
|
|
38
47
|
end
|
|
39
|
-
|
|
40
48
|
end
|
|
41
49
|
end
|
|
42
50
|
end
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
module Cb
|
|
2
12
|
module Responses
|
|
3
13
|
module User
|
|
4
|
-
|
|
5
14
|
class Retrieve < ApiResponse
|
|
6
|
-
|
|
7
15
|
attr_reader :status
|
|
8
16
|
|
|
9
17
|
def initialize(args)
|
|
@@ -48,7 +56,6 @@ module Cb
|
|
|
48
56
|
'Status'
|
|
49
57
|
end
|
|
50
58
|
end
|
|
51
|
-
|
|
52
59
|
end
|
|
53
60
|
end
|
|
54
61
|
end
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
module Cb
|
|
2
12
|
module Responses
|
|
3
13
|
module User
|
|
4
|
-
|
|
5
14
|
class TemporaryPassword < ApiResponse
|
|
6
|
-
|
|
7
15
|
# there's really no response model here, so let's just
|
|
8
16
|
# pass the new password along in a way that makes sense.
|
|
9
17
|
alias_method :temp_password, :model
|
|
@@ -32,7 +40,6 @@ module Cb
|
|
|
32
40
|
'TemporaryPassword'
|
|
33
41
|
end
|
|
34
42
|
end
|
|
35
|
-
|
|
36
43
|
end
|
|
37
44
|
end
|
|
38
45
|
end
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
require 'cb/responses/api_response'
|
|
2
12
|
|
|
3
13
|
module Cb
|
|
4
14
|
module Responses
|
|
5
15
|
module WorkStatus
|
|
6
16
|
class List < ApiResponse
|
|
7
|
-
|
|
8
17
|
protected
|
|
9
18
|
|
|
10
19
|
def hash_containing_metadata
|
|
@@ -16,19 +25,18 @@ module Cb
|
|
|
16
25
|
end
|
|
17
26
|
|
|
18
27
|
def extract_models
|
|
19
|
-
[
|
|
28
|
+
[model_array].flatten.map { |work_status| Cb::Models::WorkStatus.new work_status }
|
|
20
29
|
end
|
|
21
30
|
|
|
22
31
|
private
|
|
23
32
|
|
|
24
33
|
def work_statuses_node
|
|
25
|
-
|
|
34
|
+
'WorkStatuses'
|
|
26
35
|
end
|
|
27
36
|
|
|
28
37
|
def model_array
|
|
29
38
|
response[work_statuses_node]
|
|
30
39
|
end
|
|
31
|
-
|
|
32
40
|
end
|
|
33
41
|
end
|
|
34
42
|
end
|
data/lib/cb/utils/api.rb
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
require 'httparty'
|
|
2
12
|
require 'observer'
|
|
3
13
|
|
|
@@ -20,31 +30,31 @@ module Cb
|
|
|
20
30
|
end
|
|
21
31
|
|
|
22
32
|
def initialize
|
|
23
|
-
self.class.default_params :
|
|
24
|
-
:
|
|
33
|
+
self.class.default_params developerkey: Cb.configuration.dev_key,
|
|
34
|
+
outputjson: Cb.configuration.use_json.to_s
|
|
25
35
|
|
|
26
36
|
self.class.default_timeout Cb.configuration.time_out
|
|
27
|
-
self.class.headers.merge! ({'developerkey' => Cb.configuration.dev_key})
|
|
28
|
-
self.class.headers.merge! ({'accept-encoding' => 'deflate, gzip'}) unless Cb.configuration.debug_api
|
|
37
|
+
self.class.headers.merge! ({ 'developerkey' => Cb.configuration.dev_key })
|
|
38
|
+
self.class.headers.merge! ({ 'accept-encoding' => 'deflate, gzip' }) unless Cb.configuration.debug_api
|
|
29
39
|
end
|
|
30
40
|
|
|
31
|
-
def cb_get(path, options={}, &block)
|
|
41
|
+
def cb_get(path, options = {}, &block)
|
|
32
42
|
execute_http_request(:get, nil, path, options, &block)
|
|
33
43
|
end
|
|
34
44
|
|
|
35
|
-
def cb_post(path, options={}, &block)
|
|
45
|
+
def cb_post(path, options = {}, &block)
|
|
36
46
|
execute_http_request(:post, nil, path, options, &block)
|
|
37
47
|
end
|
|
38
48
|
|
|
39
|
-
def cb_put(path, options={}, &block)
|
|
49
|
+
def cb_put(path, options = {}, &block)
|
|
40
50
|
execute_http_request(:put, nil, path, options, &block)
|
|
41
51
|
end
|
|
42
52
|
|
|
43
|
-
def cb_delete(path, options={}, &block)
|
|
53
|
+
def cb_delete(path, options = {}, &block)
|
|
44
54
|
execute_http_request(:delete, nil, path, options, &block)
|
|
45
55
|
end
|
|
46
56
|
|
|
47
|
-
def execute_http_request(http_method, uri, path, options={}, &block)
|
|
57
|
+
def execute_http_request(http_method, uri, path, options = {}, &block)
|
|
48
58
|
self.class.base_uri(uri || Cb.configuration.base_uri)
|
|
49
59
|
api_caller = find_api_caller(caller)
|
|
50
60
|
start_time = Time.now.to_f
|
|
@@ -84,7 +94,7 @@ module Cb
|
|
|
84
94
|
end
|
|
85
95
|
|
|
86
96
|
def self.criteria_to_hash(criteria)
|
|
87
|
-
params =
|
|
97
|
+
params = {}
|
|
88
98
|
if criteria.respond_to?(:instance_variables)
|
|
89
99
|
criteria.instance_variables.each do |var|
|
|
90
100
|
var_name = var.to_s
|
|
@@ -137,7 +147,7 @@ module Cb
|
|
|
137
147
|
|
|
138
148
|
def self.camelize(input)
|
|
139
149
|
input.sub!(/^[a-z\d]*/) { $&.capitalize }
|
|
140
|
-
input.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{
|
|
150
|
+
input.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{Regexp.last_match(2).capitalize}" }.gsub('/', '::')
|
|
141
151
|
end
|
|
142
152
|
|
|
143
153
|
def set_api_error(validated_response)
|
|
@@ -145,7 +155,7 @@ module Cb
|
|
|
145
155
|
end
|
|
146
156
|
|
|
147
157
|
def format_hash_key(api_hash_key)
|
|
148
|
-
return
|
|
158
|
+
return '' unless api_hash_key.respond_to?(:snakecase)
|
|
149
159
|
api_hash_key.snakecase
|
|
150
160
|
end
|
|
151
161
|
end
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
module Cb
|
|
2
12
|
module Utils
|
|
3
13
|
class ConsoleObserver
|
|
4
14
|
def update(api_call)
|
|
5
|
-
puts "#{api_call.api_call_type
|
|
15
|
+
puts "#{api_call.api_call_type} #{api_call.path}/#{api_call.options} response: #{api_call.response.to_json}"
|
|
6
16
|
end
|
|
7
17
|
end
|
|
8
18
|
end
|
|
9
19
|
end
|
|
10
|
-
|
data/lib/cb/utils/country.rb
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
module Cb
|
|
2
12
|
module Utils
|
|
3
13
|
class Country
|
|
4
14
|
# These aren't all country codes. We get it. Our naming scheme didn't hold up over time.
|
|
5
15
|
def self.get_supported
|
|
6
16
|
%w(AH BE CA CC CE CH CN CP CS CY DE DK E1 ER ES EU F1
|
|
7
|
-
|
|
8
|
-
|
|
17
|
+
FR GC GR I1 IE IN IT J1 JC JS LJ M1 MY NL NO PD PI
|
|
18
|
+
PL RM RO RX S1 SE SF SG T1 T2 UK US WH WM WR)
|
|
9
19
|
end
|
|
10
20
|
|
|
11
21
|
def self.is_valid?(country)
|
|
@@ -15,7 +25,7 @@ module Cb
|
|
|
15
25
|
def self.inject_convenience_methods
|
|
16
26
|
get_supported.each do |country|
|
|
17
27
|
unless self.respond_to? "#{country}"
|
|
18
|
-
|
|
28
|
+
define_singleton_method "#{country}" do
|
|
19
29
|
return country
|
|
20
30
|
end
|
|
21
31
|
end
|
|
@@ -23,4 +33,4 @@ module Cb
|
|
|
23
33
|
end
|
|
24
34
|
end
|
|
25
35
|
end
|
|
26
|
-
end
|
|
36
|
+
end
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
module Cb
|
|
2
12
|
module Utils
|
|
3
13
|
module FluidAttributes
|
|
4
|
-
|
|
5
14
|
def fluid_attr_accessor(*names)
|
|
6
15
|
names.each do |name|
|
|
7
|
-
|
|
8
16
|
define_method :"#{name}" do |*args|
|
|
9
17
|
return instance_variable_get(:"@#{name}") if args.length == 0
|
|
10
18
|
|
|
@@ -13,7 +21,7 @@ module Cb
|
|
|
13
21
|
return self
|
|
14
22
|
end
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
fail ArgumentError.new("Wrong number of arguments (#{args.length} for 1)")
|
|
17
25
|
end
|
|
18
26
|
|
|
19
27
|
define_method :"#{name}=" do |*args|
|
|
@@ -22,7 +30,6 @@ module Cb
|
|
|
22
30
|
end
|
|
23
31
|
end
|
|
24
32
|
end
|
|
25
|
-
|
|
26
33
|
end
|
|
27
34
|
end
|
|
28
35
|
end
|
data/lib/cb/utils/meta_values.rb
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
module Cb
|
|
2
12
|
module Utils
|
|
3
13
|
class MetaValues
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
module Cb
|
|
2
12
|
module Utils
|
|
3
13
|
class ResponseArrayExtractor
|
|
4
|
-
|
|
5
14
|
def self.extract(response_hash, key, singular_key = nil)
|
|
6
|
-
|
|
15
|
+
new(response_hash, key, singular_key).extract
|
|
7
16
|
end
|
|
8
17
|
|
|
9
18
|
def initialize(response_hash, key, singular_key)
|
|
10
19
|
@response_hash = response_hash
|
|
11
20
|
@key = key
|
|
12
|
-
@singular_key = singular_key || key[0..key.length-2]
|
|
21
|
+
@singular_key = singular_key || key[0..key.length - 2]
|
|
13
22
|
end
|
|
14
23
|
|
|
15
24
|
def extract
|
|
@@ -40,10 +49,9 @@ module Cb
|
|
|
40
49
|
if @response_hash[@key][@singular_key].is_a?(Array)
|
|
41
50
|
@response_hash[@key][@singular_key]
|
|
42
51
|
else
|
|
43
|
-
[
|
|
52
|
+
[@response_hash[@key][@singular_key]]
|
|
44
53
|
end
|
|
45
54
|
end
|
|
46
|
-
|
|
47
55
|
end
|
|
48
56
|
end
|
|
49
|
-
end
|
|
57
|
+
end
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
module Cb
|
|
2
12
|
module Utils
|
|
3
13
|
class ResponseMap
|
|
4
14
|
class << self
|
|
5
|
-
def response_for
|
|
15
|
+
def response_for(request_class)
|
|
6
16
|
response_class = response_hash[request_class]
|
|
7
17
|
return response_class unless response_class.nil?
|
|
8
|
-
|
|
18
|
+
fail ResponseNotFoundError.new request_class
|
|
9
19
|
end
|
|
10
20
|
|
|
11
21
|
protected
|
|
@@ -60,7 +70,6 @@ module Cb
|
|
|
60
70
|
Cb::Requests::State::Get => Cb::Responses::State
|
|
61
71
|
}.merge response_hash_extension
|
|
62
72
|
end
|
|
63
|
-
|
|
64
73
|
end
|
|
65
74
|
end
|
|
66
75
|
class ResponseNotFoundError < StandardError
|
data/lib/cb/utils/validator.rb
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
# Copyright 2015 CareerBuilder, LLC
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
1
11
|
require 'json'
|
|
2
12
|
require 'nori'
|
|
3
13
|
|
|
4
14
|
module Cb
|
|
5
15
|
module ResponseValidator
|
|
6
|
-
|
|
7
16
|
class << self
|
|
8
17
|
def validate(response)
|
|
9
18
|
raise_response_code_errors(response)
|
|
@@ -14,8 +23,8 @@ module Cb
|
|
|
14
23
|
|
|
15
24
|
def raise_response_code_errors(response)
|
|
16
25
|
code = response.code rescue nil
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
fail Cb::ServiceUnavailableError if code == 503 || simulate_auth_outage?
|
|
27
|
+
fail Cb::UnauthorizedError if code == 401
|
|
19
28
|
end
|
|
20
29
|
|
|
21
30
|
def simulate_auth_outage?
|
|
@@ -24,31 +33,24 @@ module Cb
|
|
|
24
33
|
|
|
25
34
|
def process_response_body(response)
|
|
26
35
|
body = response.response.body rescue nil
|
|
27
|
-
return
|
|
36
|
+
return {} unless body
|
|
37
|
+
|
|
38
|
+
return {} if body.include?('<!DOCTYPE html') if response.code != 200
|
|
28
39
|
|
|
29
|
-
if response.code != 200
|
|
30
|
-
return Hash.new if body.include?('<!DOCTYPE html')
|
|
31
|
-
end
|
|
32
|
-
|
|
33
40
|
try_parse_json(body) || try_parse_xml(body) || {}
|
|
34
41
|
end
|
|
35
42
|
|
|
36
43
|
def try_parse_json(body)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
nil
|
|
41
|
-
end
|
|
44
|
+
JSON.parse(body)
|
|
45
|
+
rescue JSON::ParserError
|
|
46
|
+
nil
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
def try_parse_xml(body)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
nil
|
|
49
|
-
end
|
|
50
|
+
MultiXml.parse(body, KeepRoot: true)
|
|
51
|
+
rescue MultiXml::ParseError
|
|
52
|
+
nil
|
|
50
53
|
end
|
|
51
54
|
end
|
|
52
|
-
|
|
53
55
|
end
|
|
54
56
|
end
|