Class: AllHours::Task

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, api:) ⇒ Task

Returns a new instance of Task.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/all_hours/task.rb', line 23

def initialize data:, api:
  @api = api
  @id = data["id"]
  @name = data["name"]
  @project_ids = data["project_ids"]
  @section = data["section"]
  @labels = data["labels"]
  @tags = data["tags"]
  @position = data["position"]
  @description = data["description"]
  @dueAt = Date.parse data["dueAt"] unless data["dueAt"].nil?
  @status = data["status"]
  @time = data["time"]
  @estimate = data["estimate"]
  @attributes = data["attributes"]
  @metrics = data["metrics"]
  @unbillable = data["unbillable"]
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def attributes
  @attributes
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def description
  @description
end

#dueAtObject

Returns the value of attribute dueAt.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def dueAt
  @dueAt
end

#estimateObject

Returns the value of attribute estimate.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def estimate
  @estimate
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def id
  @id
end

#labelsObject

Returns the value of attribute labels.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def labels
  @labels
end

#metricsObject

Returns the value of attribute metrics.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def metrics
  @metrics
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def name
  @name
end

#positionObject

Returns the value of attribute position.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def position
  @position
end

#project_idsObject

Returns the value of attribute project_ids.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def project_ids
  @project_ids
end

#sectionObject

Returns the value of attribute section.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def section
  @section
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def status
  @status
end

#tagsObject

Returns the value of attribute tags.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def tags
  @tags
end

#timeObject

Returns the value of attribute time.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def time
  @time
end

#unbillableObject

Returns the value of attribute unbillable.



7
8
9
# File 'lib/all_hours/task.rb', line 7

def unbillable
  @unbillable
end

Class Method Details

.find(api:, task_id:) ⇒ Object



42
43
44
45
# File 'lib/all_hours/task.rb', line 42

def self.find api:, task_id:
  data = api.api_call path: "tasks/#{task_id}"
  Task.new api: api, data: data
end

.search(api:, limit: 100, query: nil, searchInClosed: false) ⇒ Object



47
48
49
50
51
52
53
54
55
# File 'lib/all_hours/task.rb', line 47

def self.search api:, limit: 100, query: nil, searchInClosed: false
  data = api.api_call(path: "tasks/search", query: {limit: limit, query: query, searchInClosed: searchInClosed})
  tasks = []
  data.each do |task_data|
    tasks << Task.new(api: api, data: task_data)
  end

  tasks
end