class TogglIntegrator::Toggl

class Toggl

Public Class Methods

my_projects() click to toggle source
# File lib/toggl_integrator/toggl.rb, line 10
def my_projects
  user = api.me true
  api.my_projects(user).map do |i|
    {
      'id' => i['id'], 'name' => i['name']
    }
  end
end
time_entries() click to toggle source
# File lib/toggl_integrator/toggl.rb, line 19
def time_entries
  api.get_time_entries dates.map { |k, v| [k, v.to_s] }.to_h
end

Private Class Methods

api() click to toggle source
# File lib/toggl_integrator/toggl.rb, line 25
def api
  @api ||= TogglV8::API.new ENV['TOGGL_API_TOKEN']
end
dates() click to toggle source
# File lib/toggl_integrator/toggl.rb, line 29
def dates
  return @dates if @dates.present?

  today = Date.today
  @dates = { start_date: today - 1, end_date: today + 1 }
end