Class: Harvest::TimeTracking

Inherits:
Base
  • Object
show all
Defined in:
lib/harvest/time_tracking.rb

Instance Attribute Summary

Attributes inherited from Base

#domain, #email, #password, #use_ssl

Instance Method Summary collapse

Methods inherited from Base

#initialize, #rate_limit_status

Constructor Details

This class inherits a constructor from Harvest::Base

Instance Method Details

#add(body) ⇒ Object

POST /daily/add



27
28
29
# File 'lib/harvest/time_tracking.rb', line 27

def add(body)
  Mash.new(self.class.post("/daily/add", :body => body)).add.day_entry
end

#daily(date = nil) ⇒ Object

GET /daily GET /daily/#day_of_the_year/#year



6
7
8
9
10
11
12
13
14
# File 'lib/harvest/time_tracking.rb', line 6

def daily(date=nil)
  date = DateTime.parse(date) if date.is_a?(String)
  if date.respond_to?(:yday)
    response = self.class.get("/daily/#{date.yday}/#{date.year}")
  else
    response = self.class.get('/daily')
  end
  response
end

#delete(id) ⇒ Object

DELETE /daily/delete/#day_entry_id



32
33
34
# File 'lib/harvest/time_tracking.rb', line 32

def delete(id)
  Mash.new(self.class.delete("/daily/delete/#{id}"))
end

#entry(id) ⇒ Object

GET /daily/show/#day_entry_id



17
18
19
# File 'lib/harvest/time_tracking.rb', line 17

def entry(id)
  Mash.new(self.class.get("/daily/show/#{id}")).add.day_entry
end

#toggle(id) ⇒ Object

GET /daily/timer/#day_entry_id



22
23
24
# File 'lib/harvest/time_tracking.rb', line 22

def toggle(id)
  Mash.new(self.class.get("/daily/timer/#{id}")).timer.day_entry
end

#update(id, body) ⇒ Object

POST /daily/update/#day_entry_id



37
38
39
40
41
42
# File 'lib/harvest/time_tracking.rb', line 37

def update(id, body)
  # current_entry = entry(id)
  # body = current_entry.merge(Mash.new body.to_hash)
  # puts body.inspect
  Mash.new(self.class.post("/daily/update/#{id}", :body => body)).add.day_entry
end