Ruby wrapper for the Bullhorn REST API. For additional information on the API itself, see the official Bullhorn documentation.
Add this line to your application's Gemfile:
gem 'bullhorn-rest'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bullhorn-rest
If you haven't accessed the bullhorn API before, it may be nececarry to follow these additional steps:
- Visit
https://auth.bullhornstaffing.com/oauth/authorize?action=Login&client_id=XXX&response_type=code&username=XXX
in a browser, replacing the client_id and username with your credentials. - Type the password into the login form.
- Check that you are redirected to the redirect URL and that a
code
parameter has been appended to the URL.
require 'bullhorn/rest'
client = Bullhorn::Rest::Client.new(username: '<USERNAME>', password: '<PASSWORD>', client_id: '<CLIENT_ID>', client_secret: '<CLIENT_SECRET>')
# Returns all candidates
client.candidates
# Returns all candidates belonging to the current user
client.user_candidates
# Returns all candidates belonging to the user's department
client.department_candidates
# Get data for a particular candidate
client.candidate(id)
# Geta for multiple candidates
client.candidate([id1, id2])
# Update a candidate
client.update_candidate(id, attributes)
# Create a candidate
client.create_candidate(attributes)
# Delete a candidate
client.delete_candidate(id)
# Query for candidates
client.query_candidates(where: "email = 'brogrammer@bigco.com'")
The above api methods generalize to all entities in the system. E.g. for the JobOrder
entity simple replace occurences of candidate
with job_order
in all of the above methods.
The following entities are exposed via the API:
- appointment
- appointment_attendee
- business_sector
- candidate
- candidate_certification
- candidate_education
- candidate_reference
- candidate_work_history
- category
- client_contact
- client_corporation
- corporate_user
- corporation_department
- country
- custom_action
- job_order
- job_submission
- note
- note_entity
- placement
- placement_change_request
- placement_commission
- sendout
- skill
- specialty
- state
- task
- tearsheet
- tearsheet_recipient
- time_unit
Additionally, the following entities have user_<entity>
and department_<entity>
methods available:
- candidate
- client_contact
- client_corporation
- job_order
- note
- placement
The following entities are immutable and do not have any of the update/create/delete methods available:
- category
- corporate_user
- country
- skill
- specialty
- state
- time_unit
By adding the magic that is: https://github.com/intridea/hashie we can now refer to the JSON responses directly in ruby.
res = client.candidates
start = res.start
total = res.total
You can go as deeply nested in the response as you like and all the array/collection goodness Ruby supports is yours.
Any request that returns multiple items will be paginated to 100 items by default. Any query will return 500 by default. You can override these.
In order to iterate through the entire result set page by page, you can use convenience methods: has_next_page? and next_page like in the following:
res = client.candidates
while res.has_next_page?
... process response ...
res.next_page
end
"Has Many" associations can be accessed by passing in the name of the association in the association
key of the options hash on the normal entity method. For instance, in order to get all of the candidates associated with a tearsheet:
candidates = client.tearsheet(id, association: 'candidates')
- Fork it ( http://github.com//bullhorn-rest/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request