Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Updates as mentioned in Issue #34 for viewpoint. #35

Merged
merged 2 commits into from

2 participants

@heiko-xencon

Here you go.

@zenchild
Owner

Thanks, I'll have a look and if everything tests out well I'll hopefully have the changes merged this week some time.

@zenchild zenchild merged commit 7462ea0 into from
@zenchild
Owner

Everything checked out good. Thanks for the fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 3 deletions.
  1. +12 −2 lib/model/generic_folder.rb
  2. +2 −1  lib/model/item.rb
View
14 lib/model/generic_folder.rb
@@ -249,6 +249,7 @@ def get_events
def find_items(opts = {})
opts = opts.clone # clone the passed in object so we don't modify it in case it's being used in a loop
item_shape = opts.has_key?(:item_shape) ? opts.delete(:item_shape) : {:base_shape => 'Default'}
+ shallow = item_shape[:base_shape] != 'AllProperties'
unless item_shape.has_key?(:additional_properties) # Don't overwrite if specified by caller
item_shape[:additional_properties] = {:field_uRI => ['item:ParentFolderId']}
end
@@ -258,7 +259,7 @@ def find_items(opts = {})
items = []
resp.items.each do |i|
i_type = i.keys.first
- items << (eval "#{i_type.to_s.camel_case}.new(i[i_type])")
+ items << (eval "#{i_type.to_s.camel_case}.new(i[i_type], :shallow => #{shallow})")
end
return items
else
@@ -383,6 +384,7 @@ def get_items(item_ids, change_key = nil, options={})
# See: http://msdn.microsoft.com/en-us/library/aa565609.aspx
def sync_items!(sync_amount = 256, sync_all = false, opts = {})
item_shape = opts.has_key?(:item_shape) ? opts.delete(:item_shape) : {:base_shape => 'Default'}
+ shallow = item_shape[:base_shape] != 'AllProperties'
resp = (Viewpoint::EWS::EWS.instance).ews.sync_folder_items(@folder_id, @sync_state, sync_amount, item_shape)
parms = resp.items.shift
@sync_state = parms[:sync_state]
@@ -395,12 +397,20 @@ def sync_items!(sync_amount = 256, sync_all = false, opts = {})
items[key] << i[key][:item_id]
else
i_type = i[key].keys.first
- items[key] << (eval "#{i_type.to_s.camel_case}.new(i[key][i_type])")
+ next if !i_type
+ items[key] << (eval "#{i_type.to_s.camel_case}.new(i[key][i_type], :shallow => #{shallow})")
end
end
items
end
+ # Fetch current synced state (comes from synchronizing elements).
+ # @return [Boolean] Current synchronization state, i.e. whether sync_items! needs to be called
+ # again to finish the pending rounds of synchronization requests.
+ def synced
+ @synced
+ end
+
# This is basically a work-around for Microsoft's BPOS hosted Exchange, which does not support
# subscriptions at the time of this writing. This is the best way I could think of to get
# items from a specific period of time and track changes.
View
3  lib/model/item.rb
@@ -33,11 +33,12 @@ class Item
# @todo Add support to fetch an item with a ChangeKey
def self.get_item(item_id, shape = :default)
item_shape = {:base_shape => shape.to_s.camelcase}
+ shallow = item_shape[:base_shape] != 'AllProperties'
resp = (Viewpoint::EWS::EWS.instance).ews.get_item([item_id], item_shape)
if(resp.status == 'Success')
item = resp.items.shift
type = item.keys.first
- eval "#{type.to_s.camel_case}.new(item[type])"
+ eval "#{type.to_s.camel_case}.new(item[type], :shallow => #{shallow})"
else
raise EwsError, "Could not retrieve item. #{resp.code}: #{resp.message}"
end
Something went wrong with that request. Please try again.