Class: SysAid::Task

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTask

Returns a new instance of Task.



9
10
11
12
# File 'lib/sysaid/task.rb', line 9

def initialize
  self.start_time = Date.new
  self.end_time = Date.new
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def category
  @category
end

#ciidObject

Returns the value of attribute ciid.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def ciid
  @ciid
end

#cust_date1Object

Returns the value of attribute cust_date1.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def cust_date1
  @cust_date1
end

#cust_date2Object

Returns the value of attribute cust_date2.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def cust_date2
  @cust_date2
end

#cust_int1Object

Returns the value of attribute cust_int1.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def cust_int1
  @cust_int1
end

#cust_int2Object

Returns the value of attribute cust_int2.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def cust_int2
  @cust_int2
end

#cust_list1Object

Returns the value of attribute cust_list1.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def cust_list1
  @cust_list1
end

#cust_list2Object

Returns the value of attribute cust_list2.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def cust_list2
  @cust_list2
end

#cust_notesObject

Returns the value of attribute cust_notes.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def cust_notes
  @cust_notes
end

#cust_text1Object

Returns the value of attribute cust_text1.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def cust_text1
  @cust_text1
end

#cust_text2Object

Returns the value of attribute cust_text2.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def cust_text2
  @cust_text2
end

#custom_date_fieldsObject

Returns the value of attribute custom_date_fields.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def custom_date_fields
  @custom_date_fields
end

#custom_fieldsObject

Returns the value of attribute custom_fields.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def custom_fields
  @custom_fields
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def description
  @description
end

#end_timeObject

Returns the value of attribute end_time.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def end_time
  @end_time
end

#estimationObject

Returns the value of attribute estimation.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def estimation
  @estimation
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def id
  @id
end

#notesObject

Returns the value of attribute notes.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def notes
  @notes
end

#progressObject

Returns the value of attribute progress.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def progress
  @progress
end

#project_idObject

Returns the value of attribute project_id.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def project_id
  @project_id
end

#start_timeObject

Returns the value of attribute start_time.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def start_time
  @start_time
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def status
  @status
end

#task_dependencyObject

Returns the value of attribute task_dependency.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def task_dependency
  @task_dependency
end

#task_dependency_typeObject

Returns the value of attribute task_dependency_type.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def task_dependency_type
  @task_dependency_type
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def title
  @title
end

#versionObject

Returns the value of attribute version.



4
5
6
# File 'lib/sysaid/task.rb', line 4

def version
  @version
end

Class Method Details

.find_by_id(task_id) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/sysaid/task.rb', line 14

def self.find_by_id(task_id)
  task = SysAid::Task.new

  task.id = task_id

  return nil unless task.refresh

  return task
end

.find_by_project_id(project_id) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sysaid/task.rb', line 24

def self.find_by_project_id(project_id)
  SysAid.ensure_logged_in

  response = SysAid.call(:execute_select_query, message: sql_query(project_id))

  if response.to_hash[:execute_select_query_response][:return]
    return response.to_hash[:execute_select_query_response][:return]
  end

  return false
end

Instance Method Details

#deleteObject

Deletes a task from the SysAid server

No return value as SysAid’s ‘delete’ call returns void. No idea why.

Example:

>> task_object.delete
=> true


74
75
76
77
78
# File 'lib/sysaid/task.rb', line 74

def delete
  SysAid.ensure_logged_in
  
  SysAid.call(:delete, message: to_xml(false))
end

#refreshObject

Loads the latest task information from the SysAid server



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/sysaid/task.rb', line 37

def refresh
  SysAid.ensure_logged_in

  response = SysAid.call(:load_by_string_id, message: to_xml)

  if response.to_hash[:load_by_string_id_response][:return]
    set_self_from_response(response.to_hash[:load_by_string_id_response][:return])
    return true
  end

  return false
end

#saveObject

Saves a task back to the SysAid server

Example:

>> task_object.save
=> true


55
56
57
58
59
60
61
62
63
64
65
# File 'lib/sysaid/task.rb', line 55

def save
  SysAid.ensure_logged_in

  # Save it via the SOAP API
  response = SysAid.call(:save, message: to_xml(false))
  if response.to_hash[:save_response][:return]
    return true
  else
    return false
  end
end