Class: FreshBooks::TimeEntry

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

Constant Summary collapse

TYPE_MAPPINGS =
{ 'time_entry_id' => Fixnum, 'project_id' => Fixnum, 
'task_id' => Fixnum, 'hours' => Float }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.delete(time_entry_id) ⇒ Object



624
625
626
627
628
# File 'lib/freshbooks.rb', line 624

def self.delete(time_entry_id)
  resp = FreshBooks::call_api('time_entry.delete', 'time_entry_id' => time_entry_id)

  resp.success?
end

.get(time_entry_id) ⇒ Object



614
615
616
617
618
# File 'lib/freshbooks.rb', line 614

def self.get(time_entry_id)
  resp = FreshBooks::call_api('time_entry.get', 'time_entry_id' => time_entry_id)

  resp.success? ? self.new_from_xml(resp.elements[1]) : nil
end

.list(options = {}) ⇒ Object



630
631
632
633
634
635
636
637
638
# File 'lib/freshbooks.rb', line 630

def self.list(options = {})
  resp = FreshBooks::call_api('time_entry.list', options)

  return nil unless resp.success?

  time_entry_elems = resp.elements[1].elements

  time_entry_elems.map { |elem| self.new_from_xml(elem) }
end

Instance Method Details

#createObject



599
600
601
602
603
604
605
606
# File 'lib/freshbooks.rb', line 599

def create
  resp = FreshBooks::call_api('time_entry.create', 'time_entry' => self)
  if resp.success?
    self.time_entry_id = resp.elements[1].text.to_i
  end

  resp.success? ? self.time_entry_id : nil
end

#deleteObject



620
621
622
# File 'lib/freshbooks.rb', line 620

def delete
  TimeEntry::delete(self.time_entry_id)
end

#updateObject



608
609
610
611
612
# File 'lib/freshbooks.rb', line 608

def update
  resp = FreshBooks::call_api('time_entry.update', 'time_entry' => self)

  resp.success?
end