cb-api 19.1.1 → 20.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e1ad51af191a99572a406269d6c2651a8fa5ff7
4
- data.tar.gz: b64a995401eb9222ad3081084e2ea1198e3c1b49
3
+ metadata.gz: c0242c0310d95df0d5a5ec18e5b6854c854d6d75
4
+ data.tar.gz: 57a461e4922d487512d15d42591202cb6895a536
5
5
  SHA512:
6
- metadata.gz: f8c76d539e0823fefecb876a5d94869e2d862e13574838f01839e33c8556b3def6341cb8c24ad06cf9740a3a6410e98d2857c45a8b7c48bcaadae68bb7bbec63
7
- data.tar.gz: 4894150692ad214101a51c26e2528d97aaf0c16e2772c6d8e95423f225efc35e1faf097631509b3d2a561ddf004004048af03954703a820ff7240b56aabe371a
6
+ metadata.gz: 094c95855fd37458d597fe4c21e283bddc3367ee775aa5e057a4fbabb8e0db9573d418ef3aafffbc5ac09083847e69102facdf824aaa3e68ec065aab5868551f
7
+ data.tar.gz: 361519737459ad1b9bbc70308009c0deeadc129036507a4b50d5167832d1e5a56f3514194bc35d665ad57ce70d8049c44d23b46188c49b726a3b331e02c7ab45
data/CHANGELOG.md CHANGED
@@ -3,6 +3,7 @@ Version History
3
3
  * All Version bumps are required to update this file as well!!
4
4
  ----
5
5
 
6
+ * 20.0.0 Refactoring of the clients. Breaking changes to AnonSavedSearch, EmployeeTypes, SavedSearch
6
7
  * 19.1.1 No functional differences, some code cleanup
7
8
  * 19.1.0 Add Migration ID field to resume listing model.
8
9
  * 19.0.0 Removed job search version(s) prior to version 3. Breaks existing consumers of the API in the following ways. JobResultsV3 renamed to JobResults. The old JobResults path no longer works. Users of the JobSearch API will now need to use OAuth and not Developer Keys to use the JobSearch API>
@@ -8,16 +8,17 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
+ require_relative 'base'
11
12
  module Cb
12
13
  module Clients
13
- class AnonSavedSearch
14
- def create(*args)
14
+ class AnonSavedSearch < Base
15
+ def self.create(*args)
15
16
  body = new_model(*args).create_anon_to_xml
16
17
  json = cb_client.cb_post(create_uri, body: body)
17
18
  Responses::AnonymousSavedSearch::Create.new(json)
18
19
  end
19
20
 
20
- def delete(*args)
21
+ def self.delete(*args)
21
22
  body = new_model(*args).delete_anon_to_xml
22
23
  json = cb_client.cb_post(delete_uri, body: body)
23
24
  Responses::AnonymousSavedSearch::Delete.new(json)
@@ -25,26 +26,22 @@ module Cb
25
26
 
26
27
  private
27
28
 
28
- def new_model(*args)
29
+ def self.new_model(*args)
29
30
  return args.first if args.respond_to?(:[]) && args.first.is_a?(Models::SavedSearch)
30
31
  Models::SavedSearch.new(extract_args(*args))
31
32
  end
32
33
 
33
- def extract_args(*args)
34
+ def self.extract_args(*args)
34
35
  args.is_a?(Array) && args.count == 1 ? args[0] : args
35
36
  end
36
37
 
37
- def create_uri
38
+ def self.create_uri
38
39
  Cb.configuration.uri_anon_saved_search_create
39
40
  end
40
41
 
41
- def delete_uri
42
+ def self.delete_uri
42
43
  Cb.configuration.uri_anon_saved_search_delete
43
44
  end
44
-
45
- def cb_client
46
- @cb_client ||= Cb::Utils::Api.instance
47
- end
48
45
  end
49
46
  end
50
47
  end
@@ -8,9 +8,10 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
+ require_relative 'base'
11
12
  module Cb
12
13
  module Clients
13
- class Application
14
+ class Application < Base
14
15
  class << self
15
16
  def get(criteria)
16
17
  response cb_call(:get, criteria, Cb.configuration.host_site)
@@ -26,7 +27,7 @@ module Cb
26
27
 
27
28
  def form(job_id)
28
29
  url = Cb.configuration.uri_application_form.sub(':did', job_id)
29
- response_hash = api_client.cb_get(url, headers: headers(Cb.configuration.host_site))
30
+ response_hash = cb_client.cb_get(url, headers: headers(Cb.configuration.host_site))
30
31
  Responses::ApplicationForm.new response_hash
31
32
  end
32
33
 
@@ -40,7 +41,7 @@ module Cb
40
41
  end
41
42
 
42
43
  uri = uri(criteria)
43
- api_client.method(:"cb_#{http_method}").call(uri, options)
44
+ cb_client.method(:"cb_#{http_method}").call(uri, options)
44
45
  end
45
46
 
46
47
  def response(response_hash)
@@ -59,10 +60,6 @@ module Cb
59
60
  'Content-Type' => 'application/json'
60
61
  }
61
62
  end
62
-
63
- def api_client
64
- Cb::Utils::Api.instance
65
- end
66
63
  end
67
64
  end
68
65
  end
@@ -9,15 +9,14 @@
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
11
  require 'json'
12
-
12
+ require_relative 'base'
13
13
  module Cb
14
14
  module Clients
15
- class ApplicationExternal
15
+ class ApplicationExternal < Base
16
16
  def self.submit_app(app)
17
17
  fail Cb::IncomingParamIsWrongTypeException unless app.is_a?(Cb::Models::ApplicationExternal)
18
18
 
19
- my_api = Cb::Utils::Api.instance
20
- xml_hash = my_api.cb_post(Cb.configuration.uri_application_external, body: app.to_xml)
19
+ xml_hash = cb_client.cb_post(Cb.configuration.uri_application_external, body: app.to_xml)
21
20
 
22
21
  if xml_hash.key? 'ApplyUrl'
23
22
  app.apply_url = xml_hash['ApplyUrl']
@@ -25,7 +24,7 @@ module Cb
25
24
  app.apply_url = ''
26
25
  end
27
26
 
28
- my_api.append_api_responses(app, xml_hash)
27
+ cb_client.append_api_responses(app, xml_hash)
29
28
  end
30
29
  end
31
30
  end
@@ -0,0 +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.
11
+ module Cb
12
+ module Clients
13
+ class Base
14
+ def self.cb_client
15
+ @cb_client ||= Cb::Utils::Api.instance
16
+ end
17
+ end
18
+ end
19
+ end
@@ -9,13 +9,12 @@
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
11
  require 'json'
12
-
12
+ require_relative 'base'
13
13
  module Cb
14
14
  module Clients
15
- class Category
15
+ class Category < Base
16
16
  def self.search
17
- my_api = Cb::Utils::Api.instance
18
- json_hash = my_api.cb_get(Cb.configuration.uri_job_category_search)
17
+ json_hash = cb_client.cb_get(Cb.configuration.uri_job_category_search)
19
18
  categoryList = []
20
19
 
21
20
  if json_hash.key?('ResponseCategories')
@@ -25,15 +24,14 @@ module Cb
25
24
  end
26
25
  end
27
26
 
28
- my_api.append_api_responses(categoryList, json_hash['ResponseCategories'])
27
+ cb_client.append_api_responses(categoryList, json_hash['ResponseCategories'])
29
28
  end
30
29
 
31
- my_api.append_api_responses(categoryList, json_hash)
30
+ cb_client.append_api_responses(categoryList, json_hash)
32
31
  end
33
32
 
34
33
  def self.search_by_host_site(host_site)
35
- my_api = Cb::Utils::Api.instance
36
- json_hash = my_api.cb_get(Cb.configuration.uri_job_category_search, query: { CountryCode: host_site })
34
+ json_hash = cb_client.cb_get(Cb.configuration.uri_job_category_search, query: { CountryCode: host_site })
37
35
  categoryList = []
38
36
 
39
37
  if json_hash.key?('ResponseCategories')
@@ -47,10 +45,10 @@ module Cb
47
45
  end
48
46
  end
49
47
 
50
- my_api.append_api_responses(categoryList, json_hash['ResponseCategories'])
48
+ cb_client.append_api_responses(categoryList, json_hash['ResponseCategories'])
51
49
  end
52
50
 
53
- my_api.append_api_responses(categoryList, json_hash)
51
+ cb_client.append_api_responses(categoryList, json_hash)
54
52
  end
55
53
  end
56
54
  end
@@ -9,22 +9,22 @@
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
11
  require 'json'
12
-
12
+ require_relative 'base'
13
13
  module Cb
14
14
  module Clients
15
- class Company
15
+ class Company < Base
16
16
  def self.find_by_did(did)
17
- my_api = Cb::Utils::Api.instance
18
- json_hash = my_api.cb_get(Cb.configuration.uri_company_find, query: { CompanyDID: did, hostsite: Cb.configuration.host_site })
17
+ json_hash = cb_client.cb_get(Cb.configuration.uri_company_find,
18
+ query: { CompanyDID: did, hostsite: Cb.configuration.host_site })
19
19
 
20
20
  if json_hash.key?('Results')
21
21
  if json_hash['Results'].key?('CompanyProfileDetail')
22
22
  company = Models::Company.new(json_hash['Results']['CompanyProfileDetail'])
23
23
  end
24
- my_api.append_api_responses(company, json_hash['Results'])
24
+ cb_client.append_api_responses(company, json_hash['Results'])
25
25
  end
26
26
 
27
- my_api.append_api_responses(company, json_hash)
27
+ cb_client.append_api_responses(company, json_hash)
28
28
  end
29
29
 
30
30
  def self.find_for(obj)
@@ -0,0 +1,55 @@
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.
11
+ require_relative 'base'
12
+ module Cb
13
+ module Clients
14
+ class CoverLetters < Base
15
+ def self.get(args={})
16
+ uri = Cb.configuration.uri_cover_letters
17
+ uri += "/#{ args[:id] }" if args[:id]
18
+ cb_client.cb_get(uri, headers: headers(args))
19
+ end
20
+
21
+ def self.create(args={})
22
+ cb_client.cb_put(Cb.configuration.uri_cover_letters,
23
+ body: body(args),
24
+ headers: headers(args))
25
+ end
26
+
27
+ def self.delete(args={})
28
+ uri = "#{ Cb.configuration.uri_cover_letters }/#{ args[:id] }"
29
+ cb_client.cb_delete(uri, body: body(args), headers: headers(args))
30
+ end
31
+
32
+ def self.update(args={})
33
+ uri = "#{ Cb.configuration.uri_cover_letters }/#{ args[:id] }"
34
+ cb_client.cb_post(uri, body: body(args), headers: headers(args))
35
+ end
36
+
37
+ private
38
+ def self.headers(args)
39
+ {
40
+ 'Accept' => 'application/json',
41
+ 'Authorization' => "Bearer #{ args[:oauth_token] }",
42
+ 'Content-Type' => 'application/json'
43
+ }
44
+ end
45
+
46
+ def self.body(args)
47
+ body = Hash.new
48
+ body[:id] = args[:id] if args[:id]
49
+ body[:text] = args[:text] if args[:text]
50
+ body[:name] = args[:name] if args[:name]
51
+ body.to_json
52
+ end
53
+ end
54
+ end
55
+ end
@@ -9,14 +9,13 @@
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
11
  require 'json'
12
-
12
+ require_relative 'base'
13
13
  module Cb
14
14
  module Clients
15
- class Education
15
+ class Education < Base
16
16
  def self.get_for(country)
17
17
  Cb::Utils::Country.is_valid? country ? country : 'US'
18
- my_api = Cb::Utils::Api.instance
19
- json_hash = my_api.cb_get(Cb.configuration.uri_education_code, query: { countrycode: country })
18
+ json_hash = cb_client.cb_get(Cb.configuration.uri_education_code, query: { countrycode: country })
20
19
 
21
20
  codes = []
22
21
  if json_hash.key?('ResponseEducationCodes')
@@ -26,10 +25,10 @@ module Cb
26
25
  codes << Cb::Models::Education.new(education)
27
26
  end
28
27
  end
29
- my_api.append_api_responses(codes, json_hash['ResponseEducationCodes'])
28
+ cb_client.append_api_responses(codes, json_hash['ResponseEducationCodes'])
30
29
  end
31
30
 
32
- my_api.append_api_responses(codes, json_hash)
31
+ cb_client.append_api_responses(codes, json_hash)
33
32
  end
34
33
  end
35
34
  end
@@ -8,30 +8,27 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
+ require_relative 'base'
11
12
  module Cb
12
13
  module Clients
13
- class EmployeeTypes
14
- def search
14
+ class EmployeeTypes < Base
15
+ def self.search
15
16
  json = cb_client.cb_get(endpoint)
16
17
  new_response_object(json)
17
18
  end
18
19
 
19
- def search_by_hostsite(host_site)
20
+ def self.search_by_hostsite(host_site)
20
21
  json = cb_client.cb_get(endpoint, query: { CountryCode: host_site })
21
22
  new_response_object(json)
22
23
  end
23
24
 
24
25
  private
25
26
 
26
- def cb_client
27
- @client ||= Cb::Utils::Api.instance
28
- end
29
-
30
- def endpoint
27
+ def self.endpoint
31
28
  Cb.configuration.uri_employee_types
32
29
  end
33
30
 
34
- def new_response_object(json_response)
31
+ def self.new_response_object(json_response)
35
32
  Responses::EmployeeTypes::Search.new(json_response)
36
33
  end
37
34
  end
@@ -9,21 +9,14 @@
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
11
  require 'json'
12
-
12
+ require_relative 'base'
13
13
  module Cb
14
14
  module Clients
15
- class Industry
16
- class << self
17
- def search
18
- response = api_client.cb_get(Cb.configuration.uri_job_industry_search, query: { CountryCode: Cb.configuration.host_site })
19
- Cb::Responses::Industry::Search.new(response)
20
- end
21
-
22
- private
23
-
24
- def api_client
25
- @api ||= Cb::Utils::Api.instance
26
- end
15
+ class Industry < Base
16
+ def self.search
17
+ response = cb_client.cb_get(Cb.configuration.uri_job_industry_search,
18
+ query: { CountryCode: Cb.configuration.host_site })
19
+ Cb::Responses::Industry::Search.new(response)
27
20
  end
28
21
  end
29
22
  end
@@ -9,14 +9,14 @@
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
11
  require 'json'
12
-
12
+ require_relative 'base'
13
13
  module Cb
14
14
  module Clients
15
- class Job
15
+ class Job < Base
16
16
  class << self
17
17
  def find_by_criteria(criteria)
18
- query = api_client.class.criteria_to_hash(criteria)
19
- json_response = api_client.cb_get(Cb.configuration.uri_job_find, query: query)
18
+ query = cb_client.class.criteria_to_hash(criteria)
19
+ json_response = cb_client.cb_get(Cb.configuration.uri_job_find, query: query)
20
20
  Responses::Job::Singular.new(json_response)
21
21
  end
22
22
 
@@ -26,12 +26,6 @@ module Cb
26
26
  criteria.show_custom_values = true
27
27
  find_by_criteria(criteria)
28
28
  end
29
-
30
- private
31
-
32
- def api_client
33
- @api ||= Cb::Utils::Api.instance
34
- end
35
29
  end
36
30
  end
37
31
  end
@@ -8,19 +8,19 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
+ require_relative 'base'
11
12
  module Cb
12
13
  module Clients
13
- class JobBranding
14
+ class JobBranding < Base
14
15
  def self.find_by_id(id)
15
- my_api = Cb::Utils::Api.instance
16
- json_hash = my_api.cb_get Cb.configuration.uri_job_branding, query: { id: id }
16
+ json_hash = cb_client.cb_get Cb.configuration.uri_job_branding, query: { id: id }
17
17
 
18
18
  if json_hash.key? 'Branding'
19
19
  branding = Models::JobBranding.new json_hash['Branding']
20
- my_api.append_api_responses(branding, json_hash['Branding'])
20
+ cb_client.append_api_responses(branding, json_hash['Branding'])
21
21
  end
22
22
 
23
- my_api.append_api_responses(branding, json_hash)
23
+ cb_client.append_api_responses(branding, json_hash)
24
24
  end
25
25
  end
26
26
  end
@@ -9,15 +9,14 @@
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
11
  require 'json'
12
-
12
+ require_relative 'base'
13
13
  module Cb
14
14
  module Clients
15
- class Recommendation
15
+ class Recommendation < Base
16
16
  def self.for_job(*args)
17
- my_api = Cb::Utils::Api.instance
18
17
  hash = normalize_args(args)
19
18
  hash = set_hash_defaults(hash)
20
- json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_job,
19
+ json_hash = cb_client.cb_get(Cb.configuration.uri_recommendation_for_job,
21
20
  query: hash)
22
21
 
23
22
  jobs = []
@@ -28,20 +27,19 @@ module Cb
28
27
 
29
28
  jobs = create_jobs json_hash, 'Job'
30
29
 
31
- my_api.append_api_responses(jobs, json_hash['ResponseRecommendJob']['Request'])
30
+ cb_client.append_api_responses(jobs, json_hash['ResponseRecommendJob']['Request'])
32
31
  end
33
32
 
34
- my_api.append_api_responses(jobs, json_hash['ResponseRecommendJob'])
33
+ cb_client.append_api_responses(jobs, json_hash['ResponseRecommendJob'])
35
34
  end
36
35
 
37
- my_api.append_api_responses(jobs, json_hash)
36
+ cb_client.append_api_responses(jobs, json_hash)
38
37
  end
39
38
 
40
39
  def self.for_user(*args)
41
- my_api = Cb::Utils::Api.instance
42
40
  hash = normalize_args(args)
43
41
  hash = set_hash_defaults(hash)
44
- json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_user,
42
+ json_hash = cb_client.cb_get(Cb.configuration.uri_recommendation_for_user,
45
43
  query: hash)
46
44
 
47
45
  jobs = []
@@ -53,18 +51,17 @@ module Cb
53
51
 
54
52
  jobs = create_jobs json_hash, 'User'
55
53
 
56
- my_api.append_api_responses(jobs, json_hash['ResponseRecommendUser']['Request'])
54
+ cb_client.append_api_responses(jobs, json_hash['ResponseRecommendUser']['Request'])
57
55
  end
58
56
 
59
- my_api.append_api_responses(jobs, json_hash['ResponseRecommendUser'])
57
+ cb_client.append_api_responses(jobs, json_hash['ResponseRecommendUser'])
60
58
  end
61
59
 
62
- my_api.append_api_responses(jobs, json_hash)
60
+ cb_client.append_api_responses(jobs, json_hash)
63
61
  end
64
62
 
65
63
  def self.for_company(company_did)
66
- my_api = Cb::Utils::Api.instance
67
- json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_company, query: { CompanyDID: company_did })
64
+ json_hash = cb_client.cb_get(Cb.configuration.uri_recommendation_for_company, query: { CompanyDID: company_did })
68
65
  jobs = []
69
66
  if json_hash
70
67
  api_jobs = json_hash.fetch('Results', {}).fetch('JobRecommendation', {}).fetch('Jobs', {})
@@ -74,9 +71,9 @@ module Cb
74
71
  jobs << Models::Job.new(cur_job)
75
72
  end
76
73
  end
77
- my_api.append_api_responses(jobs, json_hash.fetch('Results', {}).fetch('JobRecommendation', {}))
78
- my_api.append_api_responses(jobs, json_hash.fetch('Results', {}))
79
- my_api.append_api_responses(jobs, json_hash)
74
+ cb_client.append_api_responses(jobs, json_hash.fetch('Results', {}).fetch('JobRecommendation', {}))
75
+ cb_client.append_api_responses(jobs, json_hash.fetch('Results', {}))
76
+ cb_client.append_api_responses(jobs, json_hash)
80
77
  end
81
78
  end
82
79
 
@@ -8,22 +8,23 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
+ require_relative 'base'
11
12
  module Cb
12
13
  module Clients
13
- class SavedSearch
14
- def create(saved_search)
14
+ class SavedSearch < Base
15
+ def self.create(saved_search)
15
16
  body = saved_search.create_to_xml
16
17
  json = cb_client.cb_post(Cb.configuration.uri_saved_search_create, body: body)
17
18
  singular_model_response(json, saved_search.external_user_id)
18
19
  end
19
20
 
20
- def update(saved_search)
21
+ def self.update(saved_search)
21
22
  body = saved_search.update_to_json
22
23
  json = cb_client.cb_put(Cb.configuration.uri_saved_search_update, body: body, headers: update_headers(saved_search.host_site))
23
24
  Responses::SavedSearch::Update.new(json)
24
25
  end
25
26
 
26
- def delete(hash)
27
+ def self.delete(hash)
27
28
  uri = replace_uri_field(Cb.configuration.uri_saved_search_delete, ':did', hash[:did])
28
29
  json = cb_client.cb_delete(
29
30
  uri,
@@ -33,14 +34,14 @@ module Cb
33
34
  Responses::SavedSearch::Delete.new(json)
34
35
  end
35
36
 
36
- def retrieve(oauth_token, external_id)
37
+ def self.retrieve(oauth_token, external_id)
37
38
  query = retrieve_query(oauth_token)
38
39
  uri = replace_uri_field(Cb.configuration.uri_saved_search_retrieve, ':did', external_id)
39
40
  json = cb_client.cb_get(uri, query: query)
40
41
  Responses::SavedSearch::Retrieve.new(json)
41
42
  end
42
43
 
43
- def list(oauth_token, hostsite)
44
+ def self.list(oauth_token, hostsite)
44
45
  query = list_query(oauth_token, hostsite)
45
46
  json = cb_client.cb_get(Cb.configuration.uri_saved_search_list, query: query)
46
47
  Responses::SavedSearch::List.new(json)
@@ -48,7 +49,7 @@ module Cb
48
49
 
49
50
  private
50
51
 
51
- def update_headers(host_site)
52
+ def self.update_headers(host_site)
52
53
  {
53
54
  'developerkey' => Cb.configuration.dev_key,
54
55
  'Content-Type' => 'application/json',
@@ -56,18 +57,14 @@ module Cb
56
57
  }
57
58
  end
58
59
 
59
- def cb_client
60
- @cb_client ||= Cb::Utils::Api.instance
61
- end
62
-
63
- def retrieve_query(oauth_token)
60
+ def self.retrieve_query(oauth_token)
64
61
  {
65
62
  developerkey: Cb.configuration.dev_key,
66
63
  useroauthtoken: oauth_token
67
64
  }
68
65
  end
69
66
 
70
- def list_query(oauth_token, hostsite)
67
+ def self.list_query(oauth_token, hostsite)
71
68
  {
72
69
  developerkey: Cb.configuration.dev_key,
73
70
  useroauthtoken: oauth_token,
@@ -75,13 +72,13 @@ module Cb
75
72
  }
76
73
  end
77
74
 
78
- def singular_model_response(json_hash, external_user_id = nil, external_id = nil)
75
+ def self.singular_model_response(json_hash, external_user_id = nil, external_id = nil)
79
76
  json_hash['ExternalUserID'] = external_user_id unless external_user_id.nil?
80
77
  json_hash['ExternalID'] = external_id unless external_id.nil?
81
78
  Responses::SavedSearch::Singular.new(json_hash)
82
79
  end
83
80
 
84
- def replace_uri_field(uri_string, field, replacement)
81
+ def self.replace_uri_field(uri_string, field, replacement)
85
82
  uri_string.gsub(field, replacement)
86
83
  end
87
84
  end
@@ -8,51 +8,47 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
+ require_relative 'base'
11
12
  module Cb
12
13
  module Clients
13
- class TalentNetwork
14
+ class TalentNetwork < Base
14
15
  def self.join_form_questions(tndid)
15
- my_api = Cb::Utils::Api.instance
16
- json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_questions}/#{tndid}/json")
16
+ json_hash = cb_client.cb_get("#{Cb.configuration.uri_tn_join_questions}/#{tndid}/json")
17
17
  tn_questions_collection = Models::TalentNetwork.new(json_hash)
18
- my_api.append_api_responses(tn_questions_collection, json_hash)
18
+ cb_client.append_api_responses(tn_questions_collection, json_hash)
19
19
  end
20
20
 
21
21
  def self.join_form_branding(tndid)
22
- my_api = Cb::Utils::Api.instance
23
- json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_form_branding}/#{tndid}/json")
22
+ json_hash = cb_client.cb_get("#{Cb.configuration.uri_tn_join_form_branding}/#{tndid}/json")
24
23
 
25
24
  if json_hash.key? 'Branding'
26
25
  tn_join_form_branding = Models::TalentNetwork::JoinFormBranding.new(json_hash['Branding'])
27
26
  end
28
27
 
29
- my_api.append_api_responses(tn_join_form_branding, json_hash)
28
+ cb_client.append_api_responses(tn_join_form_branding, json_hash)
30
29
  end
31
30
 
32
31
  def self.join_form_geography(tnlanguage = 'USEnglish')
33
- my_api = Cb::Utils::Api.instance
34
- json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_form_geo}", query: { TNLanguage: "#{tnlanguage}" })
32
+ json_hash = cb_client.cb_get("#{Cb.configuration.uri_tn_join_form_geo}", query: { TNLanguage: "#{tnlanguage}" })
35
33
  geo_dropdown = Models::TalentNetwork::JoinFormGeo.new(json_hash)
36
- my_api.append_api_responses(geo_dropdown, json_hash)
34
+ cb_client.append_api_responses(geo_dropdown, json_hash)
37
35
  end
38
36
 
39
37
  def self.member_create(args = {})
40
- my_api = Cb::Utils::Api.instance
41
38
  tn_member = Models::TalentNetwork::Member.new(args)
42
- json_hash = my_api.cb_post("#{Cb.configuration.uri_tn_member_create}/json", body: tn_member.to_xml)
43
- my_api.append_api_responses(json_hash, json_hash)
39
+ json_hash = cb_client.cb_post("#{Cb.configuration.uri_tn_member_create}/json", body: tn_member.to_xml)
40
+ cb_client.append_api_responses(json_hash, json_hash)
44
41
  end
45
42
 
46
43
  def self.tn_job_information(job_did, join_form_intercept = 'true')
47
- my_api = Cb::Utils::Api.instance
48
- json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_job_info}/#{job_did}/json",
44
+ json_hash = cb_client.cb_get("#{Cb.configuration.uri_tn_job_info}/#{job_did}/json",
49
45
  query: {RequestJoinFormIntercept: join_form_intercept } )
50
46
 
51
47
  if json_hash.key? 'Response'
52
48
  tn_job_info = Models::TalentNetwork::JobInfo.new(json_hash['Response'])
53
49
  end
54
50
 
55
- my_api.append_api_responses(tn_job_info, json_hash)
51
+ cb_client.append_api_responses(tn_job_info, json_hash)
56
52
  end
57
53
  end
58
54
  end
@@ -12,45 +12,43 @@ require 'json'
12
12
 
13
13
  module Cb
14
14
  module Clients
15
- class User
15
+ class User < Base
16
16
  class << self
17
17
  def check_existing(email, password)
18
18
  xml = build_check_existing_request(email, password)
19
- response = api_client.cb_post(Cb.configuration.uri_user_check_existing, body: xml)
19
+ response = cb_client.cb_post(Cb.configuration.uri_user_check_existing, body: xml)
20
20
  Cb::Responses::User::CheckExisting.new(response)
21
21
  end
22
22
 
23
23
  def temporary_password(external_id)
24
24
  query = { 'ExternalID' => external_id }
25
- response = api_client.cb_get(Cb.configuration.uri_user_temp_password, query: query)
25
+ response = cb_client.cb_get(Cb.configuration.uri_user_temp_password, query: query)
26
26
  Cb::Responses::User::TemporaryPassword.new(response)
27
27
  end
28
28
 
29
29
  def retrieve(external_id, _test_mode = false)
30
- my_api = Cb::Utils::Api.instance
31
- json_hash = my_api.cb_post Cb.configuration.uri_user_retrieve, body: build_retrieve_request(external_id, true)
30
+ cb_client = Cb::Utils::Api.instance
31
+ json_hash = cb_client.cb_post Cb.configuration.uri_user_retrieve, body: build_retrieve_request(external_id, true)
32
32
  if json_hash.key? 'ResponseUserInfo'
33
33
  if json_hash['ResponseUserInfo'].key? 'UserInfo'
34
34
  user = Models::User.new json_hash['ResponseUserInfo']['UserInfo']
35
35
  end
36
- my_api.append_api_responses user, json_hash['ResponseUserInfo']
36
+ cb_client.append_api_responses user, json_hash['ResponseUserInfo']
37
37
  end
38
38
 
39
- my_api.append_api_responses user, json_hash
39
+ cb_client.append_api_responses user, json_hash
40
40
  end
41
41
 
42
42
  def change_password(user_info)
43
- my_api = Cb::Utils::Api.instance
44
43
  uri = Cb.configuration.uri_user_change_password
45
- response = my_api.cb_post(uri, body: user_info.to_xml)
44
+ response = cb_client.cb_post(uri, body: user_info.to_xml)
46
45
 
47
46
  Cb::Responses::User::ChangePassword.new(response) if response.key?('ResponseUserChangePW')
48
47
  end
49
48
 
50
49
  def delete(delete_criteria)
51
- my_api = Cb::Utils::Api.instance
52
50
  uri = Cb.configuration.uri_user_delete
53
- response = my_api.cb_post(uri, body: delete_criteria.to_xml)
51
+ response = cb_client.cb_post(uri, body: delete_criteria.to_xml)
54
52
 
55
53
  Cb::Responses::User::Delete.new(response) if response.key?('ResponseUserDelete')
56
54
  end
@@ -89,10 +87,6 @@ module Cb
89
87
  </Request>
90
88
  eos
91
89
  end
92
-
93
- def api_client
94
- Cb::Utils::Api.instance
95
- end
96
90
  end
97
91
  end
98
92
  end
data/lib/cb/config.rb CHANGED
@@ -63,6 +63,7 @@ module Cb
63
63
  @uri_application_form ||= '/cbapi/job/:did/applicationform'
64
64
  @uri_company_find ||= '/Employer/CompanyDetails'
65
65
  @uri_countries ||= '/consumer/datalist/countries'
66
+ @uri_cover_letters ||= '/consumer/coverletters'
66
67
  @uri_cover_letter_list ||= '/v1/coverletter/list'
67
68
  @uri_cover_letter_retrieve ||= '/coverletter/retrieve'
68
69
  @uri_cover_letter_update ||= '/coverletter/edit'
@@ -27,6 +27,10 @@ module Cb
27
27
  Cb::Clients::Category
28
28
  end
29
29
 
30
+ def cover_letters
31
+ Cb::Clients::CoverLetters
32
+ end
33
+
30
34
  def industry
31
35
  Cb::Clients::Industry
32
36
  end
data/lib/cb/utils/api.rb CHANGED
@@ -73,6 +73,10 @@ module Cb
73
73
  end
74
74
 
75
75
  def append_api_responses(obj, resp)
76
+ #As of ruby 2.2 nil is frozen so stop monkey patching it please -jyeary
77
+ if obj.nil? && obj.frozen?
78
+ obj = Cb::Utils::NilResponse.new
79
+ end
76
80
  meta_class = ensure_non_nil_metavalues(obj)
77
81
 
78
82
  resp.each do |api_key, api_value|
@@ -92,7 +96,6 @@ module Cb
92
96
  meta_class.instance_variable_set(:"@#{meta_name}", api_value)
93
97
  end
94
98
  end
95
-
96
99
  obj.class.send(:attr_reader, 'api_error')
97
100
  obj.instance_variable_set(:@api_error, @api_error)
98
101
 
@@ -0,0 +1,23 @@
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.
11
+ require 'httparty'
12
+ require 'observer'
13
+
14
+ module Cb
15
+ module Utils
16
+ class NilResponse
17
+ def initialize ;end
18
+ def nil?
19
+ true
20
+ end
21
+ end
22
+ end
23
+ end
data/lib/cb/version.rb CHANGED
@@ -9,5 +9,5 @@
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and limitations under the License.
11
11
  module Cb
12
- VERSION = '19.1.1'
12
+ VERSION = '20.0.0'
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cb-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 19.1.1
4
+ version: 20.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The CareerBuilder.com Niche and Consumer Development teams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-24 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -213,8 +213,10 @@ files:
213
213
  - lib/cb/clients/anon_saved_search.rb
214
214
  - lib/cb/clients/application.rb
215
215
  - lib/cb/clients/application_external.rb
216
+ - lib/cb/clients/base.rb
216
217
  - lib/cb/clients/category.rb
217
218
  - lib/cb/clients/company.rb
219
+ - lib/cb/clients/cover_letters.rb
218
220
  - lib/cb/clients/education.rb
219
221
  - lib/cb/clients/employee_types.rb
220
222
  - lib/cb/clients/industry.rb
@@ -373,6 +375,7 @@ files:
373
375
  - lib/cb/utils/country.rb
374
376
  - lib/cb/utils/fluid_attributes.rb
375
377
  - lib/cb/utils/meta_values.rb
378
+ - lib/cb/utils/nil_response.rb
376
379
  - lib/cb/utils/response_array_extractor.rb
377
380
  - lib/cb/utils/response_map.rb
378
381
  - lib/cb/utils/validator.rb