Class: Dobedobedo::Task
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
#token ⇒ Object
Returns the value of attribute token.
5
6
7
|
# File 'lib/dobedobedo/task.rb', line 5
def token
@token
end
|
Instance Method Details
#close ⇒ Object
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
|
23
24
25
|
# File 'lib/dobedobedo/task.rb', line 23
def
@token.get("/workspaces/#{workspace_id}/tasks/#{id}/comments").parsed.map {|n| Dobedobedo::Comment.new(@token, n)}
end
|
#delete ⇒ Object
37
38
39
|
# File 'lib/dobedobedo/task.rb', line 37
def delete()
@token.delete("/workspaces/#{@workspace_id}/tasks/#{@id}")
end
|
#update ⇒ Object
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
|