lib/ews/types/generic_folder.rb
def sync_items!(sync_state = nil, sync_amount = 256, sync_all = false, opts = {})
      item_shape = opts.has_key?(:item_shape) ? opts.delete(:item_shape) : {:base_shape => :default}
      sync_state ||= @sync_state

      resp = ews.sync_folder_items item_shape: item_shape,
        sync_folder_id: self.folder_id, max_changes_returned: sync_amount, sync_state: sync_state
      rmsg = resp.response_messages[0]

      if rmsg.success?
        @synced = rmsg.includes_last_item_in_range?
        @sync_state = rmsg.sync_state
        rhash = {}
        rmsg.changes.each do |c|
          ctype = c.keys.first
          rhash[ctype] = [] unless rhash.has_key?(ctype)
          if ctype == :delete || ctype == :read_flag_change
            rhash[ctype] << c[ctype][:elems][0][:item_id][:attribs]
          else
            type = c[ctype][:elems][0].keys.first
            item = class_by_name(type).new(ews, c[ctype][:elems][0][type])
            rhash[ctype] << item
          end
        end
        rhash
      else
        raise EwsError, "Could not synchronize: #{rmsg.code}: #{rmsg.message_text}"
      end
    end
def sync_items!(sync_state = nil, sync_amount = 256, sync_all = false, opts = {})
      item_shape = opts.has_key?(:item_shape) ? opts.delete(:item_shape) : {:base_shape => :default}
      sync_state ||= @sync_state

      resp = ews.sync_folder_items item_shape: item_shape,
        sync_folder_id: self.folder_id, max_changes_returned: sync_amount, sync_state: sync_state
      rmsg = resp.response_messages[0]

      if rmsg.success?
        @synced = rmsg.includes_last_item_in_range?
        @sync_state = rmsg.sync_state
        rhash = {}
        rmsg.changes.each do |c|
          ctype = c.keys.first
          rhash[ctype] = [] unless rhash.has_key?(ctype)
          if ctype == :delete || ctype == :read_flag_change
            rhash[ctype] << c[ctype][:elems][0][:item_id][:attribs]
          else
            type = c[ctype][:elems][0].keys.first
            item = class_by_name(type).new(ews, c[ctype][:elems][0][type])
            rhash[ctype] << item
          end
        end
        rhash
      else
        raise EwsError, "Could not synchronize: #{rmsg.code}: #{rmsg.message_text}"
      end
    end
Syncronize Items in this folder. If this method is issued multiple
 times it will continue where the last sync completed.
 @param [Integer] sync_amount The number of items to synchronize per sync
 @param [Boolean] sync_all Whether to sync all the data by looping through.
   The default is to just sync the first set.  You can manually loop through
   with multiple calls to #sync_items!
 @return [Hash] Returns a hash with keys for each change type that ocurred.
   Possible key values are:
     (:create/:udpate/:delete/:read_flag_change).
   For :deleted and :read_flag_change items a simple hash with :id and
   :change_key is returned.
   See: http://msdn.microsoft.com/en-us/library/aa565609.aspx