cb-api 7.0.0 → 7.1.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.
- data/README.md +21 -1
- data/lib/cb/client.rb +3 -2
- data/lib/cb/requests/anonymous_saved_search/create.rb +66 -0
- data/lib/cb/requests/anonymous_saved_search/delete.rb +29 -0
- data/lib/cb/utils/api.rb +10 -18
- data/lib/cb/utils/response_map.rb +3 -0
- data/lib/cb/version.rb +1 -1
- metadata +4 -2
data/README.md
CHANGED
@@ -61,4 +61,24 @@ You will also get meta data regarding the search itself (helpful for pagination)
|
|
61
61
|
|
62
62
|
Coming Soon
|
63
63
|
================
|
64
|
-
|
64
|
+
The way that requests are handled is being completely redone. You will now only need to instantiate a single client class and pass it a request object.
|
65
|
+
|
66
|
+
You may now pass a block that will be executed before and after each API call. This will provide the same information that the Observer methods do.
|
67
|
+
|
68
|
+
client = Cb::Client.new { |request_metadata| storage_device.add(request_metadata) }
|
69
|
+
|
70
|
+
Or just call it without the block if you don't care about an individual call's observer info
|
71
|
+
|
72
|
+
client = Cb::Client.new
|
73
|
+
|
74
|
+
Pass it a request object, and you will receive the appropriate response object back
|
75
|
+
|
76
|
+
request = Cb::Requests::Endpoint::CallName.new( { key1: 'value1', key2: 'value2' } )
|
77
|
+
response = client.execute request
|
78
|
+
|
79
|
+
Currently, this workflow only works on the following endpoints:
|
80
|
+
|
81
|
+
* User
|
82
|
+
* Anonymous Saved Search
|
83
|
+
|
84
|
+
Look here for future updates on this refactor!
|
data/lib/cb/client.rb
CHANGED
@@ -15,7 +15,8 @@ module Cb
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def call_api(request)
|
18
|
-
|
18
|
+
http_wrapper.execute_http_request(
|
19
|
+
request.http_method,
|
19
20
|
request.endpoint_uri,
|
20
21
|
{
|
21
22
|
query: request.query,
|
@@ -25,7 +26,7 @@ module Cb
|
|
25
26
|
&@callback_block)
|
26
27
|
end
|
27
28
|
|
28
|
-
def
|
29
|
+
def http_wrapper
|
29
30
|
Cb::Utils::Api.instance
|
30
31
|
end
|
31
32
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative '../base'
|
2
|
+
|
3
|
+
module Cb
|
4
|
+
module Requests
|
5
|
+
module AnonymousSavedSearch
|
6
|
+
class Create < Base
|
7
|
+
|
8
|
+
def endpoint_uri
|
9
|
+
Cb.configuration.uri_anon_saved_search_create
|
10
|
+
end
|
11
|
+
|
12
|
+
def http_method
|
13
|
+
:post
|
14
|
+
end
|
15
|
+
|
16
|
+
def body
|
17
|
+
<<-eos
|
18
|
+
<Request>
|
19
|
+
<HostSite>#{@args[:host_site]}</HostSite>
|
20
|
+
<Cobrand>#{@args[:cobrand]}</Cobrand>
|
21
|
+
<BrowserID>#{@args[:browser_id]}</BrowserID>
|
22
|
+
<SessionID>#{@args[:session_id]}</SessionID>
|
23
|
+
<Test>#{(@args[:test] || false).to_s}</Test>
|
24
|
+
<EmailAddress>#{@args[:email_address]}</EmailAddress>
|
25
|
+
<SearchName>#{@args[:search_name]}</SearchName>
|
26
|
+
#{search_parameters(@args[:search_parameters]) unless @args[:search_parameters].nil?}
|
27
|
+
<IsDailyEmail>#{@args[:is_daily_email]}</IsDailyEmail>
|
28
|
+
<DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>
|
29
|
+
</Request>
|
30
|
+
eos
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def search_parameters(args)
|
36
|
+
<<-eos
|
37
|
+
<SearchParameters>
|
38
|
+
<BooleanOperator>#{args[:boolean_operator]}</BooleanOperator>
|
39
|
+
<JobCategory>#{args[:job_category]}</JobCategory>
|
40
|
+
<EducationCode>#{args[:education_code]}</EducationCode>
|
41
|
+
<EmpType>#{args[:emp_type]}</EmpType>
|
42
|
+
<ExcludeCompanyNames>#{args[:exclude_company_names]}</ExcludeCompanyNames>
|
43
|
+
<ExcludeJobTitles>#{args[:exclude_job_titles]}</ExcludeJobTitles>
|
44
|
+
<ExcludeKeywords>#{args[:exclude_keywords]}</ExcludeKeywords>
|
45
|
+
<Country>#{args[:country]}</Country>
|
46
|
+
<IndustryCodes>#{args[:industry_codes]}</IndustryCodes>
|
47
|
+
<JobTitle>#{args[:job_title]}</JobTitle>
|
48
|
+
<Keywords>#{args[:keywords]}</Keywords>
|
49
|
+
<Location>#{args[:location]}</Location>
|
50
|
+
<OrderBy>#{args[:order_by]}</OrderBy>
|
51
|
+
<OrderDirection>#{args[:order_direction]}</OrderDirection>
|
52
|
+
<PayHigh>#{args[:pay_high]}</PayHigh>
|
53
|
+
<PayLow>#{args[:pay_low]}</PayLow>
|
54
|
+
<PostedWithin>#{args[:posted_within]}</PostedWithin>
|
55
|
+
<Radius>#{args[:radius]}</Radius>
|
56
|
+
<SpecificEducation>#{args[:specific_education]}</SpecificEducation>
|
57
|
+
<ExcludeNational>#{args[:exclude_national]}</ExcludeNational>
|
58
|
+
<PayInfoOnly>#{args[:pay_info_only]}</PayInfoOnly>
|
59
|
+
</SearchParameters>
|
60
|
+
eos
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative '../base'
|
2
|
+
|
3
|
+
module Cb
|
4
|
+
module Requests
|
5
|
+
module AnonymousSavedSearch
|
6
|
+
class Delete < Base
|
7
|
+
|
8
|
+
def endpoint_uri
|
9
|
+
Cb.configuration.uri_anon_saved_search_delete
|
10
|
+
end
|
11
|
+
|
12
|
+
def http_method
|
13
|
+
:post
|
14
|
+
end
|
15
|
+
|
16
|
+
def body
|
17
|
+
<<-eos
|
18
|
+
<Request>
|
19
|
+
<ExternalID>#{@args[:external_id]}</ExternalID>
|
20
|
+
<DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>
|
21
|
+
<Test>#{(@args[:test] || false).to_s}</Test>
|
22
|
+
</Request>
|
23
|
+
eos
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/cb/utils/api.rb
CHANGED
@@ -29,34 +29,26 @@ module Cb
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def cb_get(path, options={}, &block)
|
32
|
-
|
33
|
-
cb_event(:cb_get_before, path, options, nil, &block)
|
34
|
-
response = self.class.get(path, options)
|
35
|
-
cb_event(:cb_get_after, path, options, response, &block)
|
36
|
-
validate_response(response)
|
32
|
+
execute_http_request(:get, path, options, &block)
|
37
33
|
end
|
38
34
|
|
39
35
|
def cb_post(path, options={}, &block)
|
40
|
-
|
41
|
-
cb_event(:cb_post_before, path, options, nil, &block)
|
42
|
-
response = self.class.post(path, options)
|
43
|
-
cb_event(:cb_post_after, path, options, response, &block)
|
44
|
-
validate_response(response)
|
36
|
+
execute_http_request(:post, path, options, &block)
|
45
37
|
end
|
46
38
|
|
47
39
|
def cb_put(path, options={}, &block)
|
48
|
-
|
49
|
-
cb_event(:cb_put_before, path, options, nil, &block)
|
50
|
-
response = self.class.put(path, options)
|
51
|
-
cb_event(:cb_put_after, path, options, response, &block)
|
52
|
-
validate_response(response)
|
40
|
+
execute_http_request(:put, path, options, &block)
|
53
41
|
end
|
54
42
|
|
55
43
|
def cb_delete(path, options={}, &block)
|
44
|
+
execute_http_request(:delete, path, options, &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
def execute_http_request(http_method, path, options={}, &block)
|
56
48
|
self.class.base_uri Cb.configuration.base_uri
|
57
|
-
cb_event(:
|
58
|
-
response = self.class.
|
59
|
-
cb_event(:
|
49
|
+
cb_event(:"cb_#{http_method.to_s}_before", path, options, nil, &block)
|
50
|
+
response = self.class.method(http_method).call(path, options)
|
51
|
+
cb_event(:"cb_#{http_method.to_s}_after", path, options, response, &block)
|
60
52
|
validate_response(response)
|
61
53
|
end
|
62
54
|
|
@@ -12,6 +12,9 @@ module Cb
|
|
12
12
|
|
13
13
|
def response_hash
|
14
14
|
{
|
15
|
+
Cb::Requests::AnonymousSavedSearch::Create => Cb::Responses::AnonymousSavedSearch::Create,
|
16
|
+
Cb::Requests::AnonymousSavedSearch::Delete => Cb::Responses::AnonymousSavedSearch::Delete,
|
17
|
+
|
15
18
|
Cb::Requests::User::ChangePassword => Cb::Responses::User::ChangePassword,
|
16
19
|
Cb::Requests::User::CheckExisting => Cb::Responses::User::CheckExisting,
|
17
20
|
Cb::Requests::User::Delete => Cb::Responses::User::Delete,
|
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: 7.
|
4
|
+
version: 7.1.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-05-
|
12
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -268,6 +268,8 @@ files:
|
|
268
268
|
- lib/cb/models/implementations/spot.rb
|
269
269
|
- lib/cb/models/implementations/email_subscription.rb
|
270
270
|
- lib/cb/models/api_call_model.rb
|
271
|
+
- lib/cb/requests/anonymous_saved_search/delete.rb
|
272
|
+
- lib/cb/requests/anonymous_saved_search/create.rb
|
271
273
|
- lib/cb/requests/user/check_existing.rb
|
272
274
|
- lib/cb/requests/user/delete.rb
|
273
275
|
- lib/cb/requests/user/change_password.rb
|