greenhouse_io-gitlab 2.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +11 -0
- data/CHANGES.md +41 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +200 -0
- data/Rakefile +8 -0
- data/greenhouse_io.gemspec +29 -0
- data/lib/greenhouse_io.rb +9 -0
- data/lib/greenhouse_io/api.rb +19 -0
- data/lib/greenhouse_io/api/client.rb +145 -0
- data/lib/greenhouse_io/api/job_board.rb +66 -0
- data/lib/greenhouse_io/configuration.rb +21 -0
- data/lib/greenhouse_io/error.rb +10 -0
- data/lib/greenhouse_io/version.rb +3 -0
- data/spec/fixtures/cassettes/apply_to_job.yml +44 -0
- data/spec/fixtures/cassettes/client/activity_feed.yml +36 -0
- data/spec/fixtures/cassettes/client/all_scorecards.yml +38 -0
- data/spec/fixtures/cassettes/client/application.yml +36 -0
- data/spec/fixtures/cassettes/client/application_by_job_id.yml +139 -0
- data/spec/fixtures/cassettes/client/applications.yml +43 -0
- data/spec/fixtures/cassettes/client/candidate.yml +36 -0
- data/spec/fixtures/cassettes/client/candidates.yml +38 -0
- data/spec/fixtures/cassettes/client/create_candidate_note.yml +42 -0
- data/spec/fixtures/cassettes/client/create_candidate_note_invalid_candidate_id.yml +42 -0
- data/spec/fixtures/cassettes/client/create_candidate_note_invalid_missing_field.yml +42 -0
- data/spec/fixtures/cassettes/client/create_candidate_note_invalid_on_behalf_of.yml +42 -0
- data/spec/fixtures/cassettes/client/create_candidate_note_invalid_user_id.yml +42 -0
- data/spec/fixtures/cassettes/client/current_offer_for_application.yml +40 -0
- data/spec/fixtures/cassettes/client/department.yml +36 -0
- data/spec/fixtures/cassettes/client/departments.yml +38 -0
- data/spec/fixtures/cassettes/client/headers.yml +38 -0
- data/spec/fixtures/cassettes/client/job.yml +37 -0
- data/spec/fixtures/cassettes/client/job_post.yml +49 -0
- data/spec/fixtures/cassettes/client/jobs.yml +39 -0
- data/spec/fixtures/cassettes/client/offer.yml +48 -0
- data/spec/fixtures/cassettes/client/offers.yml +51 -0
- data/spec/fixtures/cassettes/client/offers_for_application.yml +40 -0
- data/spec/fixtures/cassettes/client/office.yml +36 -0
- data/spec/fixtures/cassettes/client/offices.yml +46 -0
- data/spec/fixtures/cassettes/client/scheduled_interviews.yml +38 -0
- data/spec/fixtures/cassettes/client/scorecards.yml +37 -0
- data/spec/fixtures/cassettes/client/source.yml +39 -0
- data/spec/fixtures/cassettes/client/sources.yml +37 -0
- data/spec/fixtures/cassettes/client/stages.yml +36 -0
- data/spec/fixtures/cassettes/client/user.yml +36 -0
- data/spec/fixtures/cassettes/client/users.yml +38 -0
- data/spec/fixtures/cassettes/department.yml +45 -0
- data/spec/fixtures/cassettes/departments.yml +45 -0
- data/spec/fixtures/cassettes/invalid_application.yml +43 -0
- data/spec/fixtures/cassettes/invalid_application_id.yml +44 -0
- data/spec/fixtures/cassettes/invalid_id.yml +40 -0
- data/spec/fixtures/cassettes/invalid_organization.yml +40 -0
- data/spec/fixtures/cassettes/job.yml +80 -0
- data/spec/fixtures/cassettes/job_with_questions.yml +85 -0
- data/spec/fixtures/cassettes/jobs.yml +44 -0
- data/spec/fixtures/cassettes/jobs_with_content.yml +118 -0
- data/spec/fixtures/cassettes/office.yml +45 -0
- data/spec/fixtures/cassettes/offices.yml +45 -0
- data/spec/greenhouse_io/api/client_spec.rb +679 -0
- data/spec/greenhouse_io/api/job_board_spec.rb +187 -0
- data/spec/greenhouse_io/configuration_spec.rb +71 -0
- data/spec/greenhouse_io/error_spec.rb +23 -0
- data/spec/spec_helper.rb +22 -0
- metadata +242 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 51f9bbfcc363d99b8b8f920ff67c4141eb410e66809cd76ee1238e595ef7da02
|
4
|
+
data.tar.gz: 6a715a12268273408527ed832fe17e4327407ae9042a02d815aae449d46ff178
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a379e7d14cd34c4f48064197c54d35ef581ba578553108e4a1ce739b72f4bbde670133846b6f38c49e0fa3a299385add1ed75ac092e601a312b8d47428e2343
|
7
|
+
data.tar.gz: adc5a9436b3becd331dfac6ba3cf1506dc82c7d67fd69ab3a9efaef8b2ec9f384d17e7cf85c93e0def5129c8fec1e2876861d75ec87a7bd7c44133b9fb887332
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGES.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# greenhouse_io changelog
|
2
|
+
|
3
|
+
This project follows [semantic versioning](http://semver.org/). This changelog follows suggestions from [keepachangelog.com](http://keepachangelog.com/).
|
4
|
+
|
5
|
+
## Version 2.5.0
|
6
|
+
Released 2016-05-31. Contributed by [@theshanx](https://github.com/theshanx). Thanks! :)
|
7
|
+
|
8
|
+
#### Added
|
9
|
+
- Added methods for retrieving offers for an application: `current_offer_for_application` and `offers_for_application`
|
10
|
+
|
11
|
+
## Version 2.4.0
|
12
|
+
Released 2016-04-20. Contributed by [@mariochavez](https://github.com/mariochavez) -- thank you!
|
13
|
+
|
14
|
+
#### Added
|
15
|
+
- Exposed `link` HTTP header in `GreenhouseIo::Client`.
|
16
|
+
|
17
|
+
#### Removed
|
18
|
+
- Removed dependency on `multi_json` in favor of Ruby's `json` module.
|
19
|
+
|
20
|
+
## Version 2.3.1
|
21
|
+
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.
|
22
|
+
|
23
|
+
#### Added
|
24
|
+
- Added method `create_candidate_note`. Thanks for contributing, [@jleven](https://github.com/jleven)!
|
25
|
+
|
26
|
+
## Version 2.3.0
|
27
|
+
Released 2016-02-13.
|
28
|
+
|
29
|
+
##### Added
|
30
|
+
- Added support for listing all scorecards belonging to an organization: `all_scorecards`. Thanks, [@bcoppersmith](https://github.com/bcoppersmith)!
|
31
|
+
|
32
|
+
## Version 2.2.0
|
33
|
+
Released 2016-02-03.
|
34
|
+
|
35
|
+
##### Added
|
36
|
+
- Added support for listing Offers and retrieving them by ID
|
37
|
+
- Added support for filtering with `job_id` parameter
|
38
|
+
|
39
|
+
##### Changed
|
40
|
+
- Upgraded dependencies: `multi_json` (now ~>1.11.2), and development gems
|
41
|
+
- Added version dependency for `httmultiparty`: ``'~> 0.3.16'``
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Adrian Bautista
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
# Greenhouse IO
|
2
|
+
|
3
|
+
[![Gem
|
4
|
+
Version](https://badge.fury.io/rb/greenhouse_io.png)](http://badge.fury.io/rb/greenhouse_io)
|
5
|
+
[![Build Status](https://travis-ci.org/grnhse/greenhouse_io.svg?branch=master)](https://travis-ci.org/grnhse/greenhouse_io)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/grnhse/greenhouse_io/badges/coverage.svg)](https://codeclimate.com/github/grnhse/greenhouse_io/coverage)
|
7
|
+
[![Dependency Status](https://gemnasium.com/grnhse/greenhouse_io.svg)](https://gemnasium.com/grnhse/greenhouse_io)
|
8
|
+
|
9
|
+
A Ruby interface to
|
10
|
+
[Greenhouse.io's](https://app.greenhouse.io/jobboard/jsonp_instructions)
|
11
|
+
API (requires Ruby 1.9.3 or greater).
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add the gem to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'greenhouse_io'
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install
|
22
|
+
|
23
|
+
## API Documentation
|
24
|
+
|
25
|
+
Documentation for the Harvest and Job Board web APIs can be found at [developers.greenhouse.io](https://developers.greenhouse.io).
|
26
|
+
|
27
|
+
## Configuration
|
28
|
+
|
29
|
+
You can assign default configuration values when using this gem.
|
30
|
+
Here is an example `config/initializers/greenhouse_io.rb` file used in a Rails application:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
GreenhouseIo.configure do |config|
|
34
|
+
config.symbolize_keys = true # set response keys as strings or symbols, default is false
|
35
|
+
config.organization = 'General Assembly'
|
36
|
+
config.api_token = ENV['GREENHOUSE_API_TOKEN']
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
Greenhouse's two APIs, **[Harvest](https://app.greenhouse.io/configure/dev_center/harvest)** and **[Job Board](https://app.greenhouse.io/configure/dev_center/api_documentation)**, can now be accessed through the gem. The [`GreenhouseIo::JobBoard`](#greenhouseiojobboard) is nearly identical to the old `GreenhouseIo::API` class. [`GreenhouseIo::Client`](#greenhouseioclient) connects to the new Harvest API.
|
43
|
+
|
44
|
+
### GreenhouseIo::JobBoard
|
45
|
+
|
46
|
+
Creating an instance of the JobBoard client:
|
47
|
+
```ruby
|
48
|
+
gh = GreenhouseIo::JobBoard.new("api_token", organization: "your_organization")
|
49
|
+
```
|
50
|
+
|
51
|
+
If you've configured the gem with a default `organization` and `api_token`, then you can just instantiate the class.
|
52
|
+
```ruby
|
53
|
+
gh = GreenhouseIo::JobBoard.new
|
54
|
+
```
|
55
|
+
|
56
|
+
`api_token` is only required for `#apply_to_job` and `organization` is also optional during initialization if an organization is passed in during method requests.
|
57
|
+
|
58
|
+
#### Fetching Office Data
|
59
|
+
```ruby
|
60
|
+
gh.offices
|
61
|
+
gh.offices(organization: 'different_organization')
|
62
|
+
# returns a hash containing all of the organization's department and jobs grouped by office
|
63
|
+
```
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
gh.office(id)
|
67
|
+
gh.office(id, organization: 'different_organization')
|
68
|
+
# returns a hash containing the departments and jobs of a specific office
|
69
|
+
```
|
70
|
+
|
71
|
+
#### Fetching Department Data
|
72
|
+
```ruby
|
73
|
+
gh.departments
|
74
|
+
gh.departments(organization: 'different_organizaton')
|
75
|
+
```
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
gh.department(id)
|
79
|
+
gh.department(id, organization: 'different_organization')
|
80
|
+
```
|
81
|
+
|
82
|
+
#### Fetching Job Data
|
83
|
+
```ruby
|
84
|
+
gh.jobs
|
85
|
+
gh.jobs(content: 'true')
|
86
|
+
# includes the job description in the response
|
87
|
+
gh.jobs(organization: 'different_organization')
|
88
|
+
```
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
gh.job(id)
|
92
|
+
gh.job(id, questions: true)
|
93
|
+
# returns the specified job and the array of questions on the application
|
94
|
+
gh.job(id, organization: 'different_organization')
|
95
|
+
```
|
96
|
+
|
97
|
+
#### Submitting a Job Application
|
98
|
+
This is the only API method that **requires** an API token from Greenhouse
|
99
|
+
```ruby
|
100
|
+
gh.apply_to_job(form_parameter_hash)
|
101
|
+
|
102
|
+
# form_parameter_hash should match the questions array of a given job opening
|
103
|
+
# there should be a hidden input with name id in your form that
|
104
|
+
# has the value of the job ID on Greenhouse.io
|
105
|
+
```
|
106
|
+
|
107
|
+
### GreenhouseIo::Client
|
108
|
+
|
109
|
+
Creating an instance of the API client:
|
110
|
+
```ruby
|
111
|
+
gh_client = GreenhouseIo::Client.new("api_token")
|
112
|
+
```
|
113
|
+
|
114
|
+
If you've configured the gem with a default `api_token`, then you can just instantiate the class.
|
115
|
+
```ruby
|
116
|
+
gh_client = GreenhouseIo::Client.new
|
117
|
+
```
|
118
|
+
|
119
|
+
#### Listing candidates
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
gh_client.candidates
|
123
|
+
```
|
124
|
+
|
125
|
+
#### Creating a candidate note
|
126
|
+
Use this method to attach a new note to a candidate.
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
candidate_id = 4567
|
130
|
+
author_id = 123 # ID of the user who wrote this note
|
131
|
+
note = {
|
132
|
+
:user_id => 123,
|
133
|
+
:message => "This candidate has very strong opinions about Node.JS.",
|
134
|
+
:visibility => "public"
|
135
|
+
}
|
136
|
+
|
137
|
+
gh_client.create_candidate_note(candidate_id, note, author_id)
|
138
|
+
```
|
139
|
+
|
140
|
+
#### Throttling
|
141
|
+
|
142
|
+
Rate limit and rate limit remaining are available after making an API request with an API client:
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
gh_client.rate_limit # => 20
|
146
|
+
gh_client.rate_limit_remaining # => 20
|
147
|
+
```
|
148
|
+
|
149
|
+
#### Pagination
|
150
|
+
|
151
|
+
All `GreenhouseIo::Client` API methods accept `:page` and `:per_page` options to get specific results of a paginated response from Greenhouse.
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
gh_client.offices(id, page: 1, per_page: 2)
|
155
|
+
```
|
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
|
+
|
167
|
+
#### Available methods
|
168
|
+
|
169
|
+
Methods for which an `id` is optional:
|
170
|
+
|
171
|
+
* `offices`
|
172
|
+
* `departments`
|
173
|
+
* `candidates`
|
174
|
+
* `applications`
|
175
|
+
* `jobs`
|
176
|
+
* `users`
|
177
|
+
* `sources`
|
178
|
+
* `all_scorecards`
|
179
|
+
* `offers`
|
180
|
+
|
181
|
+
Methods for which an `id` is **required**:
|
182
|
+
|
183
|
+
* `activity_feed` *(requires a candidate ID)*
|
184
|
+
* `scorecards` *(requires an application ID)*
|
185
|
+
* `scheduled_interviews` *(requires an application ID)*
|
186
|
+
* `offers_for_application` *(requires an application ID)*
|
187
|
+
* `current_offer_for_application` *(requires an application ID)*
|
188
|
+
* `stages` *(requires a job ID)*
|
189
|
+
* `job_post` *(requires a job ID)*
|
190
|
+
* `create_candidate_note` *(requires a candidate ID)*
|
191
|
+
|
192
|
+
## Contributing
|
193
|
+
|
194
|
+
1. Fork it
|
195
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
196
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
197
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
198
|
+
5. Create new Pull Request
|
199
|
+
|
200
|
+
Contributions are always welcome!
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'greenhouse_io/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "greenhouse_io-gitlab"
|
8
|
+
spec.version = GreenhouseIo::VERSION
|
9
|
+
spec.authors = ["Greenhouse Software", "Adrian Bautista"]
|
10
|
+
spec.email = ["support@greenhouse.io", "adrianbautista8@gmail.com"]
|
11
|
+
spec.description = %q{Ruby bindings for the greenhouse.io Harvest API and Job Board API}
|
12
|
+
spec.summary = %q{Ruby bindings for the greenhouse.io Harvest API and Job Board API}
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.homepage = "https://github.com/grnhse/greenhouse_io"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency('httmultiparty', '~> 0.3.16')
|
22
|
+
spec.required_ruby_version = '>= 1.9.3'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.4.0"
|
27
|
+
spec.add_development_dependency "webmock", "~> 1.22.6"
|
28
|
+
spec.add_development_dependency "vcr", "~> 3.0.1"
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module GreenhouseIo
|
2
|
+
module API
|
3
|
+
def get_response(url, options)
|
4
|
+
self.class.get(url, options)
|
5
|
+
end
|
6
|
+
|
7
|
+
def post_response(url, options)
|
8
|
+
self.class.post(url, options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def parse_json(response)
|
12
|
+
JSON.parse(response.body, symbolize_names: GreenhouseIo.configuration.symbolize_keys)
|
13
|
+
end
|
14
|
+
|
15
|
+
def basic_auth
|
16
|
+
{ :username => self.api_token }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
module GreenhouseIo
|
2
|
+
class Client
|
3
|
+
include HTTMultiParty
|
4
|
+
include GreenhouseIo::API
|
5
|
+
|
6
|
+
PERMITTED_OPTIONS = [:page, :per_page, :job_id]
|
7
|
+
PERMITTED_OPTIONS_PER_ENDPOINT = {
|
8
|
+
'offers' => [:status, :resolved_after],
|
9
|
+
'candidates' => [:updated_after, :email]
|
10
|
+
}
|
11
|
+
|
12
|
+
attr_accessor :api_token, :rate_limit, :rate_limit_remaining, :link
|
13
|
+
base_uri 'https://harvest.greenhouse.io/v1'
|
14
|
+
|
15
|
+
def initialize(api_token = nil)
|
16
|
+
@api_token = api_token || GreenhouseIo.configuration.api_token
|
17
|
+
end
|
18
|
+
|
19
|
+
def offices(id = nil, options = {})
|
20
|
+
get_from_harvest_api "/offices#{path_id(id)}", options
|
21
|
+
end
|
22
|
+
|
23
|
+
def offers(id = nil, options = {})
|
24
|
+
get_from_harvest_api "/offers#{path_id(id)}", options, "offers"
|
25
|
+
end
|
26
|
+
|
27
|
+
def departments(id = nil, options = {})
|
28
|
+
get_from_harvest_api "/departments#{path_id(id)}", options
|
29
|
+
end
|
30
|
+
|
31
|
+
def candidates(id = nil, options = {})
|
32
|
+
get_from_harvest_api "/candidates#{path_id(id)}", options, "candidates"
|
33
|
+
end
|
34
|
+
|
35
|
+
def activity_feed(id, options = {})
|
36
|
+
get_from_harvest_api "/candidates/#{id}/activity_feed", options
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_candidate_note(candidate_id, note_hash, on_behalf_of)
|
40
|
+
post_to_harvest_api(
|
41
|
+
"/candidates/#{candidate_id}/activity_feed/notes",
|
42
|
+
note_hash,
|
43
|
+
{ 'On-Behalf-Of' => on_behalf_of.to_s }
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def applications(id = nil, options = {})
|
48
|
+
get_from_harvest_api "/applications#{path_id(id)}", options
|
49
|
+
end
|
50
|
+
|
51
|
+
def offers_for_application(id, options = {})
|
52
|
+
get_from_harvest_api "/applications/#{id}/offers", options
|
53
|
+
end
|
54
|
+
|
55
|
+
def current_offer_for_application(id, options = {})
|
56
|
+
get_from_harvest_api "/applications/#{id}/offers/current_offer", options
|
57
|
+
end
|
58
|
+
|
59
|
+
def scorecards(id, options = {})
|
60
|
+
get_from_harvest_api "/applications/#{id}/scorecards", options
|
61
|
+
end
|
62
|
+
|
63
|
+
def all_scorecards(id = nil, options = {})
|
64
|
+
get_from_harvest_api "/scorecards/#{id}", options
|
65
|
+
end
|
66
|
+
|
67
|
+
def scheduled_interviews(id, options = {})
|
68
|
+
get_from_harvest_api "/applications/#{id}/scheduled_interviews", options
|
69
|
+
end
|
70
|
+
|
71
|
+
def jobs(id = nil, options = {})
|
72
|
+
get_from_harvest_api "/jobs#{path_id(id)}", options
|
73
|
+
end
|
74
|
+
|
75
|
+
def stages(id, options = {})
|
76
|
+
get_from_harvest_api "/jobs/#{id}/stages", options
|
77
|
+
end
|
78
|
+
|
79
|
+
def job_post(id, options = {})
|
80
|
+
get_from_harvest_api "/jobs/#{id}/job_post", options
|
81
|
+
end
|
82
|
+
|
83
|
+
def users(id = nil, options = {})
|
84
|
+
get_from_harvest_api "/users#{path_id(id)}", options
|
85
|
+
end
|
86
|
+
|
87
|
+
def sources(id = nil, options = {})
|
88
|
+
get_from_harvest_api "/sources#{path_id(id)}", options
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def path_id(id = nil)
|
94
|
+
"/#{id}" unless id.nil?
|
95
|
+
end
|
96
|
+
|
97
|
+
def permitted_options(options)
|
98
|
+
options.select { |key, value| PERMITTED_OPTIONS.include? key }
|
99
|
+
end
|
100
|
+
|
101
|
+
def permitted_options_for_endpoint(options, endpoint)
|
102
|
+
options.select { |key, value| PERMITTED_OPTIONS_PER_ENDPOINT[endpoint].include? key }
|
103
|
+
end
|
104
|
+
|
105
|
+
def get_from_harvest_api(url, options = {}, endpoint = nil)
|
106
|
+
all_permitted_options = permitted_options(options)
|
107
|
+
all_permitted_options.merge!(permitted_options_for_endpoint(options, endpoint)) if endpoint
|
108
|
+
|
109
|
+
response = get_response(url, {
|
110
|
+
:query => all_permitted_options,
|
111
|
+
:basic_auth => basic_auth
|
112
|
+
})
|
113
|
+
|
114
|
+
set_headers_info(response.headers)
|
115
|
+
|
116
|
+
if response.code == 200
|
117
|
+
parse_json(response)
|
118
|
+
else
|
119
|
+
raise GreenhouseIo::Error.new(response.code)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def post_to_harvest_api(url, body, headers)
|
124
|
+
response = post_response(url, {
|
125
|
+
:body => JSON.dump(body),
|
126
|
+
:basic_auth => basic_auth,
|
127
|
+
:headers => headers
|
128
|
+
})
|
129
|
+
|
130
|
+
set_headers_info(response.headers)
|
131
|
+
|
132
|
+
if response.code == 200
|
133
|
+
parse_json(response)
|
134
|
+
else
|
135
|
+
raise GreenhouseIo::Error.new(response.code)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def set_headers_info(headers)
|
140
|
+
self.rate_limit = headers['x-ratelimit-limit'].to_i
|
141
|
+
self.rate_limit_remaining = headers['x-ratelimit-remaining'].to_i
|
142
|
+
self.link = headers['link'].to_s
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|