Skip to content

Commit

Permalink
Merge pull request #23 from grnhse/theshanx-master
Browse files Browse the repository at this point in the history
Add methods to retrieve offers for an application (#22)
  • Loading branch information
capablemonkey committed May 31, 2016
2 parents dd2e5b3 + c7573d4 commit c5041d4
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 1 deletion.
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.5.0
Released 2016-05-31. Contributed by [@theshanx](https://github.com/theshanx). Thanks! :)

#### Added
- Added methods for retrieving offers for an application: `current_offer_for_application` and `offers_for_application`

## Version 2.4.0
Released 2016-04-20. Contributed by [@mariochavez](https://github.com/mariochavez) -- thank you!

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ Methods for which an `id` is **required**:
* `activity_feed` *(requires a candidate ID)*
* `scorecards` *(requires an application ID)*
* `scheduled_interviews` *(requires an application ID)*
* `offers_for_application` *(requires an application ID)*
* `current_offer_for_application` *(requires an application ID)*
* `stages` *(requires a job ID)*
* `job_post` *(requires a job ID)*
* `create_candidate_note` *(requires a candidate ID)*
Expand Down
8 changes: 8 additions & 0 deletions lib/greenhouse_io/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ def applications(id = nil, options = {})
get_from_harvest_api "/applications#{path_id(id)}", options
end

def offers_for_application(id, options = {})
get_from_harvest_api "/applications/#{id}/offers", options
end

def current_offer_for_application(id, options = {})
get_from_harvest_api "/applications/#{id}/offers/current_offer", options
end

def scorecards(id, options = {})
get_from_harvest_api "/applications/#{id}/scorecards", options
end
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.4.0"
VERSION = "2.5.0"
end
40 changes: 40 additions & 0 deletions spec/fixtures/cassettes/client/current_offer_for_application.yml

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

40 changes: 40 additions & 0 deletions spec/fixtures/cassettes/client/offers_for_application.yml

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

41 changes: 41 additions & 0 deletions spec/greenhouse_io/api/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -634,5 +634,46 @@
end
end
end

describe "#offers_for_application" do
before do
VCR.use_cassette('client/offers_for_application') do
@offers = @client.offers_for_application(123)
end
end

it "returns a response" do
expect(@offers).to_not be_nil
end

it "returns an array of offers" do
expect(@offers).to be_an_instance_of(Array)

return unless @offers.size > 0
expect(@offers.first).to have_key(:application_id)
expect(@offers.first).to have_key(:version)
expect(@offers.first).to have_key(:status)
end
end

describe "#current_offer_for_application" do
before do
VCR.use_cassette('client/current_offer_for_application') do
@offer = @client.current_offer_for_application(123)
end
end

it "returns a response" do
expect(@offer).to_not be_nil
end

it "returns an offer object" do
expect(@offer).to be_an_instance_of(Hash)
expect(@offer[:id]).to be_a(Integer).and be > 0
expect(@offer[:created_at]).to be_a(String)
expect(@offer[:version]).to be_a(Integer).and be > 0
expect(@offer[:status]).to be_a(String)
end
end
end
end

0 comments on commit c5041d4

Please sign in to comment.