Class: Paymo::Entries

Inherits:
Object
  • Object
show all
Defined in:
lib/paymo/resources/entries.rb

Instance Method Summary collapse

Instance Method Details

#add(start_date, end_date, task_id, options = {}) ⇒ Object

options - hash of added_manually (boolean), billed (boolean), description (string)



84
85
# File 'lib/paymo/resources/entries.rb', line 84

def add(start_date, end_date, task_id, options = {})
end

#add_bulk(date, duration, task_id, options = {}) ⇒ Object

 options - hash of billed (boolean) and description



88
89
# File 'lib/paymo/resources/entries.rb', line 88

def add_bulk(date, duration, task_id, options = {})
end

#delete(entry_id) ⇒ Object



96
97
# File 'lib/paymo/resources/entries.rb', line 96

def delete(entry_id)
end

#find_by_project(project_id, options = {}) ⇒ Object

Find entries for all tasks from the specified project matching the optional time criteria. options - start_date, end_date



41
42
43
44
45
46
47
48
49
# File 'lib/paymo/resources/entries.rb', line 41

def find_by_project(project_id, options = {})
  options.merge!({project_id: project_id })
  result = Paymo::API.get :entries, :find_by_project, options
  if result['status'] == 'ok'
    result['entries']['entry'].map! do |entry|
      Paymo::Entry.new(entry)
    end
  end
end

#find_by_task(task_id, options = {}) ⇒ Object

Find entries for a specified task matching the optional time criteria. options - start_date, end_date



34
35
36
37
# File 'lib/paymo/resources/entries.rb', line 34

def find_by_task(task_id, options = {})
  options.merge!({task_id: task_id })
  Paymo::API.get :entries, :find_by_task, options
end

#find_by_user(user_id, options = {}) ⇒ Object

Find entries for a specified user matching the optional time criteria. options - start_date, end_date



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/paymo/resources/entries.rb', line 14

def find_by_user(user_id, options = {})
  options.merge!({user_id: user_id })
  if options[:start]
    options[:start] = options[:start].strftime('%Y-%m-%d %H:%M:%S')
  end
  if options[:end]
    options[:end] = options[:end].strftime('%Y-%m-%d %H:%M:%S')
  end
  result = Paymo::API.get :entries, :find_by_user, options
  if result['status'] == 'ok'
    if result['entries'].any?
      result['entries']['entry'].map! do |entry|
        Paymo::Entry.new(entry)
      end
    end
  end
end

#get_info(entry_id) ⇒ Object

Get detailed information about an entry.



5
6
7
8
9
10
# File 'lib/paymo/resources/entries.rb', line 5

def get_info(entry_id)
  result = Paymo::API.get :entries, :get_info, entry_id: entry_id
  if result['status'] == 'ok'
    Paymo::Entry.new(result['entry'])
  end
end

#get_tracked_time_by_project(project_id, options = {}) ⇒ Object

options - start_date, end_date



76
77
78
79
80
# File 'lib/paymo/resources/entries.rb', line 76

def get_tracked_time_by_project(project_id, options = {})
  options.merge!({project_id: project_id })
  result = Paymo::API.get :entries, :get_tracked_time_by_project, options
  { time: result['time']['_content'] }
end

#get_tracked_time_by_task(task_id, options = {}) ⇒ Object

Returns the total amount of time tracked (in seconds) in all the entries for the given task matching the optional time criteria. options - start_date, end_date



69
70
71
72
73
# File 'lib/paymo/resources/entries.rb', line 69

def get_tracked_time_by_task(task_id, options = {})
  options.merge!({task_id: task_id })
  result = Paymo::API.get :entries, :get_tracked_time_by_task, options
  { time: result['time']['_content'] }
end

#get_tracked_time_by_user(user_id, options = {}) ⇒ Object

Returns the total amount of time tracked (in seconds) in all the entries for the given user matching the optional time criteria. options - start_date, end_date



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/paymo/resources/entries.rb', line 54

def get_tracked_time_by_user(user_id, options = {})
  options.merge!({user_id: user_id })
  if options[:start]
    options[:start] = options[:start].strftime('%Y-%m-%d %H:%M:%S')
  end
  if options[:end]
    options[:end] = options[:end].strftime('%Y-%m-%d %H:%M:%S')
  end
  result = Paymo::API.get :entries, :get_tracked_time_by_user, options
  { time: result['time']['_content'] }
end

#update(entry_id, start_date, end_date, options = {}) ⇒ Object

options - task_id, added_manually = true, billed = false, description



92
93
# File 'lib/paymo/resources/entries.rb', line 92

def update(entry_id, start_date, end_date, options = {})
end