Class: GetToWork::Service::Harvest
Instance Attribute Summary collapse
#api_token
Instance Method Summary
collapse
display_name, #display_name, #keychain, #name, #save_config, #set_client_token, #update_keychain, #yaml_key
Constructor Details
#initialize(yaml_hash) ⇒ Harvest
Returns a new instance of Harvest.
9
10
11
12
13
|
# File 'lib/get_to_work/service/harvest.rb', line 9
def initialize(yaml_hash)
super(yaml_hash)
@harvest = nil
end
|
Instance Attribute Details
#project_id ⇒ Object
Returns the value of attribute project_id.
8
9
10
|
# File 'lib/get_to_work/service/harvest.rb', line 8
def project_id
@project_id
end
|
#subdomain ⇒ Object
Returns the value of attribute subdomain.
8
9
10
|
# File 'lib/get_to_work/service/harvest.rb', line 8
def subdomain
@subdomain
end
|
#task_id ⇒ Object
Returns the value of attribute task_id.
8
9
10
|
# File 'lib/get_to_work/service/harvest.rb', line 8
def task_id
@task_id
end
|
Instance Method Details
#api_client ⇒ Object
15
16
17
18
19
20
21
|
# 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:) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# 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 ⇒ Object
23
24
25
26
27
|
# File 'lib/get_to_work/service/harvest.rb', line 23
def authenticate_with_keychain
if !@subdomain.blank? && keychain
return api_client
end
end
|
#clients ⇒ Object
42
43
44
|
# File 'lib/get_to_work/service/harvest.rb', line 42
def clients
@clients ||= get_clients
end
|
#get_clients ⇒ Object
46
47
48
|
# File 'lib/get_to_work/service/harvest.rb', line 46
def get_clients
api_client.clients.all
end
|
#get_time ⇒ Object
50
51
52
|
# File 'lib/get_to_work/service/harvest.rb', line 50
def get_time
api_client.time
end
|
#project ⇒ Object
60
61
62
|
# File 'lib/get_to_work/service/harvest.rb', line 60
def project
projects.find(@project_id)
end
|
#projects ⇒ Object
54
55
56
57
58
|
# 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 = {}) ⇒ Object
64
65
66
|
# File 'lib/get_to_work/service/harvest.rb', line 64
def start_timer(opts = {})
api_client.time.create(opts)
end
|
#stop_timer(timer_id) ⇒ Object
68
69
70
|
# File 'lib/get_to_work/service/harvest.rb', line 68
def stop_timer(timer_id)
api_client.time.toggle(timer_id)
end
|