resumator-client 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -13,7 +13,7 @@ Communicates with the resumator API
13
13
  resp = client.jobs
14
14
  puts resp[0].title
15
15
  resp = client.jobs(id: resp[0].id)
16
- ``
16
+ ```
17
17
 
18
18
  Any of the parameters listed in the [API docs](http://www.resumatorapi.com/v1/) should be supported.
19
19
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -0,0 +1,27 @@
1
+ require_relative "../resumator-client"
2
+
3
+ module Resumator
4
+ class Activities
5
+ StatusChange = Struct.new("StatusChange", :time, :date, :from, :to, :position)
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ def status_history(obj_id)
11
+ resp = @client.activities(object_id: obj_id, category: "resume_status")
12
+ resp = [resp] if resp.is_a? Hash # If there is only one activity, it comes back on its own not in an array.
13
+ history = []
14
+ resp.each do |r|
15
+ data = r["action"].scan /"([^"]+)"/
16
+ change = StatusChange.new()
17
+ change.time = r["time"]
18
+ change.date = r["date"]
19
+ change.from = data[0].first
20
+ change.to = data[1].first
21
+ change.position = data[2].first
22
+ history << change
23
+ end
24
+ history
25
+ end
26
+ end
27
+ end
@@ -14,6 +14,9 @@ module Resumator
14
14
  faraday.request :url_encoded # form-encode POST params
15
15
  faraday.response :logger if ENV['DEBUG']
16
16
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
17
+ faraday.request :retry, 2
18
+ faraday.options[:timeout] = 2 # open/read timeout in seconds
19
+ faraday.options[:open_timeout] = 2 # connection open timeout in seconds
17
20
  end
18
21
  @connection.params['apikey'] = @api_key
19
22
  end
@@ -1 +1,3 @@
1
1
  require_relative "resumator-client/client"
2
+ require_relative "resumator-client/activities"
3
+
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "resumator-client"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kurt Nelson"]
@@ -26,11 +26,14 @@ Gem::Specification.new do |s|
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "lib/resumator-client.rb",
29
+ "lib/resumator-client/activities.rb",
29
30
  "lib/resumator-client/client.rb",
30
31
  "resumator-client.gemspec",
32
+ "spec/fixtures/vcr_cassettes/activities.yml",
31
33
  "spec/fixtures/vcr_cassettes/request.yml",
32
34
  "spec/request/resumator_client_spec.rb",
33
35
  "spec/spec_helper.rb",
36
+ "spec/unit/activities_spec.rb",
34
37
  "spec/unit/client_spec.rb"
35
38
  ]
36
39
  s.homepage = "http://github.com/kurtisnelson/resumator"
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.resumatorapi.com/v1/activities/object_id/prospect_20120920202531_GLLJFJ5ES0WFOJFL/category/resume_status?apikey=<RESUMATOR_API_KEY>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - ! '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Access-Control-Allow-Origin:
22
+ - ! '*'
23
+ Content-Type:
24
+ - application/json
25
+ Date:
26
+ - Tue, 30 Oct 2012 18:29:20 GMT
27
+ Server:
28
+ - nginx/1.0.15
29
+ X-Powered-By:
30
+ - PHP/5.3.3
31
+ Content-Length:
32
+ - '752'
33
+ Connection:
34
+ - keep-alive
35
+ body:
36
+ encoding: US-ASCII
37
+ string: ! '[{"id":"activity_20120926143642_XAJ5GJI5PP6JH6QX","category":"resume_status","team_id":"","user_id":"usr_20110609133428_29RPHSXHAKEY2ZXG","object_id":"prospect_20120920202531_GLLJFJ5ES0WFOJFL","action":"Charles
38
+ Quinn changed the status of applicant from \"Reviewed\" to \"Phone
39
+ Screened\" for the job \"Web Application Developer\".","date":"2012-09-26","time":"14:36:42"},{"id":"activity_20120921192110_XR6TWCHZ2SEIUGO6","category":"resume_status","team_id":"","user_id":"usr_20110609133428_29RPHSXHAKEY2ZXG","object_id":"prospect_20120920202531_GLLJFJ5ES0WFOJFL","action":"Charles
40
+ Quinn changed the status of applicant from \"New\" to \"Reviewed\"
41
+ for the job \"Web Application Developer\".","date":"2012-09-21","time":"19:21:10"}]'
42
+ http_version:
43
+ recorded_at: Tue, 30 Oct 2012 18:29:20 GMT
44
+ recorded_with: VCR 2.2.5
data/spec/spec_helper.rb CHANGED
@@ -14,6 +14,7 @@ ENV['RESUMATOR_TEST_KEY'] = "BxO624TAeatcdZfsugE45vNtiMpW28vJ" unless ENV['RESUM
14
14
  VCR.configure do |c|
15
15
  c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
16
16
  c.hook_into :webmock # or :fakeweb
17
+ c.filter_sensitive_data('<RESUMATOR_API_KEY>') { ENV['RESUMATOR_TEST_KEY'] }
17
18
  end
18
19
  RSpec.configure do |config|
19
20
 
@@ -0,0 +1,33 @@
1
+ require_relative "../spec_helper"
2
+
3
+ describe Resumator::Activities do
4
+ before :all do
5
+ VCR.insert_cassette "activities"
6
+ end
7
+ after :all do
8
+ VCR.eject_cassette
9
+ end
10
+
11
+ subject{Resumator::Activities.new(Resumator::Client.new(ENV['RESUMATOR_TEST_KEY']))}
12
+ describe "#status_history" do
13
+ it "doesn't explode" do
14
+ data = subject.status_history("prospect_20120920202531_GLLJFJ5ES0WFOJFL")
15
+ data.first.from.should_not be nil
16
+ data.first.to.should_not be nil
17
+ end
18
+
19
+ it "can handle an empty response" do
20
+ Resumator::Client.any_instance.stub(:activities) { [] }
21
+ data = subject.status_history("stupidValue")
22
+ data.count.should be 0
23
+ end
24
+
25
+ it "can handle a hash response" do
26
+ Resumator::Client.any_instance.stub(:activities) { {"action" => "\"Word\" space \"More\" space \"Cool Job\"", "time" => "noon", "date" => "yesterday"} }
27
+ data = subject.status_history("badValue")
28
+ data.first.time.should eq "noon"
29
+ end
30
+ end
31
+
32
+
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resumator-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -188,11 +188,14 @@ files:
188
188
  - Rakefile
189
189
  - VERSION
190
190
  - lib/resumator-client.rb
191
+ - lib/resumator-client/activities.rb
191
192
  - lib/resumator-client/client.rb
192
193
  - resumator-client.gemspec
194
+ - spec/fixtures/vcr_cassettes/activities.yml
193
195
  - spec/fixtures/vcr_cassettes/request.yml
194
196
  - spec/request/resumator_client_spec.rb
195
197
  - spec/spec_helper.rb
198
+ - spec/unit/activities_spec.rb
196
199
  - spec/unit/client_spec.rb
197
200
  homepage: http://github.com/kurtisnelson/resumator
198
201
  licenses:
@@ -209,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
212
  version: '0'
210
213
  segments:
211
214
  - 0
212
- hash: 3930389205690378076
215
+ hash: 2670977623812130506
213
216
  required_rubygems_version: !ruby/object:Gem::Requirement
214
217
  none: false
215
218
  requirements: