Skip to content

looppi/wheniwork

 
 

Repository files navigation

Wheniwork

Build Status Code Climate Gem Version

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!

Installation

Add this line to your application's Gemfile:

gem 'wheniwork'

And then execute:

$ bundle

Or install it yourself as:

$ gem install wheniwork

Usage

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,
      ...

Caching

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

TODO

  • 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.

Contributing

  1. Fork the repository.
  2. Create a topic branch.
  3. Add specs for your unimplemented feature or bug fix.
  4. Run bundle exec rake. If your specs pass, return to step 3.
  5. Implement your feature or bug fix.
  6. Run bundle exec rake. If your specs fail, return to step 5.
  7. Add documentation for your feature or bug fix.
  8. Add, commit, and push your changes.
  9. Submit a pull request.

Copyright

Copyright (c) 2013 Forward Labs. See LICENSE for details.

wheniwork_ext

About

Ruby wrapper around http://dev.wheniwork.com/

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%