class GetToWork::Service::Harvest
Attributes
project_id[R]
subdomain[R]
task_id[R]
Public Class Methods
new(yaml_hash)
click to toggle source
Calls superclass method
GetToWork::Service::new
# File lib/get_to_work/service/harvest.rb, line 9 def initialize(yaml_hash) super(yaml_hash) @harvest = nil end
Public Instance Methods
api_client()
click to toggle source
# File lib/get_to_work/service/harvest.rb, line 15 def api_client @api_client ||= ::Harvest.client( subdomain: @subdomain, username: keychain.account, password: keychain.password ) end
authenticate(username:, password:, subdomain:)
click to toggle source
# File lib/get_to_work/service/harvest.rb, line 29 def authenticate(username:, password:, subdomain:) @subdomain = subdomain @api_client = ::Harvest.client( subdomain: @subdomain, username: username, password: password ) if @api_client @api_token = password end end
authenticate_with_keychain()
click to toggle source
# File lib/get_to_work/service/harvest.rb, line 23 def authenticate_with_keychain if !@subdomain.blank? && keychain return api_client end end
clients()
click to toggle source
# File lib/get_to_work/service/harvest.rb, line 42 def clients @clients ||= get_clients end
get_clients()
click to toggle source
# File lib/get_to_work/service/harvest.rb, line 46 def get_clients api_client.clients.all end
get_time()
click to toggle source
# File lib/get_to_work/service/harvest.rb, line 50 def get_time api_client.time end
project()
click to toggle source
# File lib/get_to_work/service/harvest.rb, line 60 def project projects.find(@project_id) end
projects()
click to toggle source
# File lib/get_to_work/service/harvest.rb, line 54 def projects api_client.time.trackable_projects.sort do |x, y| x[:name] <=> y[:name] end end
start_timer(opts = {})
click to toggle source
# File lib/get_to_work/service/harvest.rb, line 64 def start_timer(opts = {}) api_client.time.create(opts) end
stop_timer(timer_id)
click to toggle source
# File lib/get_to_work/service/harvest.rb, line 68 def stop_timer(timer_id) api_client.time.toggle(timer_id) end