This is a thin ruby wrapper around the WhenIWork's API.
NOTE: this is a work in progress. Please check the TODO section for details on what's missing. Contributions are welcome!
Add this line to your application's Gemfile:
gem 'wheniwork'
And then execute:
$ bundle
Or install it yourself as:
$ gem install wheniwork
In order to use it, require the gem:
require 'wheniwork'
Then, add your credentials to the configuration:
WhenIWork.configure do |c|
c.username = '<YOUR USERNAME>'
c.password = '<YOUR PASSWORD>'
c.api_key = '<YOUR API KEY>'
end
Check the options section to see what configuration options you can use. Finally, use the client:
=> client = WhenIWork::Client.new
=> client.shifts
=> => {"start"=>"Fri, 19 Jul 2013 16:56:34 +0100",
"end"=>"Mon, 22 Jul 2013 16:56:34 +0100",
"shifts"=>
[{"id"=>10876241,
"account_id"=>11111,
"user_id"=>222222,
"location_id"=>33333,
"position_id"=>44444,
...
The gem uses active support caching to cache the requests for 1 minute. This is configurable through the configuration block:
WhenIWork.configure do |c|
c.cache_store = Rails.cache
c.cache_enabled = true
end
If you set cache_enabled to false, nothing will be cached:
WhenIWork.configure do |c|
c.cache_enabled = false
end
- Add missing endpoints - we currently only handle a few endpoints, would be great to be able to cover the entire API;
- Error handling - there isn't error handling at the moment - something to consider when issues occur;
- Test caching logic.
- Fork the repository.
- Create a topic branch.
- Add specs for your unimplemented feature or bug fix.
- Run
bundle exec rake
. If your specs pass, return to step 3. - Implement your feature or bug fix.
- Run
bundle exec rake
. If your specs fail, return to step 5. - Add documentation for your feature or bug fix.
- Add, commit, and push your changes.
- Submit a pull request.
Copyright (c) 2013 Forward Labs. See LICENSE for details.
wheniwork_ext