lib/ews/types/calendar_item.rb
# Updates the specified item attributes
#
# Uses `SetItemField` if value is present and `DeleteItemField` if value is nil
# @param updates [Hash] with (:attribute => value)
# @param options [Hash]
# @option options :conflict_resolution [String] one of 'NeverOverwrite', 'AutoResolve' (default) or 'AlwaysOverwrite'
# @option options :send_meeting_invitations_or_cancellations [String] one of 'SendToNone' (default), 'SendOnlyToAll',
#   'SendOnlyToChanged', 'SendToAllAndSaveCopy' or 'SendToChangedAndSaveCopy'
# @return [CalendarItem, false]
# @example Update Subject and Body
#   item = #...
#   item.update_item!(subject: 'New subject', body: 'New Body')
# @see http://msdn.microsoft.com/en-us/library/exchange/aa580254.aspx
# @todo AppendToItemField updates not implemented
Updates the specified item attributes
Uses `SetItemField` if value is present and `DeleteItemField` if value is nil
Updates the specified item attributes Uses ` SetItemField ` if value is present and ` DeleteItemField ` if value is nil
def update_item!(updates, options = {})
      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
          item_updates << {delete_item_field: field}
        elsif item_field
          item = Viewpoint::EWS::Template::CalendarItem.new(attribute => value)
          item_attributes = item.to_ews_item.map do |name, value|
            case value
            when String
              {name => {text: value}}
            when Hash
              {name => Viewpoint::EWS::SOAP::EwsBuilder.camel_case_attributes(value)}
            else
              {name => value}
            end
          end
          item_updates << {set_item_field: field.merge(calendar_item: {sub_elements: item_attributes})}
        else
        end
      end
      if item_updates.any?
        data = {}
        data[:conflict_resolution] = options[:conflict_resolution] || 'AutoResolve'
        data[:send_meeting_invitations_or_cancellations] = options[:send_meeting_invitations_or_cancellations] || 'SendToNone'
        data[:item_changes] = [{item_id: self.item_id, updates: item_updates}]
        rm = ews.update_item(data).response_messages.first
        if rm && rm.success?
          self.get_all_properties!
          self
        else
          raise EwsCreateItemError, "Could not update calendar item. #{rm.code}: #{rm.message_text}" unless rm
        end
      end
    end
def update_item! ( updates , options = { } ) 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 item_updates << { delete_item_field : field } elsif item_field item = Viewpoint :: EWS :: Template :: CalendarItem . new ( attribute => value ) item_attributes = item . to_ews_item . map do | name , value | case value when String { name => { text : value } } when Hash { name => Viewpoint :: EWS :: SOAP :: EwsBuilder . camel_case_attributes ( value ) } else { name => value } end end item_updates << { set_item_field : field . merge ( calendar_item : { sub_elements : item_attributes } ) } else end end if item_updates . any? data = { } data [ :conflict_resolution ] = options [ :conflict_resolution ] || 'AutoResolve' data [ :send_meeting_invitations_or_cancellations ] = options [ :send_meeting_invitations_or_cancellations ] || 'SendToNone' data [ :item_changes ] = [ { item_id : self . item_id , updates : item_updates } ] rm = ews . update_item ( data ) . response_messages . first if rm && rm . success? self . get_all_properties! self else raise EwsCreateItemError , "Could not update calendar item. #{rm.code}: #{rm.message_text}" unless rm end end end
Updates the specified item attributes
Uses `SetItemField` if value is present and `DeleteItemField` if value is nil
Updates the specified item attributes Uses ` SetItemField ` if value is present and ` DeleteItemField ` if value is nil
# Build DeleteItemField Change # Build SetItemField Change # Remap attributes because ews_builder #dispatch_field_item! uses #build_xml! # Ignore unknown attribute
None
CalendarItem, false
updates
with (:attribute => value)
with ( : attribute = > value )
options
:send_meeting_invitations_or_cancellations  one of 'SendToNone' (default), 'SendOnlyToAll', 'SendOnlyToChanged', 'SendToAllAndSaveCopy' or 'SendToChangedAndSaveCopy'
: send_meeting_invitations_or_cancellations one of ' SendToNone ' ( default ) ' SendOnlyToAll ' ' SendOnlyToChanged ' ' SendToAllAndSaveCopy ' or ' SendToChangedAndSaveCopy '
<not_specific>
None
example
Update Subject and Body item = #... item.update_item!(subject: 'New subject', body: 'New Body')
Update Subject and Body item = # ... item . update_item! ( subject : ' New subject ' body : ' New Body ' )
see
None
todo
AppendToItemField updates not implemented
AppendToItemField updates not implemented