Class: FreckleApi::Timer
Instance Method Summary collapse
- #discard!(api) ⇒ Object
- #log!(api, entry_date: nil, minutes: nil, description: '') ⇒ Object
- #pause!(api) ⇒ Object
- #reload!(api) ⇒ Object
- #start!(api) ⇒ Object
Methods inherited from Model
Methods included from Coercions
Instance Method Details
#discard!(api) ⇒ Object
28 29 30 31 32 |
# File 'lib/freckle_api/timer.rb', line 28 def discard!(api) api.request(:put, timer_uri(:discard), parse: false) response.code.to_i == 204 ? true : nil end |
#log!(api, entry_date: nil, minutes: nil, description: '') ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/freckle_api/timer.rb', line 17 def log!(api, entry_date: nil, minutes: nil, description: '') response = api.request(:put, timer_uri(:log), parse: false, body: { description: description }) response.code.to_i == 204 end |
#pause!(api) ⇒ Object
13 14 15 |
# File 'lib/freckle_api/timer.rb', line 13 def pause!(api) update api.request(:put, timer_uri(:pause)) end |
#reload!(api) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/freckle_api/timer.rb', line 34 def reload!(api) response = api.request(:get, FreckleApi.uri('projects', project.id, 'timer'), parse: false) response.code.to_i == 204 ? update(response.body) : nil end |
#start!(api) ⇒ Object
9 10 11 |
# File 'lib/freckle_api/timer.rb', line 9 def start!(api) update api.request(:put, timer_uri(:start)) end |