cb-api 5.4.0 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -5,6 +5,18 @@ Now that you have a key, lets get to the good stuff.
5
5
  You can find an example rails site that uses the gem here:
6
6
  https://github.com/cbdr/ruby-cb-api-demo
7
7
 
8
+ Installation
9
+ ================
10
+
11
+ Install required gems:
12
+
13
+ gem install iconv
14
+ gem install cb-api
15
+
16
+ Require the library in your Ruby script:
17
+
18
+ require 'cb'
19
+
8
20
  Configuration
9
21
  ================
10
22
  Set your dev key, and any other configuration settings in a place that will run prior to your API calls.
@@ -11,7 +11,13 @@ module Cb
11
11
  Cb::Responses::User::CheckExisting.new(response)
12
12
  end
13
13
 
14
- def retrieve external_id, test_mode = false
14
+ def temporary_password(external_id)
15
+ query = { 'ExternalID' => external_id }
16
+ response = api_client.cb_get(Cb.configuration.uri_user_temp_password, query: query)
17
+ Cb::Responses::User::TemporaryPassword.new(response)
18
+ end
19
+
20
+ def retrieve(external_id, test_mode = false)
15
21
  my_api = Cb::Utils::Api.new
16
22
  json_hash = my_api.cb_post Cb.configuration.uri_user_retrieve, :body => build_retrieve_request(external_id, true)
17
23
  if json_hash.has_key? 'ResponseUserInfo'
@@ -24,7 +30,7 @@ module Cb
24
30
  my_api.append_api_responses user, json_hash
25
31
  end
26
32
 
27
- def change_password external_id, old_password, new_password, test_mode = false
33
+ def change_password(external_id, old_password, new_password, test_mode = false)
28
34
  result = false
29
35
  my_api = Cb::Utils::Api.new
30
36
  json_hash = my_api.cb_post Cb.configuration.uri_user_change_password, :body => build_change_password_request(external_id, old_password, new_password, test_mode)
@@ -39,7 +45,7 @@ module Cb
39
45
  my_api.append_api_responses result, json_hash
40
46
  end
41
47
 
42
- def delete external_id, password, test_mode = false
48
+ def delete(external_id, password, test_mode = false)
43
49
  result = false
44
50
  my_api = Cb::Utils::Api.new
45
51
  json_hash = my_api.cb_post Cb.configuration.uri_user_delete, :body => build_delete_request(external_id, password, test_mode)
@@ -67,7 +73,7 @@ module Cb
67
73
  eos
68
74
  end
69
75
 
70
- def build_retrieve_request external_id, test_mode
76
+ def build_retrieve_request(external_id, test_mode)
71
77
  <<-eos
72
78
  <Request>
73
79
  <DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>
@@ -77,7 +83,7 @@ module Cb
77
83
  eos
78
84
  end
79
85
 
80
- def build_change_password_request external_id, old_password, new_password, test_mode
86
+ def build_change_password_request(external_id, old_password, new_password, test_mode)
81
87
  <<-eos
82
88
  <Request>
83
89
  <DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>
@@ -89,7 +95,7 @@ module Cb
89
95
  eos
90
96
  end
91
97
 
92
- def build_delete_request external_id, password, test_mode
98
+ def build_delete_request(external_id, password, test_mode)
93
99
  <<-eos
94
100
  <Request>
95
101
  <DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>
@@ -8,7 +8,7 @@ module Cb
8
8
  :uri_recommendation_for_company,
9
9
  :uri_application, :uri_application_submit,
10
10
  :uri_application_external,
11
- :uri_application_registered, :uri_user_change_password,
11
+ :uri_application_registered, :uri_user_change_password, :uri_user_temp_password,
12
12
  :uri_user_delete, :uri_user_retrieve, :uri_user_check_existing,
13
13
  :uri_job_branding,
14
14
  :uri_resume_own_all, :uri_resume_retrieve,
@@ -44,6 +44,7 @@ module Cb
44
44
  @uri_user_delete ||= '/v2/User/delete'
45
45
  @uri_user_retrieve ||= '/v2/user/retrieve'
46
46
  @uri_user_check_existing ||= '/v2/user/checkexisting'
47
+ @uri_user_temp_password ||= '/v1/user/temporarypassword'
47
48
  @uri_job_branding ||= '/branding'
48
49
  @uri_resume_own_all ||= '/v2/resume/ownall'
49
50
  @uri_resume_retrieve ||= '/v2/resume/retrieve'
@@ -29,7 +29,21 @@ module Cb
29
29
  end
30
30
 
31
31
  def parsed_time_elapsed
32
- response.include?('TimeElapsed') ? response['TimeElapsed'].to_f : nil
32
+ elapsed_node_parsable? ? response[elapsed_node].to_f : nil
33
+ end
34
+
35
+ def elapsed_node_parsable?
36
+ response.include?(elapsed_node) &&
37
+ response[elapsed_node].respond_to?(:to_f) &&
38
+ timing_parses_to_nonzero?
39
+ end
40
+
41
+ def timing_parses_to_nonzero?
42
+ response[elapsed_node].to_f != 0.0
43
+ end
44
+
45
+ def elapsed_node
46
+ 'TimeElapsed'
33
47
  end
34
48
  end
35
49
 
@@ -0,0 +1,38 @@
1
+ module Cb
2
+ module Responses
3
+ module User
4
+
5
+ class TemporaryPassword < ApiResponse
6
+
7
+ # there's really no response model here, so let's just
8
+ # pass the new password along in a way that makes sense.
9
+ alias_method :temp_password, :model
10
+
11
+ protected
12
+
13
+ def validate_api_hash
14
+ required_response_field(password_node, response)
15
+ end
16
+
17
+ def extract_models
18
+ response[password_node]
19
+ end
20
+
21
+ def hash_containing_metadata
22
+ response
23
+ end
24
+
25
+ def raise_on_timing_parse_error
26
+ false
27
+ end
28
+
29
+ private
30
+
31
+ def password_node
32
+ 'TemporaryPassword'
33
+ end
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module Cb
2
- VERSION = '5.4.0'
2
+ VERSION = '5.5.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: 5.4.0
4
+ version: 5.5.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-03-11 00:00:00.000000000 Z
12
+ date: 2014-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -218,6 +218,7 @@ files:
218
218
  - lib/cb/responses/spot/retrieve_response.rb
219
219
  - lib/cb/responses/api_response.rb
220
220
  - lib/cb/responses/user/check_existing.rb
221
+ - lib/cb/responses/user/temporary_password.rb
221
222
  - lib/cb/responses/timing.rb
222
223
  - lib/cb/responses/saved_search/list.rb
223
224
  - lib/cb/responses/saved_search/singular.rb