Skip to content

Commit

Permalink
Merge pull request #19 from grnhse/NoRedInk-activity-feed-notes
Browse files Browse the repository at this point in the history
Add create candidate notes method
  • Loading branch information
capablemonkey committed Apr 20, 2016
2 parents d4a1d6b + 4d024df commit 0438818
Show file tree
Hide file tree
Showing 11 changed files with 355 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This project follows [semantic versioning](http://semver.org/). This changelog follows suggestions from [keepachangelog.com](http://keepachangelog.com/).

## Version 2.3.1
Released 2016-04-20.

#### Added
- Added method `create_candidate_note`. Thanks for contributing, [@jleven](https://github.com/jleven)!

## Version 2.3.0
Released 2016-02-13.

Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,27 @@ If you've configured the gem with a default `api_token`, then you can just insta
gh_client = GreenhouseIo::Client.new
```

#### Listing candidates

```
gh_client.candidates
```

#### Creating a candidate note
Use this method to attach a new note to a candidate.

```
candidate_id = 4567
author_id = 123 # ID of the user who wrote this note
note = {
:user_id => 123,
:message => "This candidate has very strong opinions about Node.JS.",
:visibility => "public"
}
gh_client.create_candidate_note(candidate_id, note, author_id)
```

#### Throttling

Rate limit and rate limit remaining are available after making an API request with an API client:
Expand All @@ -135,7 +156,7 @@ gh_client.offices(id, page: 1, per_page: 2)

#### Available methods

Methods in which an `id` is optional:
Methods for which an `id` is optional:

* `offices`
* `departments`
Expand All @@ -147,13 +168,14 @@ Methods in which an `id` is optional:
* `all_scorecards`
* `offers`

Methods in which an `id` is **required**:
Methods for which an `id` is **required**:

* `activity_feed` *(requires a candidate ID)*
* `scorecards` *(requires an application ID)*
* `scheduled_interviews` *(requires an application ID)*
* `stages` *(requires a job ID)*
* `job_post` *(requires a job ID)*
* `create_candidate_note` *(requires a candidate ID)*

## Contributing

Expand All @@ -162,3 +184,5 @@ Methods in which an `id` is **required**:
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Contributions are always welcome!
2 changes: 1 addition & 1 deletion lib/greenhouse_io.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'httmultiparty'
require 'multi_json'
require 'cgi'
require 'json'

require "greenhouse_io/version"
require "greenhouse_io/error"
Expand Down
31 changes: 30 additions & 1 deletion lib/greenhouse_io/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ def activity_feed(id, options = {})
get_from_harvest_api "/candidates/#{id}/activity_feed", options
end

def create_candidate_note(candidate_id, note_hash, on_behalf_of)
post_to_harvest_api(
"/candidates/#{candidate_id}/activity_feed/notes",
note_hash,
{ 'On-Behalf-Of' => on_behalf_of.to_s }
)
end

def applications(id = nil, options = {})
get_from_harvest_api "/applications#{path_id(id)}", options
end
Expand Down Expand Up @@ -79,8 +87,29 @@ def permitted_options(options)
end

def get_from_harvest_api(url, options = {})
response = get_response(url, query: permitted_options(options), basic_auth: basic_auth)
response = get_response(url, {
:query => permitted_options(options),
:basic_auth => basic_auth
})

set_rate_limits(response.headers)

if response.code == 200
parse_json(response)
else
raise GreenhouseIo::Error.new(response.code)
end
end

def post_to_harvest_api(url, body, headers)
response = post_response(url, {
:body => JSON.dump(body),
:basic_auth => basic_auth,
:headers => headers
})

set_rate_limits(response.headers)

if response.code == 200
parse_json(response)
else
Expand Down
2 changes: 1 addition & 1 deletion lib/greenhouse_io/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module GreenhouseIo
VERSION = "2.3.0"
VERSION = "2.3.1"
end
42 changes: 42 additions & 0 deletions spec/fixtures/cassettes/client/create_candidate_note.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0438818

Please sign in to comment.