Giter VIP home page Giter VIP logo

greenhouse_io's Introduction

Greenhouse IO

Gem Version Build Status Test Coverage Dependency Status

A Ruby interface to Greenhouse.io's API (requires Ruby 1.9.3 or greater).

Installation

Add the gem to your application's Gemfile:

gem 'greenhouse_io'

Or install it yourself as:

$ gem install

API Documentation

Documentation for the Harvest and Job Board web APIs can be found at developers.greenhouse.io.

Configuration

You can assign default configuration values when using this gem.
Here is an example config/initializers/greenhouse_io.rb file used in a Rails application:

GreenhouseIo.configure do |config|
	config.symbolize_keys = true # set response keys as strings or symbols, default is false
	config.organization = 'General Assembly'
	config.api_token = ENV['GREENHOUSE_API_TOKEN']
end

Usage

Greenhouse's two APIs, Harvest and Job Board, can now be accessed through the gem. The GreenhouseIo::JobBoard is nearly identical to the old GreenhouseIo::API class. GreenhouseIo::Client connects to the new Harvest API.

GreenhouseIo::JobBoard

Creating an instance of the JobBoard client:

gh = GreenhouseIo::JobBoard.new("api_token", organization: "your_organization")

If you've configured the gem with a default organization and api_token, then you can just instantiate the class.

gh = GreenhouseIo::JobBoard.new

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.

Fetching Office Data

gh.offices
gh.offices(organization: 'different_organization')
# returns a hash containing all of the organization's department and jobs grouped by office
gh.office(id)
gh.office(id, organization: 'different_organization')
# returns a hash containing the departments and jobs of a specific office

Fetching Department Data

gh.departments
gh.departments(organization: 'different_organizaton')
gh.department(id)
gh.department(id, organization: 'different_organization')

Fetching Job Data

gh.jobs
gh.jobs(content: 'true')
# includes the job description in the response
gh.jobs(organization: 'different_organization')
gh.job(id)
gh.job(id, questions: true)
# returns the specified job and the array of questions on the application
gh.job(id, organization: 'different_organization')

Submitting a Job Application

This is the only API method that requires an API token from Greenhouse

gh.apply_to_job(form_parameter_hash)

# form_parameter_hash should match the questions array of a given job opening
# there should be a hidden input with name id in your form that
# has the value of the job ID on Greenhouse.io

GreenhouseIo::Client

Creating an instance of the API client:

gh_client = GreenhouseIo::Client.new("api_token")

If you've configured the gem with a default api_token, then you can just instantiate the class.

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:

gh_client.rate_limit # => 20
gh_client.rate_limit_remaining  # => 20

Pagination

All GreenhouseIo::Client API methods accept :page and :per_page options to get specific results of a paginated response from Greenhouse.

gh_client.offices(id, page: 1, per_page: 2)

You can determine the last page and next page by looking at the link header from the last response:

gh_client.link

# => '<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"'

You'll need to manually parse the next and last links to tell what the next or final page number will be.

Available methods

Methods for which an id is optional:

  • offices
  • departments
  • candidates
  • applications
  • jobs
  • users
  • sources
  • all_scorecards
  • offers

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)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  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!

greenhouse_io's People

Contributors

adrianbautista avatar arirusso avatar bcoppersmith avatar braidn avatar capablemonkey avatar mariochavez avatar noralin avatar rodrimaia avatar theshanx avatar wdewind avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

greenhouse_io's Issues

Dependency: httparty (~> 0.13.3) depends on json (~> 1.8) which has a CVE

from bundle-audit:

Name: json
Version: 1.8.6
Advisory: CVE-2020-10663
Criticality: Unknown
URL: https://www.ruby-lang.org/en/news/2020/03/19/json-dos-cve-2020-10663/
Title: json Gem for Ruby Unsafe Object Creation Vulnerability (additional fix)
Solution: upgrade to >= 2.3.0

@grnhse Please loosen the dependency on httparty so that we can use this gem without the vulnerability.
https://www.ruby-lang.org/en/news/2020/03/19/json-dos-cve-2020-10663/

query opts doesn't work without id

gh_client.offices(id, page: 1, per_page: 2) works but gh_client.offices(page: 1, per_page: 2) failed with error:
/Users/yefeiwang/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/uri/common.rb:176:in split': bad URI(is not URI?): /candidates/{:page=>1, :per_page=>200} (URI::InvalidURIError)`

not seeing job descriptions

I am using client.jobs(status: 'true') but the status: 'true' part doesn't seem to change anything.

job.keys
=> [:id,
 :name,
 :requisition_id,
 :notes,
 :status,
 :created_at,
 :opened_at,
 :closed_at,
 :departments,
 :offices,
 :hiring_team,
 :custom_fields,
 :openings]

This is using Harvester by the way

Support for `custom_fields` endoint

Do you plan to support the https://harvest.greenhouse.io/v1/custom_field endpoint in the future? Or if not, would a PR have any chance of being accepted if it's in the desired quality? Just wondering if I need to implement support independently of this gem or if there's a chance that I can query details about a custom fields in the future using the gem.

Cheers
Ben

link header contains duplicate query params

The Ruby client illustrates this problem, but the issue lies with the underlying Harvest API service.

Problem

When passing parameters for page and per_page, the link header for the results contain both the current page parameters and the next page parameters.

Example

https://harvest.greenhouse.io/v1/applications?page=2&page=3&per_page=1&per_page=1

Steps to Reproduce (Ruby)

$ irb -rgreenhouse_io
>> gh_client = GreenhouseIo::Client.new(redacted)
=> #<GreenhouseIo::Client:0x007ff5eb85e4e8 @api_token=redacted>
>> gh_client.link
=> nil
>> gh_client.applications(nil, per_page: 1)
=> [...redacted...]
>> gh_client.link
=> "<https://harvest.greenhouse.io/v1/applications?page=2&per_page=1&per_page=1>; rel=\"next\",<https://harvest.greenhouse.io/v1/applications?page=24882&per_page=1&per_page=1>; rel=\"last\""
>> gh_client.applications(nil, page: 2, per_page: 1)
=> [...redacted...]
>> gh_client.link
=> "<https://harvest.greenhouse.io/v1/applications?page=2&page=3&per_page=1&per_page=1>; rel=\"next\",<https://harvest.greenhouse.io/v1/applications?page=1&page=2&per_page=1&per_page=1>; rel=\"prev\",<https://harvest.greenhouse.io/v1/applications?page=2&page=24882&per_page=1&per_page=1>; rel=\"last\""

Steps to Reproduce (curl)

$ curl -v https://harvest.greenhouse.io/v1/applications\?per_page\=1 -u redacted
*   Trying 54.225.221.123...
* Connected to harvest.greenhouse.io (54.225.221.123) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.greenhouse.io
* Server certificate: RapidSSL SHA256 CA - G3
* Server certificate: GeoTrust Global CA
> GET /v1/applications?per_page=1 HTTP/1.1
> Host: harvest.greenhouse.io
> Authorization: Basic redacted
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Cowboy
< Connection: keep-alive
< Date: Wed, 11 May 2016 05:58:25 GMT
< Status: 200 OK
< Content-Type: application/json;charset=utf-8
< Link: <https://harvest.greenhouse.io/v1/applications?page=2&per_page=1&per_page=1>; rel="next",<https://harvest.greenhouse.io/v1/applications?page=24882&per_page=1&per_page=1>; rel="last"

$ curl -v https://harvest.greenhouse.io/v1/applications\?page\=2\&per_page\=1 -u redacted
*   Trying 23.21.54.152...
* Connected to harvest.greenhouse.io (23.21.54.152) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.greenhouse.io
* Server certificate: RapidSSL SHA256 CA - G3
* Server certificate: GeoTrust Global CA
> GET /v1/applications?page=2&per_page=1 HTTP/1.1
> Host: harvest.greenhouse.io
> Authorization: Basic redacted
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Cowboy
< Connection: keep-alive
< Date: Wed, 11 May 2016 05:59:50 GMT
< Status: 200 OK
< Content-Type: application/json;charset=utf-8
< Link: <https://harvest.greenhouse.io/v1/applications?page=2&page=3&per_page=1&per_page=1>; rel="next",<https://harvest.greenhouse.io/v1/applications?page=1&page=2&per_page=1&per_page=1>; rel="prev",<https://harvest.greenhouse.io/v1/applications?page=2&page=24882&per_page=1&per_page=1>; rel="last"

Is there search available in the api?

Looking through this library and also greenhouse.io developer documentation, I don't see any parameters for a search query.

Are there any solutions for searching jobs with the current API?

CloudQuery Source Plugin?

Hi Team, hopefully this is right place to ask, if not, I'd appreciate if you can direct me.

I'm the founder of cloudquery.io, a high performance open source ELT framework.

Our users are interested in a Greenhouse plugin, but as we cannot maintain all the plugins ourselves, I was curious if this would be an interesting collaboration, where we would help implement an initial source plugin, and you will help maintain it.

This will give your users the ability to sync Greenhouse data to any of their datalakes/data-warehouses/databases easily using any of the growing list of CQ destination plugins.

Best,
Yevgeny

Issue with httparty dependency

Hi @adrianbautista

Submitting to the job board is resulting in an exception:

NoMethodError: undefined method `[]' for nil:NilClass
gems/multi_json-1.10.1/lib/multi_json.rb:127 current_adapter
gems/multi_json-1.10.1/lib/multi_json.rb:117 load
gems/httparty-0.13.3/lib/httparty/parser.rb:116 json
gems/httparty-0.13.3/lib/httparty/parser.rb:136 parse_supported_format
gems/httparty-0.13.3/lib/httparty/parser.rb:103 parse
gems/httparty-0.13.3/lib/httparty/parser.rb:67 call
gems/httparty-0.13.3/lib/httparty/request.rb:309 parse_response
gems/httparty-0.13.3/lib/httparty/request.rb:279 block in handle_response
gems/httparty-0.13.3/lib/httparty/response.rb:23 call
gems/httparty-0.13.3/lib/httparty/response.rb:23 parsed_response
gems/httparty-0.13.3/lib/httparty/response.rb:61 method_missing
gems/greenhouse_io-2.1.0/lib/greenhouse_io/api/job_board.rb:60 post_to_job_board_api
gems/greenhouse_io-2.1.0/lib/greenhouse_io/api/job_board.rb:38 apply_to_job

(This is being caught by HTTParty::Parser which is giving the message:
NotImplementedError: HTTParty::Parser has not implemented a parsing method for the :json format.)

This may be happening with all submissions, or just those with file uploads. I don't currently have an example without a required file upload to test with

The submission and upload are being processed by greenhouse successfully (and the user receives a confirmation email), this error is happening when the gem receives the response from the gh API.

The gem versions we're using are:

greenhouse_io (2.1.0)
httmultiparty (0.3.16)
httparty (0.13.3)
mimemagic (0.2.1)
multi_json (1.10.1)
multi_xml (0.5.5)

Where do you find your API key?

I've looked everywhere and I can't find my API key. This should be in the readme and the docs -- it's referred to but there are not links to it anywhere. Thanks!

Return last page of pagination

Hi! I'm pulling down several pages of data, and currently having to do this:

    (1..Float::INFINITY).each do |page|
      retrieved_page = candidates(page)

      if retrieved_page.present?
        retrieved_page.each do |candidate|
          # ... do stuff
        end
      else
        break
      end
    end

It would be great to know the last page number, given some per_page value. Maybe client.candidates.last_page(per_page: 500) or whatnot.

bundle install issue in ruby 3

currently my bundle won't install because of this issue

Installing mimemagic 0.4.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/andrzej/Documents/honeypot/honeypot/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.4.3/ext/mimemagic
/usr/local/opt/ruby/bin/ruby -I/usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0 -rrubygems
/Users/andrzej/Documents/honeypot/honeypot/vendor/bundle/ruby/3.0.0/gems/rake-12.3.3/exe/rake
RUBYARCHDIR\=/Users/andrzej/Documents/honeypot/honeypot/vendor/bundle/ruby/3.0.0/extensions/x86_64-darwin-20/3.0.0/mimemagic-0.4.3
RUBYLIBDIR\=/Users/andrzej/Documents/honeypot/honeypot/vendor/bundle/ruby/3.0.0/extensions/x86_64-darwin-20/3.0.0/mimemagic-0.4.3
rake aborted!
ArgumentError: wrong number of arguments (given 2, expected 1)
/Users/andrzej/Documents/honeypot/honeypot/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.4.3/ext/mimemagic/Rakefile:28:in `block in <top (required)>'
/Users/andrzej/Documents/honeypot/honeypot/vendor/bundle/ruby/3.0.0/gems/rake-12.3.3/exe/rake:27:in `<main>'
Tasks: TOP => default
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /Users/andrzej/Documents/honeypot/honeypot/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.4.3 for inspection.
Results logged to /Users/andrzej/Documents/honeypot/honeypot/vendor/bundle/ruby/3.0.0/extensions/x86_64-darwin-20/3.0.0/mimemagic-0.4.3/gem_make.out

An error occurred while installing mimemagic (0.4.3), and Bundler cannot continue.
Make sure that `gem install mimemagic -v '0.4.3' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  greenhouse_io was resolved to 2.5.0, which depends on
    httmultiparty was resolved to 0.3.16, which depends on
      mimemagic

seems like httpmultiparty is not maintained.

Option to enable debugging

I wanted to enable the debug_output for HTTParty (part of HTTMultiParty) but I have trouble doing so in my own code. In lib/greenhouse_io/api/client.rb there is the possibility to set debug_output $stdout (for example). I cannot do this in my own code, it seems to be limited to where include HTTMultiParty is specified. Do you plan on adding such debug option described above, because it would really help debugging a lot!

UPDATE: I've found a workaround that works for me, invoking: GreenhouseIo::Client.debug_output $stdout before instantiating Client.new seems to give me the desired behaviour.

Offers and applications POST

Hi,
Thank you for the useful API and for all the work you put into this.
There is this use case where I am required to POST offers and applications.
As far as I could notice in the docs plus some other clients I could find, there's no such option implemented yet.
Is this feature on the road-map?
Best,
Io

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.