From 557e2b3eb82deb8c092c7797dcff7350fe456e11 Mon Sep 17 00:00:00 2001 From: theshanx Date: Fri, 13 May 2016 15:18:57 -0700 Subject: [PATCH 1/4] Add application_offers method to Greenhouse client Also application_current_offer method. --- lib/greenhouse_io/api/client.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/greenhouse_io/api/client.rb b/lib/greenhouse_io/api/client.rb index 99fa5bc..c927fbb 100644 --- a/lib/greenhouse_io/api/client.rb +++ b/lib/greenhouse_io/api/client.rb @@ -44,6 +44,14 @@ def applications(id = nil, options = {}) get_from_harvest_api "/applications#{path_id(id)}", options end + def application_offers(id, options = {}) + get_from_harvest_api "/applications/#{id}/offers", options + end + + def application_current_offer(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 From b765aed9d16dac03a579522614392e1ec5dfbe73 Mon Sep 17 00:00:00 2001 From: Gordon Zheng Date: Tue, 31 May 2016 15:30:24 -0400 Subject: [PATCH 2/4] Change method names for clarity --- lib/greenhouse_io/api/client.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/greenhouse_io/api/client.rb b/lib/greenhouse_io/api/client.rb index c927fbb..453d52d 100644 --- a/lib/greenhouse_io/api/client.rb +++ b/lib/greenhouse_io/api/client.rb @@ -44,11 +44,11 @@ def applications(id = nil, options = {}) get_from_harvest_api "/applications#{path_id(id)}", options end - def application_offers(id, options = {}) + def offers_for_application(id, options = {}) get_from_harvest_api "/applications/#{id}/offers", options end - def application_current_offer(id, options = {}) + def current_offer_for_application(id, options = {}) get_from_harvest_api "/applications/#{id}/offers/current_offer", options end From 61a3a3909c4ecaa0e1d986789825c455c9bdd576 Mon Sep 17 00:00:00 2001 From: Gordon Zheng Date: Tue, 31 May 2016 15:50:54 -0400 Subject: [PATCH 3/4] Add tests for offers by application endpoints --- .../client/current_offer_for_application.yml | 40 ++++++++++++++++++ .../client/offers_for_application.yml | 40 ++++++++++++++++++ spec/greenhouse_io/api/client_spec.rb | 41 +++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 spec/fixtures/cassettes/client/current_offer_for_application.yml create mode 100644 spec/fixtures/cassettes/client/offers_for_application.yml diff --git a/spec/fixtures/cassettes/client/current_offer_for_application.yml b/spec/fixtures/cassettes/client/current_offer_for_application.yml new file mode 100644 index 0000000..89321c9 --- /dev/null +++ b/spec/fixtures/cassettes/client/current_offer_for_application.yml @@ -0,0 +1,40 @@ +--- +http_interactions: +- request: + method: get + uri: https://123FakeToken:@harvest.greenhouse.io/v1/applications/123/offers/current_offer + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Server: + - Cowboy + Connection: + - keep-alive + Date: + - Tue, 31 May 2016 19:48:29 GMT + Status: + - 200 OK + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '416' + X-Ratelimit-Limit: + - '40' + X-Ratelimit-Remaining: + - '39' + X-Content-Type-Options: + - nosniff + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '{"id":320847,"version":1,"application_id":123,"created_at":"2016-05-31T19:38:43.623Z","updated_at":"2016-05-31T19:38:56.024Z","sent_at":null,"resolved_at":"2016-05-31T19:38:56.024Z","starts_at":"2016-05-31","status":"accepted","custom_fields":{"benefits":null,"bonus":"1000","current_salary":null,"employment_type":"Full-time","notes":null,"options":"2000","salary":"74111","source_cost":null,"visa_cost":null}}' + http_version: + recorded_at: Tue, 31 May 2016 19:48:32 GMT +recorded_with: VCR 3.0.1 diff --git a/spec/fixtures/cassettes/client/offers_for_application.yml b/spec/fixtures/cassettes/client/offers_for_application.yml new file mode 100644 index 0000000..c0ae5c0 --- /dev/null +++ b/spec/fixtures/cassettes/client/offers_for_application.yml @@ -0,0 +1,40 @@ +--- +http_interactions: +- request: + method: get + uri: https://123FakeToken:@harvest.greenhouse.io/v1/applications/123/offers + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Server: + - Cowboy + Connection: + - keep-alive + Date: + - Tue, 31 May 2016 19:39:19 GMT + Status: + - 200 OK + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '418' + X-Ratelimit-Limit: + - '40' + X-Ratelimit-Remaining: + - '39' + X-Content-Type-Options: + - nosniff + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '[{"id":320847,"version":1,"application_id":123,"created_at":"2016-05-31T19:38:43.623Z","updated_at":"2016-05-31T19:38:56.024Z","sent_at":null,"resolved_at":"2016-05-31T19:38:56.024Z","starts_at":"2016-05-31","status":"accepted","custom_fields":{"benefits":null,"bonus":"1000","current_salary":null,"employment_type":"Full-time","notes":null,"options":"2000","salary":"74111","source_cost":null,"visa_cost":null}}]' + http_version: + recorded_at: Tue, 31 May 2016 19:39:22 GMT +recorded_with: VCR 3.0.1 diff --git a/spec/greenhouse_io/api/client_spec.rb b/spec/greenhouse_io/api/client_spec.rb index 67e4e13..7209013 100644 --- a/spec/greenhouse_io/api/client_spec.rb +++ b/spec/greenhouse_io/api/client_spec.rb @@ -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 From c7573d489ad8b972fb699f9461510ca1a0c15c19 Mon Sep 17 00:00:00 2001 From: Gordon Zheng Date: Tue, 31 May 2016 15:57:09 -0400 Subject: [PATCH 4/4] Bump version to 2.5.0 --- CHANGES.md | 6 ++++++ README.md | 2 ++ lib/greenhouse_io/version.rb | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 8f0a608..e81ba5e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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! diff --git a/README.md b/README.md index cd74013..f379a4b 100644 --- a/README.md +++ b/README.md @@ -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)* diff --git a/lib/greenhouse_io/version.rb b/lib/greenhouse_io/version.rb index 55836c9..da10943 100644 --- a/lib/greenhouse_io/version.rb +++ b/lib/greenhouse_io/version.rb @@ -1,3 +1,3 @@ module GreenhouseIo - VERSION = "2.4.0" + VERSION = "2.5.0" end