Class: Phabricator::Maniphest::Task

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

Defined Under Namespace

Modules: Priority

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Task

Returns a new instance of Task.



48
49
50
51
52
53
# File 'lib/phabricator/maniphest/task.rb', line 48

def initialize(attributes)
  @id = attributes['id']
  @title = attributes['title']
  @description = attributes['description']
  @priority = attributes['priority']
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



29
30
31
# File 'lib/phabricator/maniphest/task.rb', line 29

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



28
29
30
# File 'lib/phabricator/maniphest/task.rb', line 28

def id
  @id
end

#priorityObject

Returns the value of attribute priority.



29
30
31
# File 'lib/phabricator/maniphest/task.rb', line 29

def priority
  @priority
end

#titleObject

Returns the value of attribute title.



29
30
31
# File 'lib/phabricator/maniphest/task.rb', line 29

def title
  @title
end

Class Method Details

.create(title, description = nil, projects = [], priority = 'normal', owner = nil, ccs = [], other = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/phabricator/maniphest/task.rb', line 31

def self.create(title, description=nil, projects=[], priority='normal', owner=nil, ccs=[], other={})
  response = JSON.parse(client.request(:post, 'maniphest.createtask', {
    title: title,
    description: description,
    priority: Priority.send(priority),
    projectPHIDs: projects.map {|p| Phabricator::Project.find_by_name(p).phid },
    ownerPHID: owner ? Phabricator::User.find_by_name(owner).phid : nil,
    ccPHIDs: ccs.map {|c| Phabricator::User.find_by_name(c).phid }
  }.merge(other)))

  data = response['result']

  # TODO: Error handling

  self.new(data)
end