viewpoint 0.1.6 → 0.1.7

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.
@@ -1,3 +1,57 @@
1
+ commit 002a3562533991ff27270c6d44e2c055b63fc9d8
2
+ Author: Dan Wanek <dan.wanek@gmail.com>
3
+ Date: Sun Nov 14 20:17:47 2010 -0600
4
+
5
+ changed Message.send back to returning true on success
6
+
7
+ commit b756a46c4f9fc7ec54b0f954fd23b9ffa20e47a2
8
+ Author: Dan Wanek <dan.wanek@gmail.com>
9
+ Date: Sun Nov 14 10:53:21 2010 -0600
10
+
11
+ Added BPOS work-around GenericFolder#sync_items_sync!
12
+ Added a way to clear out synchornization GenericFolder#clear_sync_state!
13
+ Added additional tests for new methods
14
+
15
+ commit bfa1569fbeb9b7af81f0ebe84408dc376891e416
16
+ Author: Dan Wanek <dan.wanek@gmail.com>
17
+ Date: Wed Nov 10 11:13:59 2010 -0600
18
+
19
+ Added ability to mark/unmark an Item read Item#mark_read!, Item#mark_unread!
20
+
21
+ commit 40299edf5013e05427900bccea9d64db41b17942
22
+ Author: Dan Wanek <dan.wanek@gmail.com>
23
+ Date: Wed Nov 10 10:09:15 2010 -0600
24
+
25
+ Added properties to ItemShape for get_item so that you can request
26
+ :body_type of Text only.
27
+ Added EWS init methods to meeting request
28
+
29
+ commit 3c73c2556f6c4cdd33601eed90ab8815201e476d
30
+ Author: Dan Wanek <dan.wanek@gmail.com>
31
+ Date: Fri Nov 5 14:13:55 2010 -0500
32
+
33
+ version up for hash insertion bugs
34
+
35
+ commit ecac0e11754a436248688aca17c33bb1b2c4aaed
36
+ Author: Dan Wanek <dan.wanek@gmail.com>
37
+ Date: Fri Nov 5 13:47:57 2010 -0500
38
+
39
+ version 0.1.5b
40
+
41
+ commit d9bc83a83c83d832eb30b6e3f309c80e4e36350a
42
+ Author: Dan Wanek <dan.wanek@gmail.com>
43
+ Date: Fri Nov 5 13:44:20 2010 -0500
44
+
45
+ Fixed issue with GenericFolder#items_since and #items_between for
46
+ versions of Ruby less than 1.8.7. It had to do with insertion order
47
+ of Hashes.
48
+
49
+ commit bf5426fec4862020b5186caf15d77550f00649ab
50
+ Author: Dan Wanek <dan.wanek@gmail.com>
51
+ Date: Fri Nov 5 12:05:28 2010 -0500
52
+
53
+ version 0.1.5
54
+
1
55
  commit 62dbad34702f88505a846a6e9da730ab4c69ae2c
2
56
  Author: Dan Wanek <dan.wanek@gmail.com>
3
57
  Date: Fri Nov 5 11:47:50 2010 -0500
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7
@@ -104,8 +104,8 @@ module Viewpoint
104
104
  end
105
105
  end
106
106
 
107
- attr_accessor :folder_id, :change_key, :parent_id
108
- attr_reader :subscription_id, :watermark, :sync_state
107
+ attr_accessor :folder_id, :change_key, :parent_id, :sync_state
108
+ attr_reader :subscription_id, :watermark
109
109
  alias :id :folder_id
110
110
 
111
111
  def initialize(ews_item)
@@ -313,6 +313,30 @@ module Viewpoint
313
313
  items
314
314
  end
315
315
 
316
+ # This is basically a work-around for Microsoft's BPOS hosted Exchange, which does not support
317
+ # subscriptions at the time of this writing. This is the best way I could think of to get
318
+ # items from a specific period of time and track changes.
319
+ # !! Before using this method I would suggest trying a GenericFolder#items_since then using
320
+ # a subscription to track changes.
321
+ # This method should be followed by subsequent calls to GenericFolder#sync_items! to fetch
322
+ # additional items. Calling this method again will clear the sync_state and synchronize
323
+ # everything again.
324
+ # @return [Array<Item>] returns an array of Items
325
+ def sync_items_since!(datetime)
326
+ clear_sync_state!
327
+
328
+ begin
329
+ items = sync_items!
330
+ end until items.empty?
331
+
332
+ items_since(datetime)
333
+ end
334
+
335
+ # Clears out the @sync_state so you can freshly synchronize this folder if needed
336
+ def clear_sync_state!
337
+ @sync_state = nil
338
+ end
339
+
316
340
  # Create a subfolder of this folder
317
341
  #
318
342
  # @param [String] name The name of the new folder
@@ -67,14 +67,51 @@ module Viewpoint
67
67
  @shallow = shallow
68
68
  @item_id = ews_item[:item_id][:id]
69
69
  @change_key = ews_item[:item_id][:change_key]
70
+ @text_only = false
70
71
 
71
72
  init_methods
72
73
  end
73
74
 
75
+
76
+ # See if this item is set to return only text in its body.
77
+ # @return [Boolean] if true the body will return only text, otherwise it may be HTML or text.
78
+ def text_only?
79
+ @text_only
80
+ end
81
+
82
+ # Set whether or not the body should be text-only or not
83
+ # @param [Boolean] txt if true the body will return only text, otherwise it may be HTML or text.
84
+ def text_only=(txt)
85
+ @text_only = ( txt == true ? true : false)
86
+ end
87
+
88
+ # Call UpdateItem for this item with the passed updates
89
+ # @param [Hash] updates a well-formed update hash
90
+ # @example {:updates=>{:set_item_field=>{:field_u_r_i=>{:field_u_r_i=>"message:IsRead"}, :message=>{:is_read=>{:text=>"true"}}}}}
91
+ def update!(updates)
92
+ conn = Viewpoint::EWS::EWS.instance
93
+ resp = conn.ews.update_item([{:id => @item_id, :change_key => @change_key}], updates)
94
+ (resp.status == 'Success') || (raise EwsError, "Trouble updating Item. #{resp.code}: #{resp.message}")
95
+ end
96
+
97
+ # Mark this Item as read
98
+ def mark_read!
99
+ update!({:updates=>{:set_item_field=>{:field_u_r_i=>{:field_u_r_i=>"message:IsRead"}, :message=>{:is_read=>{:text=>"true"}}}}})
100
+ @is_read = true
101
+ end
102
+
103
+ # Mark this Item as unread
104
+ def mark_unread!
105
+ update!({:updates=>{:set_item_field=>{:field_u_r_i=>{:field_u_r_i=>"message:IsRead"}, :message=>{:is_read=>{:text=>"false"}}}}})
106
+ @is_read = false
107
+ true
108
+ end
109
+
74
110
  def deepen!
75
111
  return true unless @shallow
76
112
  conn = Viewpoint::EWS::EWS.instance
77
- resp = conn.ews.get_item([@item_id], {:base_shape => 'AllProperties'})
113
+ shape = {:base_shape => 'AllProperties', :body_type => (@text_only ? 'Text' : 'Best')}
114
+ resp = conn.ews.get_item([@item_id], shape)
78
115
  resp = resp.items.shift
79
116
  @ews_item = resp[resp.keys.first]
80
117
  @shallow = false
@@ -198,7 +235,7 @@ module Viewpoint
198
235
  deepen!
199
236
  send(m, *args, &block)
200
237
  else
201
- warn "!!! No such method: #{m}"
238
+ warn "!!! No such method: #{m}" if $DEBUG
202
239
  nil
203
240
  end
204
241
  end
@@ -21,6 +21,21 @@
21
21
  module Viewpoint
22
22
  module EWS
23
23
  class MeetingRequest < Item
24
+
25
+
26
+ private
27
+
28
+ def init_methods
29
+ super()
30
+ define_str_var :conversation_index, :conversation_topic, :internet_message_id, :references
31
+ define_mbox_users :to_recipients, :cc_recipients, :bcc_recipients, :reply_to, :required_attendees, :optional_attendees
32
+ define_mbox_user :from, :sender, :received_by, :received_representing, :organizer
33
+ define_bool_var :is_read, :is_read_receipt_requested, :is_response_requested, :is_delivery_receipt_requested, :is_draft, :is_from_me
34
+ define_bool_var :is_all_day_event, :is_cancelled, :is_delegated, :is_meeting, :is_out_of_date, :is_recurring, :is_resend
35
+ define_bool_var :is_submitted, :is_unmodified, :allow_new_time_proposal
36
+ define_int_var :adjacent_meeting_count, :appointment_sequence_number, :appointment_state, :conflicting_meeting_count
37
+ define_datetime_var :start, :end
38
+ end
24
39
  end # MeetingRequest
25
40
  end # EWS
26
41
  end # Viewpoint
@@ -59,7 +59,6 @@ module Viewpoint
59
59
  if !draft
60
60
  resp = conn.ews.send_item([msg_id])
61
61
  (resp.status == 'Success') || (raise EwsError, "Could not send message. #{resp.code}: #{resp.message}")
62
- self.get_item(msg_id)
63
62
  else
64
63
  self.new({:item_id => msg_id})
65
64
  end
@@ -64,6 +64,16 @@ module Viewpoint
64
64
  end
65
65
  end
66
66
 
67
+ # Create the ItemChanges Element
68
+ def item_changes!(node, item_ids, changes)
69
+ node.add("#{NS_EWS_MESSAGES}:ItemChanges") do |chgs|
70
+ chgs.add("#{NS_EWS_TYPES}:ItemChange") do |chg|
71
+ item_id!(chg, item_ids.first)
72
+ add_hierarchy!(chg, changes)
73
+ end
74
+ end
75
+ end
76
+
67
77
  # Create the ItemIds Element
68
78
  # @param [Element] node The node we are adding Mailbox elements to.
69
79
  # @param [Array] item_ids The item ids to add in.
@@ -142,6 +152,10 @@ module Viewpoint
142
152
  def item_shape!(node, item_shape)
143
153
  node.add("#{NS_EWS_MESSAGES}:ItemShape") do |is|
144
154
  is.add("#{NS_EWS_TYPES}:BaseShape", item_shape[:base_shape])
155
+ is.add("#{NS_EWS_TYPES}:IncludeMimeContent", item_shape[:include_mime_content]) if item_shape.has_key?(:include_mime_content)
156
+ is.add("#{NS_EWS_TYPES}:BodyType", item_shape[:body_type]) if item_shape.has_key?(:body_type)
157
+ is.add("#{NS_EWS_TYPES}:FilterHtmlContent", item_shape[:filter_html_content]) if item_shape.has_key?(:filter_html_content)
158
+ is.add("#{NS_EWS_TYPES}:ConvertHtmlCodePageToUTF8", item_shape[:convert_html_code_page_to_utf8]) if item_shape.has_key?(:convert_html_code_page_to_utf8)
145
159
  end
146
160
 
147
161
  unless( item_shape[:additional_props].nil? )
@@ -408,8 +408,9 @@ module Viewpoint
408
408
  # @option item_shape :additional_properties
409
409
  # See: http://msdn.microsoft.com/en-us/library/aa563810.aspx
410
410
  # @param [Hash] opts optional parameters to this method
411
- def get_item(item_ids, item_shape = {:base_shape => 'Default'})
411
+ def get_item(item_ids, item_shape = {})
412
412
  action = "#{SOAP_ACTION_PREFIX}/GetItem"
413
+ item_shape[:base_shape] = 'Default' unless item_shape.has_key?(:base_shape)
413
414
  resp = invoke("#{NS_EWS_MESSAGES}:GetItem", action) do |root|
414
415
  build!(root) do
415
416
  item_shape!(root, item_shape)
@@ -523,14 +524,19 @@ module Viewpoint
523
524
  parse!(resp)
524
525
  end
525
526
 
526
- def update_item
527
+ # Used to modify the properties of an existing item in the Exchange store
528
+ # @see http://msdn.microsoft.com/en-us/library/aa581084.aspx
529
+ # @param [Array] item_ids An Array of item ids
530
+ def update_item(item_ids, changes)
527
531
  action = "#{SOAP_ACTION_PREFIX}/UpdateItem"
528
532
  resp = invoke("#{NS_EWS_MESSAGES}:UpdateItem", action) do |root|
529
533
  build!(root) do
534
+ root.set_attr('MessageDisposition', 'SaveOnly')
535
+ root.set_attr('ConflictResolution', 'AutoResolve')
536
+ item_changes!(root, item_ids, changes)
530
537
  end
531
538
  end
532
- resp
533
- #parse_update_item(resp)
539
+ parse!(resp)
534
540
  end
535
541
 
536
542
  # Used to send e-mail messages that are located in the Exchange store.
@@ -16,13 +16,21 @@ describe "Folder Synchronization" do
16
16
  @inbox = Viewpoint::EWS::GenericFolder.get_folder :inbox
17
17
  end
18
18
 
19
- describe "Example Folder Synchronization for the Inbox" do
19
+ describe "An unsynchronized Inbox Folder" do
20
+ after(:all) do
21
+ @inbox.clear_sync_state!
22
+ end
20
23
 
21
24
  it 'should start synchronization of the Inbox Folder' do
22
25
  @inbox.sync_items!(2)
23
26
  @inbox.sync_state.should_not be_nil
24
27
  end
25
28
 
29
+ it 'should synchronized to a given DateTime' do
30
+ @inbox.sync_items_since!((Date.today - 1).to_datetime)
31
+ @inbox.sync_state.should_not be_nil
32
+ end
33
+
26
34
  end
27
35
 
28
36
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dan Wanek
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-05 00:00:00 -05:00
17
+ date: 2010-11-14 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency