cb-api 6.2.3 → 6.3.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.
@@ -4,37 +4,44 @@ module Cb
4
4
  class SavedSearch
5
5
  def create(saved_search)
6
6
  body = saved_search.create_to_xml
7
- json = cb_client.cb_post(Cb.configuration.uri_saved_search_create, :body => body)
7
+ json = cb_client.cb_post(Cb.configuration.uri_saved_search_create, body: body)
8
8
  singular_model_response(json, saved_search.external_user_id)
9
9
  end
10
10
 
11
11
  def update(saved_search)
12
- body = saved_search.update_to_xml
13
- json = cb_client.cb_post(Cb.configuration.uri_saved_search_update, :body => body)
14
- singular_model_response(json, saved_search.external_user_id, saved_search.external_id)
12
+ body = saved_search.update_to_json
13
+ json = cb_client.cb_put(Cb.configuration.uri_saved_search_update, body: body, headers: headers)
14
+ Responses::SavedSearch::Update.new(json)
15
15
  end
16
16
 
17
17
  def delete(saved_search)
18
18
  body = saved_search.delete_to_xml
19
- json = cb_client.cb_post(Cb.configuration.uri_saved_search_delete, :body => body)
19
+ json = cb_client.cb_post(Cb.configuration.uri_saved_search_delete, body: body)
20
20
  Responses::SavedSearch::Delete.new(json)
21
21
  end
22
22
 
23
23
  def retrieve(oauth_token, external_id)
24
24
  query = retrieve_query(oauth_token)
25
25
  uri = replace_uri_field(Cb.configuration.uri_saved_search_retrieve, ':did', external_id)
26
- json = cb_client.cb_get(uri, :query => query)
26
+ json = cb_client.cb_get(uri, query: query)
27
27
  Responses::SavedSearch::Retrieve.new(json)
28
28
  end
29
29
 
30
30
  def list(oauth_token, hostsite)
31
31
  query = list_query(oauth_token, hostsite)
32
- json = cb_client.cb_get(Cb.configuration.uri_saved_search_list, :query => query)
32
+ json = cb_client.cb_get(Cb.configuration.uri_saved_search_list, query: query)
33
33
  Responses::SavedSearch::List.new(json)
34
34
  end
35
35
 
36
36
  private
37
37
 
38
+ def headers
39
+ {
40
+ "developerkey" => Cb.configuration.dev_key,
41
+ 'Content-Type' => "application/json"
42
+ }
43
+ end
44
+
38
45
  def cb_client
39
46
  @cb_client ||= Cb::Utils::Api.instance
40
47
  end
data/lib/cb/config.rb CHANGED
@@ -55,7 +55,7 @@ module Cb
55
55
  @uri_resume_delete ||= '/v2/resume/delete'
56
56
  @uri_saved_search_retrieve ||= '/cbapi/savedsearches/:did'
57
57
  @uri_saved_search_create ||= '/v2/savedsearch/create'
58
- @uri_saved_search_update ||= '/v2/savedsearch/update'
58
+ @uri_saved_search_update ||= '/cbapi/SavedSearches'
59
59
  @uri_saved_search_delete ||= '/v1/savedsearch/delete'
60
60
  @uri_saved_search_list ||= '/cbapi/savedsearches'
61
61
  @uri_anon_saved_search_create ||= '/v1/anonymoussavedjobsearch/create'
@@ -6,22 +6,23 @@ module Cb
6
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, :job_search_url, :jrdid, :errors, :browser_id, :session_id, :test, :email_address,
9
- :country, :search_parameters, :did
9
+ :country, :search_parameters, :did, :user_oauth_token, :email_delivery_day
10
10
 
11
11
  def initialize(args={})
12
- @host_site = args['HostSite'] || String.new
13
- @cobrand = args['Cobrand'] || String.new
14
- @search_name = args['SearchName'] || String.new
15
- @site_id = args['SiteId'] || String.new
16
- @is_daily_email = args['IsDailyEmail'] || false
17
- @email_delivery_day = args['EmailDeliveryDay'] || String.new
18
- @job_search_url = args['JobSearchUrl'] || String.new
19
- @external_id = args['ExternalID'] || String.new
20
- @external_user_id = args['ExternalUserID'] || String.new
21
- @browser_id = args['BrowserID'] || nil
22
- @session_id = args['SessionID'] || String.new
23
- @email_address = args['EmailAddress'] || String.new
24
- @did = args['DID'] || String.new
12
+ @host_site = args['HostSite'] || args[:host_site] || String.new
13
+ @cobrand = args['Cobrand'] || args[:cobrand] || String.new
14
+ @search_name = args['SearchName'] || args[:search_name] || String.new
15
+ @site_id = args['SiteId'] || args[:site_id] || String.new
16
+ @is_daily_email = args['IsDailyEmail'] || args[:is_daily_email] || false
17
+ @email_delivery_day = args['EmailDeliveryDay'] || args[:email_delivery_day] || String.new
18
+ @job_search_url = args['JobSearchUrl'] || args[:job_search_url] || String.new
19
+ @external_id = args['ExternalID'] || args[:external_id] || String.new
20
+ @external_user_id = args['ExternalUserID'] || args[:external_user_id] || String.new
21
+ @browser_id = args['BrowserID'] || args[:browser_id] || nil
22
+ @session_id = args['SessionID'] || args[:session_id] || String.new
23
+ @email_address = args['EmailAddress'] || args[:email_address] || String.new
24
+ @did = args['DID'] || args[:did] || String.new
25
+ @user_oauth_token = args['userOAuthToken'] || args[:user_oauth_token] || String.new
25
26
  @search_parameters = SearchParameters.new(args['SavedSearchParameters'] || {})
26
27
  end
27
28
 
@@ -56,19 +57,19 @@ module Cb
56
57
  eos
57
58
  end
58
59
 
59
- def update_to_xml
60
- <<-eos
61
- <Request>
62
- <HostSite>#{host_site}</HostSite>
63
- <Cobrand>#{cobrand}</Cobrand>
64
- <SearchName>#{search_name}</SearchName>
65
- #{search_parameters.to_xml}
66
- <IsDailyEmail>#{is_daily_email.to_s.upcase}</IsDailyEmail>
67
- <ExternalID>#{external_id}</ExternalID>
68
- <ExternalUserID>#{external_user_id}</ExternalUserID>
69
- <DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>
70
- </Request>
71
- eos
60
+ def update_to_json
61
+ hash = {
62
+ "DID" => did,
63
+ "SearchName" => search_name,
64
+ "HostSite" => host_site,
65
+ "SiteID" => site_id,
66
+ "Cobrand" => cobrand,
67
+ "IsDailyEmail" => is_daily_email,
68
+ "userOAuthToken" => user_oauth_token,
69
+ "SavedSearchParameters" => search_parameters.to_hash
70
+ }
71
+ hash["EmailDeliveryDay"] = email_delivery_day unless is_daily_email
72
+ hash.to_json
72
73
  end
73
74
 
74
75
  def delete_to_xml
@@ -166,6 +167,31 @@ module Cb
166
167
  </SearchParameters>
167
168
  eos
168
169
  end
170
+
171
+ def to_hash
172
+ {
173
+ "BooleanOperator" => boolean_operator,
174
+ "JobCategory" => job_category,
175
+ "EducationCode" => education_code,
176
+ "EmpType" => emp_type,
177
+ "ExcludeCompanyNames" => exclude_company_names,
178
+ "ExcludeJobTitles" => exclude_job_titles,
179
+ "Country" => country,
180
+ "IndustryCodes" => industry_codes,
181
+ "JobTitle" => job_title,
182
+ "Keywords" => keywords,
183
+ "Location" => location,
184
+ "OrderBy" => order_by,
185
+ "OrderDirection" => order_direction,
186
+ "PayHigh" => pay_high,
187
+ "PayLow" => pay_low,
188
+ "PostedWithin" => posted_within,
189
+ "Radius" => radius,
190
+ "SpecificEducation" => specific_education,
191
+ "ExcludeNational" => exclude_national,
192
+ "PayInfoOnly" => pay_info_only
193
+ }
194
+ end
169
195
  end
170
196
  end
171
197
 
@@ -0,0 +1,33 @@
1
+ module Cb
2
+ module Responses
3
+ module SavedSearch
4
+ class Update < ApiResponse
5
+
6
+ protected
7
+
8
+ def validate_api_hash
9
+ required_response_field(collection_node, response)
10
+ end
11
+
12
+ def hash_containing_metadata
13
+ response
14
+ end
15
+
16
+ def extract_models
17
+ Models::SavedSearch.new(model_hash)
18
+ end
19
+
20
+ private
21
+
22
+ def collection_node
23
+ 'Results'
24
+ end
25
+
26
+ def model_hash
27
+ response[collection_node][0]
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
data/lib/cb/utils/api.rb CHANGED
@@ -33,9 +33,7 @@ module Cb
33
33
  cb_event(:cb_get_before, path, options, nil)
34
34
  response = self.class.get(path, options)
35
35
  cb_event(:cb_get_after, path, options, response)
36
- validated_response = ResponseValidator.validate(response)
37
- set_api_error(validated_response)
38
- validated_response
36
+ validate_response(response)
39
37
  end
40
38
 
41
39
  def cb_post(path, options={})
@@ -43,9 +41,7 @@ module Cb
43
41
  cb_event(:cb_post_before, path, options, nil)
44
42
  response = self.class.post(path, options)
45
43
  cb_event(:cb_post_after, path, options, response)
46
- validated_response = ResponseValidator.validate(response)
47
- set_api_error(validated_response)
48
- validated_response
44
+ validate_response(response)
49
45
  end
50
46
 
51
47
  def cb_put(path, options={})
@@ -53,9 +49,7 @@ module Cb
53
49
  cb_event(:cb_put_before, path, options, nil)
54
50
  response = self.class.put(path, options)
55
51
  cb_event(:cb_put_after, path, options, response)
56
- validated_response = ResponseValidator.validate(response)
57
- set_api_error(validated_response)
58
- validated_response
52
+ validate_response(response)
59
53
  end
60
54
 
61
55
  def append_api_responses(obj, resp)
@@ -106,6 +100,12 @@ module Cb
106
100
 
107
101
  private
108
102
 
103
+ def validate_response(response)
104
+ validated_response = ResponseValidator.validate(response)
105
+ set_api_error(validated_response)
106
+ validated_response
107
+ end
108
+
109
109
  def api_call_model(api_call_type, path, options, response)
110
110
  Cb::Models::ApiCall.new(api_call_type, path, options, response)
111
111
  end
data/lib/cb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cb
2
- VERSION = '6.2.3'
2
+ VERSION = '6.3.0'
3
3
  end
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: 6.2.3
4
+ version: 6.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-21 00:00:00.000000000 Z
12
+ date: 2014-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -225,6 +225,7 @@ files:
225
225
  - lib/cb/responses/saved_search/list.rb
226
226
  - lib/cb/responses/saved_search/singular.rb
227
227
  - lib/cb/responses/saved_search/delete.rb
228
+ - lib/cb/responses/saved_search/update.rb
228
229
  - lib/cb/responses/saved_search/retrieve.rb
229
230
  - lib/cb/responses/employee_types/search.rb
230
231
  - lib/cb/responses/errors.rb