Class: Viewpoint::EWS::Types::CalendarItem
- Inherits:
-
Object
- Object
- Viewpoint::EWS::Types::CalendarItem
- Includes:
- Viewpoint::EWS, Viewpoint::EWS::Types, Item, StringUtils
- Defined in:
- lib/ews/types/calendar_item.rb
Constant Summary collapse
- CALENDAR_ITEM_KEY_PATHS =
{ recurring?: [:is_recurring, :text], meeting?: [:is_meeting, :text], cancelled?: [:is_cancelled, :text], duration: [:duration, :text], time_zone: [:time_zone, :text], start: [:start, :text], end: [:end, :text], location: [:location, :text], all_day?: [:is_all_day_event, :text], legacy_free_busy_status: [:legacy_free_busy_status, :text], my_response_type: [:my_response_type, :text], organizer: [:organizer, :elems, 0, :mailbox, :elems], optional_attendees: [:optional_attendees, :elems ], required_attendees: [:required_attendees, :elems ], recurrence: [:recurrence, :elems ], deleted_occurrences: [:deleted_occurrences, :elems ], modified_occurrences: [:modified_occurrences, :elems ] }
- CALENDAR_ITEM_KEY_TYPES =
{ start: ->(str){DateTime.parse(str)}, end: ->(str){DateTime.parse(str)}, recurring?: ->(str){str.downcase == 'true'}, meeting?: ->(str){str.downcase == 'true'}, cancelled?: ->(str){str.downcase == 'true'}, all_day?: ->(str){str.downcase == 'true'}, organizer: :build_mailbox_user, optional_attendees: :build_attendees_users, required_attendees: :build_attendees_users, deleted_occurrences: :build_deleted_occurrences, modified_occurrences: :build_modified_occurrences }
- CALENDAR_ITEM_KEY_ALIAS =
{}
Constants included from StringUtils
Constants included from Item
Item::ITEM_KEY_ALIAS, Item::ITEM_KEY_PATHS, Item::ITEM_KEY_TYPES
Constants included from ItemFieldUriMap
Constants included from Viewpoint::EWS::Types
KEY_ALIAS, KEY_PATHS, KEY_TYPES, OOF_KEY_ALIAS, OOF_KEY_PATHS, OOF_KEY_TYPES
Constants included from Viewpoint::EWS
Instance Attribute Summary
Attributes included from Item
Attributes included from Viewpoint::EWS::Types
Attributes included from Viewpoint::EWS
Instance Method Summary collapse
-
#delete!(deltype = :hard, cancel_type = 'SendOnlyToAll', opts = {}) ⇒ Boolean
Delete this calendar item.
- #duration_in_seconds ⇒ Object
-
#update_item!(updates, options = {}) ⇒ CalendarItem, false
Updates the specified item attributes.
Methods included from StringUtils
Methods included from Item
#add_file_attachment, #add_inline_attachment, #add_item_attachment, #copy, #default_body_type=, #forward, #get_all_properties!, included, #initialize, #mark_read!, #mark_unread!, #move!, #recycle!, #reply_to, #reply_to_all, #submit!, #submit_attachments!
Methods included from Viewpoint::EWS::Types
#auto_deepen?, #deepen!, #ews_methods, #freeze!, #frozen?, #initialize, #mark_deep!, #method_missing, #methods, #respond_to?, #shallow?, #to_s, #unfreeze!
Methods included from Viewpoint::EWS
#remove_impersonation, root_logger, #set_impersonation
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Viewpoint::EWS::Types
Instance Method Details
#delete!(deltype = :hard, cancel_type = 'SendOnlyToAll', opts = {}) ⇒ Boolean
Delete this calendar item
50 51 52 53 |
# File 'lib/ews/types/calendar_item.rb', line 50 def delete!(deltype = :hard, cancel_type = 'SendOnlyToAll', opts = {}) opts = opts.merge(:send_meeting_cancellations => cancel_type) super(deltype, opts) end |
#duration_in_seconds ⇒ Object
124 125 126 |
# File 'lib/ews/types/calendar_item.rb', line 124 def duration_in_seconds iso8601_duration_to_seconds(duration) end |
#update_item!(updates, options = {}) ⇒ CalendarItem, false
AppendToItemField updates not implemented
Updates the specified item attributes
Uses ‘SetItemField` if value is present and `DeleteItemField` if value is nil
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ews/types/calendar_item.rb', line 69 def update_item!(updates, = {}) item_updates = [] updates.each do |attribute, value| item_field = FIELD_URIS[attribute][:text] if FIELD_URIS.include? attribute field = {field_uRI: {field_uRI: item_field}} if value.nil? && item_field # Build DeleteItemField Change item_updates << {delete_item_field: field} elsif item_field # Build SetItemField Change item = Viewpoint::EWS::Template::CalendarItem.new(attribute => value) # Remap attributes because ews_builder #dispatch_field_item! uses #build_xml! item_attributes = item.to_ews_item.map do |name, value| if value.is_a? String {name => {text: value}} elsif value.is_a? Hash node = {name => {}} value.each do |attrib_key, attrib_value| attrib_key = camel_case(attrib_key) unless attrib_key == :text node[name][attrib_key] = attrib_value end node else {name => value} end end item_updates << {set_item_field: field.merge(calendar_item: {sub_elements: item_attributes})} else # Ignore unknown attribute end end if item_updates.any? data = {} data[:conflict_resolution] = [:conflict_resolution] || 'AutoResolve' data[:send_meeting_invitations_or_cancellations] = [:send_meeting_invitations_or_cancellations] || 'SendToNone' data[:item_changes] = [{item_id: self.item_id, updates: item_updates}] rm = ews.update_item(data)..first if rm && rm.success? self.get_all_properties! self else if rm raise EwsCreateItemError, "Could not update calendar item. #{rm.code}: #{rm.}" else raise EwsCreateItemError, "Could not update calendar item." end end end end |