Class: Aspose::Cloud::Tasks::Calendar

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

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Calendar

Returns a new instance of Calendar.



5
6
7
8
9
# File 'lib/tasks/calendar.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_calendar(json_data, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Add Calendar to Project

@param json json_data Provide data in json format.


38
39
40
41
42
43
44
45
46
# File 'lib/tasks/calendar.rb', line 38

def add_calendar(json_data, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'json_data not specified.' if json_data.empty?

  str_uri = "#{@base_uri}/calendars"
  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(Aspose::Cloud::Common::Utils.process_command(signed_str_uri,'POST','JSON',json_data))
  json['Status'] == 'Created' ? json['CalendarItem'] : nil
end

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

Delete a Calendar from Project

@param number calendar_id The id of the calendar.


52
53
54
55
56
57
58
59
60
# File 'lib/tasks/calendar.rb', line 52

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

  str_uri = "#{@base_uri}/calendars/#{calendar_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_calendar(calendar_id, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Get a Particular Calendar form Project

@param number calendar_id The id of the calendar.


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

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

  str_uri = "#{@base_uri}/calendars/#{calendar_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'}))['Calendar']
end

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

Get all Calendars form Project



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

def get_calendars(folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/calendars"
  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'}))['Calendars']['List']
end