Class: Trebbiatrice::Harvest

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

Instance Method Summary collapse

Constructor Details

#initialize(login_data) ⇒ Harvest

Returns a new instance of Harvest.



13
14
15
# File 'lib/trebbiatrice/harvest.rb', line 13

def initialize()
  @harvest = ::Harvest.hardy_client()
end

Instance Method Details

#new_entry!(entry_data, find = true) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/trebbiatrice/harvest.rb', line 21

def new_entry!(entry_data, find = true)
  if find
    project_id = entry_data[:project_id].to_s
    entry = @harvest.time.all.select { |entry| entry[:project_id].to_s == project_id }.last

    if entry
      toggle!(entry[:id])
      entry
    else
      new_entry!(entry_data, false)
    end
  else
    @harvest.time.create(entry_data)
  end
end

#projectsObject



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

def projects
  @harvest.time.trackable_projects
end

#toggle!(entry_id) ⇒ Object



37
38
39
# File 'lib/trebbiatrice/harvest.rb', line 37

def toggle!(entry_id)
  @harvest.time.toggle(entry_id)
end