Breathe
A Ruby Wrapper for the BreatheHR API
Installation
Add this line to your application's Gemfile:
gem 'breathe'
And then execute:
bundle
Or install it yourself as:
gem install breathe
Usage
Require the gem:
require "breathe"
Initialize the client like so:
client = Breathe::Client.new(api_key: YOUR_API_KEY)
And use like so
List absences (Holiday and Other leave)
client.absences.list
#=> [...]
List sicknesses
client.sicknesses.list
#=> [...]
List employees
client.employees.list
#=> [...]
Get an employee by ID
client.employees.get(id)
#=> [...]
List employee training courses
client.employee_training_courses.list
#=> [...]
Filtering
You can also pass in arguments like so:
client.absences(per_page: 12, start_date: Date.today)
#=> [...]
Pagination
You can also paginate through the data like so:
client.absences.list.next_page
#=> [...]
client.absences.list.previous_page
#=> [...]
client.absences.list.last_page
#=> [...]
client.absences.list.first_pages
#=> [..]
If you don't want to paginate at all, you can initialize the client with the auto_paginate
argument set to true
like so:
client = Breathe::Client.new(api_key: YOUR_API_KEY, auto_paginate: true)
Only the absences endpoint is currently supported. PRs are accepted for more endpoints!
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
To release a new version, update the version number in lib/breathe/version.rb
, commit the change and then create a git tag for that version in the format x.x.x
(where x is each version number). Github Actions will then automatically push the latest version to Rubygems.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/breathe. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Breathe project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.