greenhouse_io 2.3.1 → 2.4.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: 9dd09e95805fe4b610dce4448a7caeaf045090aa
4
- data.tar.gz: 141396f8491cfbf28f193c69dcec7af6d8f319b1
3
+ metadata.gz: f943bd5a8beb683ca3d3e7093ab0da59b92dc080
4
+ data.tar.gz: 61b72fbb33e6b07ff1182b73899820bbac253551
5
5
  SHA512:
6
- metadata.gz: f7289af592c6275e6577a1a9236088e875100099a8301a69c5f9c6d1f9e2bdf15f627cdcd754e5af0b6a6ced6d63fff9cd36b1c698493aa12b5d0c00ed087cb2
7
- data.tar.gz: 076bcb038e271ff443ed58cef5769f4e9be601e6d1de620c6942201799b0d29b88c0814d3804bf887e0d2ec8e3722311c469e4096c2144f96f264c5c8ae65875
6
+ metadata.gz: 1a60fbbbc126b6972486f2acbbae28ae86aa8b7d2ad4f16b281941279c239be64116b983e44d836a3ab6243b7df49685219bd8d2f2c958b55f7edcaa8f16cca0
7
+ data.tar.gz: 998ddf413dc68f561770df31e79211bd384f0219b3e87270cb5f5920bce64b4e400fb0565373ec2aa6dc29824dba43f7dfa639df0f286fa28d5c57b766d61b2b
data/.gitignore CHANGED
@@ -13,4 +13,7 @@ pkg
13
13
  rdoc
14
14
  spec/reports
15
15
  tmp
16
- .ruby-*
16
+ .ruby-*
17
+ *.swp
18
+ *.un~
19
+ tags
data/CHANGES.md CHANGED
@@ -2,9 +2,18 @@
2
2
 
3
3
  This project follows [semantic versioning](http://semver.org/). This changelog follows suggestions from [keepachangelog.com](http://keepachangelog.com/).
4
4
 
5
- ## Version 2.3.1
5
+ ## Version 2.4.0
6
6
  Released 2016-04-20.
7
7
 
8
+ #### Added
9
+ - Exposed `link` HTTP header in `GreenhouseIo::Client`.
10
+
11
+ #### Removed
12
+ - Removed dependency on `multi_json` in favor of Ruby's `json` module.
13
+
14
+ ## Version 2.3.1
15
+ Released 2016-04-20. In retrospect, this should've been a minor version bump instead of a minor version since this added functionality, not a bug fix.
16
+
8
17
  #### Added
9
18
  - Added method `create_candidate_note`. Thanks for contributing, [@jleven](https://github.com/jleven)!
10
19
 
data/README.md CHANGED
@@ -118,14 +118,14 @@ gh_client = GreenhouseIo::Client.new
118
118
 
119
119
  #### Listing candidates
120
120
 
121
- ```
121
+ ```ruby
122
122
  gh_client.candidates
123
123
  ```
124
124
 
125
125
  #### Creating a candidate note
126
126
  Use this method to attach a new note to a candidate.
127
127
 
128
- ```
128
+ ```ruby
129
129
  candidate_id = 4567
130
130
  author_id = 123 # ID of the user who wrote this note
131
131
  note = {
@@ -154,6 +154,16 @@ All `GreenhouseIo::Client` API methods accept `:page` and `:per_page` options to
154
154
  gh_client.offices(id, page: 1, per_page: 2)
155
155
  ```
156
156
 
157
+ You can determine the last page and next page by looking at the `link` header from the last response:
158
+
159
+ ```ruby
160
+ gh_client.link
161
+
162
+ # => '<https://harvest.greenhouse.io/v1/candidates?page=2&per_page=100>; rel="next",<https://harvest.greenhouse.io/v1/candidates?page=142&per_page=100>; rel="last"'
163
+ ```
164
+
165
+ You'll need to manually parse the `next` and `last` links to tell what the next or final page number will be.
166
+
157
167
  #### Available methods
158
168
 
159
169
  Methods for which an `id` is optional:
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency('httmultiparty', '~> 0.3.16')
22
- spec.add_dependency('multi_json', '~>1.11.2')
23
22
  spec.required_ruby_version = '>= 1.9.3'
24
23
 
25
24
  spec.add_development_dependency "bundler", "~> 1.3"
@@ -1,5 +1,4 @@
1
1
  require 'httmultiparty'
2
- require 'multi_json'
3
2
  require 'json'
4
3
 
5
4
  require "greenhouse_io/version"
@@ -9,7 +9,7 @@ module GreenhouseIo
9
9
  end
10
10
 
11
11
  def parse_json(response)
12
- MultiJson.load(response.body, symbolize_keys: GreenhouseIo.configuration.symbolize_keys)
12
+ JSON.parse(response.body, symbolize_names: GreenhouseIo.configuration.symbolize_keys)
13
13
  end
14
14
 
15
15
  def basic_auth
@@ -5,7 +5,7 @@ module GreenhouseIo
5
5
 
6
6
  PERMITTED_OPTIONS = [:page, :per_page, :job_id]
7
7
 
8
- attr_accessor :api_token, :rate_limit, :rate_limit_remaining
8
+ attr_accessor :api_token, :rate_limit, :rate_limit_remaining, :link
9
9
  base_uri 'https://harvest.greenhouse.io/v1'
10
10
 
11
11
  def initialize(api_token = nil)
@@ -92,7 +92,7 @@ module GreenhouseIo
92
92
  :basic_auth => basic_auth
93
93
  })
94
94
 
95
- set_rate_limits(response.headers)
95
+ set_headers_info(response.headers)
96
96
 
97
97
  if response.code == 200
98
98
  parse_json(response)
@@ -108,7 +108,7 @@ module GreenhouseIo
108
108
  :headers => headers
109
109
  })
110
110
 
111
- set_rate_limits(response.headers)
111
+ set_headers_info(response.headers)
112
112
 
113
113
  if response.code == 200
114
114
  parse_json(response)
@@ -117,9 +117,10 @@ module GreenhouseIo
117
117
  end
118
118
  end
119
119
 
120
- def set_rate_limits(headers)
120
+ def set_headers_info(headers)
121
121
  self.rate_limit = headers['x-ratelimit-limit'].to_i
122
122
  self.rate_limit_remaining = headers['x-ratelimit-remaining'].to_i
123
+ self.link = headers['link'].to_s
123
124
  end
124
125
  end
125
126
  end
@@ -1,3 +1,3 @@
1
1
  module GreenhouseIo
2
- VERSION = "2.3.1"
2
+ VERSION = "2.4.0"
3
3
  end
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://123FakeToken:@harvest.greenhouse.io/v1/candidates
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Content-Type:
16
+ - application/json;charset=utf-8
17
+ Date:
18
+ - Wed, 23 Apr 2014 23:23:01 GMT
19
+ Link:
20
+ - "<https://harvest.greenhouse.io/v1/candidates/?page=1&per_page=100>; rel=\"last\""
21
+ Status:
22
+ - 200 OK
23
+ X-Content-Type-Options:
24
+ - nosniff
25
+ X-Ratelimit-Limit:
26
+ - '20'
27
+ X-Ratelimit-Remaining:
28
+ - '19'
29
+ Content-Length:
30
+ - '68109'
31
+ Connection:
32
+ - keep-alive
33
+ body:
34
+ encoding: UTF-8
35
+ string: "[{\"id\":1,\"first_name\":\"User\",\"last_name\":\"One\",\"company\":null,\"title\":null,\"created_at\":\"2013-10-17T15:32:26Z\",\"last_activity\":\"2013-10-30T14:37:10Z\",\"photo_url\":null,\"attachments\":[{\"filename\":\"USER_1_Resume_10.13.pdf\",\"url\":\"https://resumes.com/USER_1_Resume_10.13.pdf\",\"type\":\"cover_letter\"},{\"filename\":\"USER_1_Resume_10.13.pdf\",\"url\":\"https://prod-heroku.s3.amazonaws.com/person_attachments/USER_1_Resume_10.13.pdf\",\"type\":\"resume\"}],\"application_ids\":[1234],\"phone_numbers\":[{\"value\":\"123-345-5678\",\"type\":\"other\"}],\"addresses\":[],\"email_addresses\":[{\"value\":\"user_one@email.com\",\"type\":\"personal\"}],\"website_addresses\":[],\"social_media_addresses\":[]}]"
36
+ http_version:
37
+ recorded_at: Wed, 23 Apr 2014 23:23:02 GMT
38
+ recorded_with: VCR 2.5.0
@@ -43,22 +43,23 @@ describe GreenhouseIo::Client do
43
43
  end
44
44
  end
45
45
 
46
- describe "#set_rate_limits" do
46
+ describe "#set_headers_info" do
47
47
  before do
48
- @headers = {
49
- 'x-ratelimit-limit' => '20',
50
- 'x-ratelimit-remaining' => '20'
51
- }
48
+ VCR.use_cassette('client/headers') do
49
+ @client.candidates
50
+ end
52
51
  end
53
52
 
54
53
  it "sets the rate limit" do
55
- @client.send(:set_rate_limits, @headers)
56
54
  expect(@client.rate_limit).to eq(20)
57
55
  end
58
56
 
59
57
  it "sets the remaining rate limit" do
60
- @client.send(:set_rate_limits, @headers)
61
- expect(@client.rate_limit_remaining).to eq(20)
58
+ expect(@client.rate_limit_remaining).to eq(19)
59
+ end
60
+
61
+ it "sets rest link" do
62
+ expect(@client.link).to eq('<https://harvest.greenhouse.io/v1/candidates/?page=1&per_page=100>; rel="last"')
62
63
  end
63
64
  end
64
65
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: greenhouse_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greenhouse Software
@@ -25,20 +25,6 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.3.16
28
- - !ruby/object:Gem::Dependency
29
- name: multi_json
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: 1.11.2
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: 1.11.2
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: bundler
44
30
  requirement: !ruby/object:Gem::Requirement
@@ -147,6 +133,7 @@ files:
147
133
  - spec/fixtures/cassettes/client/create_candidate_note_invalid_user_id.yml
148
134
  - spec/fixtures/cassettes/client/department.yml
149
135
  - spec/fixtures/cassettes/client/departments.yml
136
+ - spec/fixtures/cassettes/client/headers.yml
150
137
  - spec/fixtures/cassettes/client/job.yml
151
138
  - spec/fixtures/cassettes/client/job_post.yml
152
139
  - spec/fixtures/cassettes/client/jobs.yml
@@ -218,6 +205,7 @@ test_files:
218
205
  - spec/fixtures/cassettes/client/create_candidate_note_invalid_user_id.yml
219
206
  - spec/fixtures/cassettes/client/department.yml
220
207
  - spec/fixtures/cassettes/client/departments.yml
208
+ - spec/fixtures/cassettes/client/headers.yml
221
209
  - spec/fixtures/cassettes/client/job.yml
222
210
  - spec/fixtures/cassettes/client/job_post.yml
223
211
  - spec/fixtures/cassettes/client/jobs.yml