Class: TimeCamp::Entry

Inherits:
Resource show all
Defined in:
lib/ruby-timecamp/resources/entry.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Resource

#attributes, #initialize, resource_name

Constructor Details

This class inherits a constructor from TimeCamp::Resource

Instance Attribute Details

#addons_external_idObject (readonly)

Returns the value of attribute addons_external_id.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def addons_external_id
  @addons_external_id
end

#billableObject (readonly)

Returns the value of attribute billable.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def billable
  @billable
end

#dateObject (readonly)

Returns the value of attribute date.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def date
  @date
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def description
  @description
end

#durationObject (readonly)

Returns the value of attribute duration.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def duration
  @duration
end

#end_timeObject (readonly)

Returns the value of attribute end_time.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def end_time
  @end_time
end

#end_time_hourObject (readonly)

Returns the value of attribute end_time_hour.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def end_time_hour
  @end_time_hour
end

#entry_idObject (readonly)

Returns the value of attribute entry_id.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def entry_id
  @entry_id
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def id
  @id
end

#invoice_idObject (readonly)

Returns the value of attribute invoice_id.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def invoice_id
  @invoice_id
end

#last_modifyObject (readonly)

Returns the value of attribute last_modify.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def last_modify
  @last_modify
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def name
  @name
end

#noteObject (readonly)

Returns the value of attribute note.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def note
  @note
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def start_time
  @start_time
end

#start_time_hourObject (readonly)

Returns the value of attribute start_time_hour.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def start_time_hour
  @start_time_hour
end

#started_atObject (readonly)

Returns the value of attribute started_at.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def started_at
  @started_at
end

#task_idObject (readonly)

Returns the value of attribute task_id.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def task_id
  @task_id
end

#time_spanObject (readonly)

Returns the value of attribute time_span.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def time_span
  @time_span
end

#user_idObject (readonly)

Returns the value of attribute user_id.



3
4
5
# File 'lib/ruby-timecamp/resources/entry.rb', line 3

def user_id
  @user_id
end

Class Method Details

.create(opts = {}) ⇒ Object

required :date(%Y-%m-%d), :duration(in seconds) optional :note, :start_time(13:30:00), :end_time, :billable, :task_id



43
44
45
46
47
48
# File 'lib/ruby-timecamp/resources/entry.rb', line 43

def self.create(opts={})
  data_keys = [:date, :duration, :note, :start_time, :end_time, :billable, :task_id]
  data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h)
  response = TimeCamp::Request.post(resource_name, opts, data)
  return EntryCollection.parse(response)
end

.delete(opts = {}) ⇒ Object



59
60
61
62
63
64
# File 'lib/ruby-timecamp/resources/entry.rb', line 59

def self.delete(opts={})
  data_keys = [:id, :entry_id]
  data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h)
  response = TimeCamp::Request.delete(resource_name, opts, data)
  return EntryCollection.parse(response)
end

.get(opts = {}) ⇒ Object

Example GET response [

{
  "id":"3621",
  "duration":"3600", // in seconds
  "user_id":"123",
  "description":"",
  "last_modify":"2014-03-19 14:34:50",
  "billable":1,
  "task_id":"3132",
  "date":"2013-03-30",
  "start_time":"12:20:00", // this value may be null if user did not specify time frame
  "name":"Task name",
  "addons_external_id":"123241", // for integrations with Trello, Pivotal Tracker, etc., "0" if no integration
  "billable":0/1,
  "invoiceId":0/invoiceId
}

] required :from, :to optional :task_ids, :with_subtasks, :user_ids



31
32
33
34
# File 'lib/ruby-timecamp/resources/entry.rb', line 31

def self.get(opts={})
    response = TimeCamp::Request.get(resource_name, opts)
    return EntryCollection.parse(response)
end

.timers(opts = {}) ⇒ Object



36
37
38
39
# File 'lib/ruby-timecamp/resources/entry.rb', line 36

def self.timers(opts={})
  response = TimeCamp::Request.get('timer_running', opts)
  return EntryCollection.parse(response)
end

.update(opts = {}) ⇒ Object

required :id optional :duration, :note, :start_time, :end_time, :billable, :invoiceId, :task_id, :updateActivities



52
53
54
55
56
57
# File 'lib/ruby-timecamp/resources/entry.rb', line 52

def self.update(opts={})
  data_keys = [:id, :duration, :note, :start_time, :end_time, :billable, :invoiceId, :task_id, :updateActivities]
  data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h)
  response = TimeCamp::Request.put(resource_name, opts, data)
  return EntryCollection.parse(response)
end