viewpoint 0.1.22 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,8 +104,8 @@ module Viewpoint
104
104
  end
105
105
 
106
106
  # Initialize an Exchange Web Services item of type CalendarItem
107
- def initialize(ews_item)
108
- super(ews_item)
107
+ def initialize(ews_item, opts={})
108
+ super(ews_item, opts)
109
109
  end
110
110
 
111
111
  # Add attendees to this CalendarItem. This does not commit the changes so you will have to use #save! to
data/lib/model/contact.rb CHANGED
@@ -75,8 +75,8 @@ module Viewpoint
75
75
  end
76
76
 
77
77
  # Initialize an Exchange Web Services item of type Contact
78
- def initialize(ews_item)
79
- super(ews_item)
78
+ def initialize(ews_item, opts={})
79
+ super(ews_item, opts)
80
80
  end
81
81
 
82
82
  def set_email_addresses(email1, email2=nil, email3=nil)
data/lib/model/event.rb CHANGED
@@ -25,7 +25,7 @@ module Viewpoint
25
25
  attr_reader :subject, :organizer, :location, :start, :end, :cal_item_type
26
26
 
27
27
  # Initialize an Exchange Web Services item
28
- def initialize(ews_item, parent_folder)
28
+ def initialize(ews_item, parent_folder, opts={})
29
29
  raise InvalidEWSItemError if ews_item.nil?
30
30
 
31
31
  @subject = ews_item.subject # String
@@ -42,7 +42,7 @@ module Viewpoint
42
42
  # body when the message is viewed.
43
43
  @message = nil
44
44
 
45
- super(ews_item, parent_folder)
45
+ super(ews_item, opts)
46
46
  end
47
47
 
48
48
 
@@ -217,7 +217,9 @@ module Viewpoint
217
217
  def find_items(opts = {})
218
218
  opts = opts.clone # clone the passed in object so we don't modify it in case it's being used in a loop
219
219
  item_shape = opts.has_key?(:item_shape) ? opts.delete(:item_shape) : {:base_shape => 'Default'}
220
- item_shape[:additional_properties] = {:field_uRI => ['item:ParentFolderId']}
220
+ unless item_shape.has_key?(:additional_properties) # Don't overwrite if specified by caller
221
+ item_shape[:additional_properties] = {:field_uRI => ['item:ParentFolderId']}
222
+ end
221
223
  resp = (Viewpoint::EWS::EWS.instance).ews.find_item([@folder_id], 'Shallow', item_shape, opts)
222
224
  if(resp.status == 'Success')
223
225
  parms = resp.items.shift
@@ -312,6 +314,29 @@ module Viewpoint
312
314
  end
313
315
  end
314
316
 
317
+ # Get Items
318
+ # @param [String] item_ids is an array of Item IDs to fetch
319
+ # @param [String] change_key specify an optional change_key if you want to
320
+ # make sure you are fetching a specific version of the object.
321
+ # @param [String] options specify an optional options hash. Supports the
322
+ # key :item_shape that expects a hash value with :base_shape and other
323
+ # optional parameters that specify the desired fields to return.
324
+ def get_items(item_ids, change_key = nil, options={})
325
+ item_shape = options[:item_shape] ||
326
+ {:base_shape => 'Default', :additional_properties => {:field_uRI => ['item:ParentFolderId']}}
327
+ shallow = item_shape[:base_shape] != 'AllProperties'
328
+ resp = (Viewpoint::EWS::EWS.instance).ews.get_item(item_ids, item_shape)
329
+ if(resp.status == 'Success')
330
+ resp.items.map do |item|
331
+ type = item.keys.first
332
+ eval "#{type.to_s.camel_case}.new(item[type], :shallow => #{shallow})"
333
+ end
334
+ else
335
+ raise EwsError, "Could not retrieve items. #{resp.code}: #{resp.message}"
336
+ end
337
+ end
338
+
339
+
315
340
  # Syncronize Items in this folder. If this method is issued multiple
316
341
  # times it will continue where the last sync completed.
317
342
  # @param [Integer] sync_amount The number of items to synchronize per sync
data/lib/model/item.rb CHANGED
@@ -62,16 +62,16 @@ module Viewpoint
62
62
  {:id => resp.items.first[:attachment_id][:root_item_id], :change_key => resp.items.first[:attachment_id][:root_item_change_key]}
63
63
  end
64
64
 
65
- attr_reader :item_id, :change_key
65
+ attr_reader :item_id, :change_key, :parent_folder_id
66
66
  alias :id :item_id
67
67
 
68
68
  # Initialize an Exchange Web Services item
69
69
  # @param [Hash] ews_item A hash representing this item
70
70
  # @param [Boolean] shallow Whether or not we have retrieved all the elements for this object
71
- def initialize(ews_item, shallow = true)
71
+ def initialize(ews_item, opts={})
72
72
  super() # Calls initialize in Model (creates @ews_methods Array)
73
73
  @ews_item = ews_item
74
- @shallow = shallow
74
+ @shallow = opts.has_key?(:shallow) ? opts[:shallow] : true
75
75
  @item_id = ews_item[:item_id][:id]
76
76
  @change_key = ews_item[:item_id][:change_key]
77
77
  @text_only = false
@@ -22,8 +22,8 @@ module Viewpoint
22
22
  module EWS
23
23
  class MeetingMessage < Item
24
24
 
25
- def initialize(ews_item)
26
- super(ews_item)
25
+ def initialize(ews_item, opts={})
26
+ super(ews_item, opts)
27
27
  end
28
28
  end # MeetingMessage
29
29
  end # EWS
data/lib/model/message.rb CHANGED
@@ -65,8 +65,8 @@ module Viewpoint
65
65
  end
66
66
 
67
67
  # Initialize an Exchange Web Services item of type Message
68
- def initialize(ews_item)
69
- super(ews_item)
68
+ def initialize(ews_item, opts={})
69
+ super(ews_item, opts)
70
70
  end
71
71
 
72
72
  def headers
data/lib/model/task.rb CHANGED
@@ -73,8 +73,8 @@ module Viewpoint
73
73
 
74
74
 
75
75
  # Initialize an Exchange Web Services item of type Task
76
- def initialize(ews_item)
77
- super(ews_item)
76
+ def initialize(ews_item, opts={})
77
+ super(ews_item, opts)
78
78
  end
79
79
 
80
80
  # Delete this item
@@ -769,6 +769,7 @@ module Viewpoint
769
769
 
770
770
  def parse!(response, opts = {})
771
771
  return response if @@raw_soap
772
+ raise EwsError, "Can't parse an empty response. Please check your endpoint." if(response.nil?)
772
773
  EwsParser.new(response).parse(opts)
773
774
  end
774
775
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: viewpoint
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.22
5
+ version: 0.1.23
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dan Wanek
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-04 00:00:00 -05:00
13
+ date: 2011-04-27 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency