Project

timely-app

0.0
The project is in a healthy, maintained state
Ruby client for the Timely API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

timely-app

Gem Version Test Status codecov

Ruby client for the Timely API.

Sponsored by Kisko Labs.

Install

Using Bundler:

bundle add timely-app

Using RubyGems:

gem install timely-app

Usage for CLI

Register your local service at https://app.timelyapp.com/{account_id}/oauth_applications

Install timely-app gem as dependency or globally.

Run auth:

TIMELY_CLIENT_ID=<client_id> TIMELY_CLIENT_SECRET=<client_secret> bundle exec timely-app auth -s

Usage for web service

Example web server: ./examples/auth_server.rb

Implement link to Timely OAuth authorization page:

<%= link_to "Sign in with Timely", TimelyApp::Client.new.get_oauth_authorize_url(client_id: ENV.fetch("TIMELY_CLIENT_ID"), redirect_uri: ENV.fetch("TIMELY_REDIRECT_URI")) %>

Implement callback action to get access token (devise example):

def timely_auth_callback
  skip_verify_authorized!

  client = TimelyApp::Client.new
  token = client.post_oauth_token(client_id: ENV.fetch("TIMELY_CLIENT_ID"), client_secret: ENV.fetch("TIMELY_CLIENT_SECRET"), code: params["code"], redirect_uri: ENV.fetch("TIMELY_REDIRECT_URI"), grant_type: "authorization_code")

  if token["access_token"].present?
    client.access_token = token["access_token"]
    timely_user = client.get_current_user

    user = User.find_or_create_by(email: timely_user["email"])
    user.update!(timely_id: timely_user["id"], timely_access_token: token["access_token"], timely_refresh_token: token["refresh_token"])

    sign_in(user)

    redirect_to "/authorized"
  else
    redirect_to "/not-authorized"
  end
rescue TimelyApp::Error => _e
  redirect_to "/not-authorized"
end

Client usage

timely = TimelyApp::Client.new(access_token: <USER_TOKEN_AFTER_OAUTH>, account_id: <ACCOUNT_ID>)

timely.get_projects.each do |project|
  puts project.name
end

How to test callbacks

You can use localhost.run to test callbacks locally.

There are large list of available tools for tunneling: awesome-tunneling

Acknowledgment

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/amkisko/timely-app

Publishing

rm timely-app-*.gem
gem build timely-app.gemspec
gem push timely-app-*.gem

License

The gem is available as open source under the terms of the MIT License.