Code Monkey home page Code Monkey logo

wheniwork's Introduction

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's People

Contributors

carvil avatar rkiller avatar

Watchers

James Cloos avatar  avatar

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.