Class: Tick::Project

Inherits:
Base
  • Object
show all
Defined in:
lib/tick/project.rb

Constant Summary collapse

XML_PROPERTIES =
%w( id budget client_id client_name closed_on created_at 
name opened_on owner_id sum_hours updated_at user_count )

Instance Attribute Summary collapse

Attributes inherited from Base

#api_name, #api_path, #created_at, #id, #updated_at

Class Method Summary collapse

Methods inherited from Base

api_name, api_path, #set_properties_from_xml_node

Instance Attribute Details

#budgetObject

Returns the value of attribute budget.



4
5
6
# File 'lib/tick/project.rb', line 4

def budget
  @budget
end

#client_idObject

Returns the value of attribute client_id.



4
5
6
# File 'lib/tick/project.rb', line 4

def client_id
  @client_id
end

#client_nameObject

Returns the value of attribute client_name.



4
5
6
# File 'lib/tick/project.rb', line 4

def client_name
  @client_name
end

#closed_onObject

Returns the value of attribute closed_on.



4
5
6
# File 'lib/tick/project.rb', line 4

def closed_on
  @closed_on
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/tick/project.rb', line 4

def name
  @name
end

#opened_onObject

Returns the value of attribute opened_on.



4
5
6
# File 'lib/tick/project.rb', line 4

def opened_on
  @opened_on
end

#owner_idObject

Returns the value of attribute owner_id.



4
5
6
# File 'lib/tick/project.rb', line 4

def owner_id
  @owner_id
end

#sum_hoursObject

Returns the value of attribute sum_hours.



4
5
6
# File 'lib/tick/project.rb', line 4

def sum_hours
  @sum_hours
end

#tasksObject

Returns the value of attribute tasks.



4
5
6
# File 'lib/tick/project.rb', line 4

def tasks
  @tasks
end

#user_countObject

Returns the value of attribute user_count.



4
5
6
# File 'lib/tick/project.rb', line 4

def user_count
  @user_count
end

Class Method Details

.list(options = {}, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/tick/project.rb', line 11

def self.list(options={}, &block)
  url = "https://#{current_session.company}.tickspot.com/api/projects"
  
  params = authentication_params.merge!(options)
  
  request_manager.GET(url, parameters:params, success:lambda{|operation, result|
    projects = []
    
    # Parse XML
    error = Pointer.new(:object)
    xml = GDataXMLDocument.alloc.initWithXMLString(result.to_s, error:error)
    
    # Create the project objects
    error = Pointer.new(:object)
    project_nodes = xml.nodesForXPath("//project", error:error)
    
    project_nodes.each do |project_node|
      project = new
      project.set_properties_from_xml_node(project_node)
      project.tasks = get_tasks_from_xml_node(project_node)
      project.tasks.each do |task|
        task.project = project
      end
      projects << project
    end
    
    block.call(projects) if block
  }, failure:lambda{|operation, error|
    block.call(error) if block
  })
  
  self
end