Class: Aspose::Cloud::Tasks::Assignments

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/assignments.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Assignments

Returns a new instance of Assignments.



5
6
7
8
9
# File 'lib/tasks/assignments.rb', line 5

def initialize(filename)
  @filename = filename
  raise 'filename not specified.' if filename.empty?
  @base_uri =  Aspose::Cloud::Common::Product.product_uri + '/tasks/' + @filename
end

Instance Method Details

#add_assignment(task_id, resource_id, units, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Add Assignment to Project

@param number task_id The unique id of the task to be assigned.
@param number resource_id The unique id of the resource to be assigned. 
@param number units The units for the new assignment.


40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/tasks/assignments.rb', line 40

def add_assignment(task_id, resource_id, units, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'task_id not specified.' if task_id.nil?
  raise 'resource_id not specified.' if resource_id.nil?
  raise 'units not specified.' if units.nil?

  str_uri = "#{@base_uri}/assignments"
  qry = { :taskUid => task_id, :resourceUid => resource_id, :units => units }
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)

  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  JSON.parse(RestClient.post(signed_str_uri, '', {:accept=>'application/json'}))['AssignmentItem']
end

#delete_assignment(assignment_id, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Delete an Assignment from a Project

@param number assignment_id The id of the assignment.


59
60
61
62
63
64
65
66
67
# File 'lib/tasks/assignments.rb', line 59

def delete_assignment(assignment_id, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'assignment_id not specified.' if assignment_id.nil?

  str_uri = "#{@base_uri}/assignments/#{assignment_id}"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  json = JSON.parse(RestClient.delete(signed_str_uri, {:accept=>'application/json'}))
  json['Code'] == 200 ? true : false
end

#get_assignment(assignment_id, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Get a Particular Assignment form Project

@param number assignment_id The id of the assignment.


25
26
27
28
29
30
31
32
# File 'lib/tasks/assignments.rb', line 25

def get_assignment(assignment_id, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'assignment_id not specified.' if assignment_id.nil?

  str_uri = "#{@base_uri}/assignments/#{assignment_id}"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Assignment']
end

#get_assignments(folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Get all Assignments form Project



14
15
16
17
18
19
# File 'lib/tasks/assignments.rb', line 14

def get_assignments(folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/assignments"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Assignments']['AssignmentItem']
end