No commit activity in last 3 years
No release in over 3 years
Simple gem to help integrate with RescueTime
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

rescue_time_client

A ruby gem to ease integrate with RescueTime API using OAuth2

##Installation

Will publish the gem soon to rubygems, till then:

Add this to your Gemfile:

gem 'rescue_time_client'

Creating a client

require 'rescue_time_client'

cl = RescueTime::Client.new('your_client_id', 'your_client_secret', 'your_callback_url (exact match)')

Note: This step is necessary for any interaction with the gem

Authenticating a user

auth_url = cl.get_auth_url(["scope1","scope2",...]) #add your required scopes in the array

Redirect user to the auth_url on the browser. After authenticating, RescueTime will return to your callback_url with a code. Pass the code to get access_token as below.

token = cl.get_token_from_code('code_from_above')

You may store the token for future purposes and continue making API calls.

Note: Currently RescueTime tokens do not expire.

Initializing user from token

When you want to initialize user from a token stored somewhere, use:

cl.set_token('token_from_db')

Making API calls

The gem makes dynamic calls to the API. Anything starting with fetch_ is a dynamic API call. For e.g.:

cl.fetch_daily_summary_data({param1: "something", param2: "other"}) #calls the daily_summary_data endpoint with the params
cl.fetch_productivity_data({param1: "something", param2: "other"}) #calls the productivity_data endpoint with the params

Thats how you can call any API endpoint. All API's return data in json format. RescueTime supports no other format as of today except for csv which is beyond the scope of this gem. format: 'json' is automatically appended for every API request made.

Note-1: The token should be set to make API calls.

Note-2: All endpoints should be prefixed with fetch_ without which it will raise a NoMethodError

##Contribution

Please feel free to fork and add pull requests.