Class: Dobedobedo::Task

Inherits:
Object
  • Object
show all
Includes:
ObjToJson
Defined in:
lib/dobedobedo/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ObjToJson

#objToJson, #obj_to_json, #obj_to_json2

Constructor Details

#initialize(token, workspace_id, project_id = nil, h = {}) ⇒ Task

Returns a new instance of Task.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dobedobedo/task.rb', line 7

def initialize(token, workspace_id, project_id=nil, h={})
  @token = token
  @workspace_id = workspace_id
  if h.empty?
    if project_id.nil?
      h = token.post("/workspaces/#{workspace_id}/tasks").parsed
    else
      h = token.post("/workspaces/#{workspace_id}/projects/#{project_id}/tasks").parsed
    end
  end
  h.each do |k,v|
    Task.send(:attr_accessor, k.to_sym)
    self.send("#{k}=".to_sym, v)
  end
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



5
6
7
# File 'lib/dobedobedo/task.rb', line 5

def token
  @token
end

Instance Method Details

#closeObject



32
33
34
35
# File 'lib/dobedobedo/task.rb', line 32

def close()
  payload = {:closed => true}
  @token.put("/workspaces/#{@workspace_id}/tasks/#{@id}", :body => payload)
end

#commentsObject



23
24
25
# File 'lib/dobedobedo/task.rb', line 23

def comments
  @token.get("/workspaces/#{workspace_id}/tasks/#{id}/comments").parsed.map {|n| Dobedobedo::Comment.new(@token, n)}
end

#deleteObject



37
38
39
# File 'lib/dobedobedo/task.rb', line 37

def delete()
  @token.delete("/workspaces/#{@workspace_id}/tasks/#{@id}")
end

#updateObject



27
28
29
30
# File 'lib/dobedobedo/task.rb', line 27

def update()
  payload = {:name => @name, :description => @description, :deleted => @deleted}
  @token.put("/workspaces/#{@workspace_id}/tasks/#{@id}", :body => payload)
end