Class: Cashboard::TimeEntry

Inherits:
Base show all
Defined in:
lib/cashboard/time_entry.rb

Instance Attribute Summary

Attributes inherited from Base

#href, #id

Instance Method Summary collapse

Methods inherited from Base

authenticate, clear_authentication, create, #delete, #links, list, new_from_url, #to_xml, #update

Methods inherited from Struct

#initialize

Methods inherited from TypecastedOpenStruct

attr_typecast, element

Constructor Details

This class inherits a constructor from Cashboard::Struct

Instance Method Details

#has_been_invoiced?Boolean

If a TimeEntry has no invoice_line_item_id set, then it hasn’t been included on an invoice.

Returns:



40
41
42
# File 'lib/cashboard/time_entry.rb', line 40

def has_been_invoiced?
  !self.invoice_line_item_id.blank?
end

#toggle_timerObject

Starts or stops timer depending on its current state.

Will return an object of Cashboard::Struct if another timer was stopped during this toggle operation.

Will return nil if no timer was stopped.



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

def toggle_timer
  options = self.class.merge_options()
  options.merge!({:body => self.to_xml})
  response = self.class.put(self.links[:toggle_timer], options)
  
  # Raise special errors if not a success
  self.class.check_status_code(response)
  
  # Re-initialize ourselves with information from response
  initialize(response.parsed_response)
  
  if self.stopped_timer
    stopped_timer = Cashboard::Struct.new(self.stopped_timer)
  end
  
  stopped_timer || nil
end