viewpoint 0.1.27 → 1.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/README.md +196 -0
  2. data/lib/ews/calendar_accessors.rb +34 -0
  3. data/lib/ews/connection.rb +117 -0
  4. data/lib/ews/connection_helper.rb +35 -0
  5. data/lib/ews/ews_client.rb +71 -0
  6. data/lib/ews/exceptions/exceptions.rb +59 -0
  7. data/lib/ews/folder_accessors.rb +199 -0
  8. data/lib/ews/item_accessors.rb +157 -0
  9. data/lib/ews/mailbox_accessors.rb +87 -0
  10. data/lib/ews/message_accessors.rb +86 -0
  11. data/lib/ews/push_subscription_accessors.rb +33 -0
  12. data/lib/ews/soap.rb +63 -0
  13. data/lib/ews/soap/builders/ews_builder.rb +1011 -0
  14. data/lib/ews/soap/ews_response.rb +83 -0
  15. data/lib/ews/soap/ews_soap_availability_response.rb +58 -0
  16. data/lib/ews/soap/ews_soap_free_busy_response.rb +109 -0
  17. data/lib/ews/soap/ews_soap_response.rb +103 -0
  18. data/lib/ews/soap/exchange_availability.rb +61 -0
  19. data/lib/ews/soap/exchange_data_services.rb +742 -0
  20. data/lib/ews/soap/exchange_notification.rb +146 -0
  21. data/lib/ews/soap/exchange_user_configuration.rb +33 -0
  22. data/lib/ews/soap/exchange_web_service.rb +294 -0
  23. data/lib/{model/attendee.rb → ews/soap/parsers/ews_parser.rb} +20 -14
  24. data/lib/ews/soap/parsers/ews_sax_document.rb +66 -0
  25. data/lib/ews/soap/response_message.rb +78 -0
  26. data/lib/ews/soap/responses/create_attachment_response_message.rb +46 -0
  27. data/lib/{model/meeting_message.rb → ews/soap/responses/create_item_response_message.rb} +7 -10
  28. data/lib/ews/soap/responses/find_item_response_message.rb +80 -0
  29. data/lib/ews/soap/responses/get_events_response_message.rb +53 -0
  30. data/lib/ews/soap/responses/send_notification_response_message.rb +58 -0
  31. data/lib/{model/attachment.rb → ews/soap/responses/subscribe_response_message.rb} +17 -13
  32. data/lib/ews/templates/forward_item.rb +24 -0
  33. data/lib/ews/templates/message.rb +66 -0
  34. data/lib/ews/templates/reply_to_item.rb +25 -0
  35. data/lib/ews/types.rb +146 -0
  36. data/lib/ews/types/attachment.rb +77 -0
  37. data/lib/{model/meeting_cancellation.rb → ews/types/attendee.rb} +9 -8
  38. data/lib/ews/types/calendar_folder.rb +8 -0
  39. data/lib/ews/types/calendar_item.rb +37 -0
  40. data/lib/ews/types/contact.rb +7 -0
  41. data/lib/ews/types/contacts_folder.rb +8 -0
  42. data/lib/ews/types/copied_event.rb +51 -0
  43. data/lib/{soap/handsoap/builder.rb → ews/types/created_event.rb} +5 -2
  44. data/lib/{model/meeting_response.rb → ews/types/deleted_event.rb} +6 -6
  45. data/lib/ews/types/distribution_list.rb +7 -0
  46. data/lib/ews/types/event.rb +62 -0
  47. data/lib/ews/types/file_attachment.rb +65 -0
  48. data/lib/ews/types/folder.rb +60 -0
  49. data/lib/{model/distribution_list.rb → ews/types/free_busy_changed_event.rb} +6 -6
  50. data/lib/ews/types/generic_folder.rb +352 -0
  51. data/lib/ews/types/item.rb +381 -0
  52. data/lib/ews/types/item_attachment.rb +46 -0
  53. data/lib/{model → ews/types}/item_field_uri_map.rb +2 -2
  54. data/lib/ews/types/mailbox_user.rb +156 -0
  55. data/lib/ews/types/meeting_cancellation.rb +7 -0
  56. data/lib/ews/types/meeting_message.rb +7 -0
  57. data/lib/ews/types/meeting_request.rb +7 -0
  58. data/lib/ews/types/meeting_response.rb +7 -0
  59. data/lib/ews/types/message.rb +7 -0
  60. data/lib/ews/types/modified_event.rb +48 -0
  61. data/lib/{model/item_attachment.rb → ews/types/moved_event.rb} +33 -15
  62. data/lib/ews/types/new_mail_event.rb +24 -0
  63. data/lib/ews/types/out_of_office.rb +147 -0
  64. data/lib/ews/types/search_folder.rb +8 -0
  65. data/lib/ews/types/status_event.rb +39 -0
  66. data/lib/ews/types/task.rb +7 -0
  67. data/lib/ews/types/tasks_folder.rb +8 -0
  68. data/lib/viewpoint.rb +82 -106
  69. metadata +99 -67
  70. data/README +0 -114
  71. data/lib/exceptions/exceptions.rb +0 -46
  72. data/lib/model/calendar_folder.rb +0 -67
  73. data/lib/model/calendar_item.rb +0 -267
  74. data/lib/model/contact.rb +0 -238
  75. data/lib/model/contacts_folder.rb +0 -46
  76. data/lib/model/event.rb +0 -116
  77. data/lib/model/file_attachment.rb +0 -53
  78. data/lib/model/folder.rb +0 -47
  79. data/lib/model/generic_folder.rb +0 -471
  80. data/lib/model/item.rb +0 -313
  81. data/lib/model/mailbox_user.rb +0 -146
  82. data/lib/model/meeting_request.rb +0 -39
  83. data/lib/model/message.rb +0 -142
  84. data/lib/model/model.rb +0 -269
  85. data/lib/model/search_folder.rb +0 -48
  86. data/lib/model/task.rb +0 -121
  87. data/lib/model/tasks_folder.rb +0 -44
  88. data/lib/soap/handsoap/builders/ews_build_helpers.rb +0 -383
  89. data/lib/soap/handsoap/builders/ews_builder.rb +0 -146
  90. data/lib/soap/handsoap/ews_service.rb +0 -813
  91. data/lib/soap/handsoap/parser.rb +0 -104
  92. data/lib/soap/handsoap/parsers/ews_parser.rb +0 -246
  93. data/lib/soap/soap_provider.rb +0 -64
@@ -1,313 +0,0 @@
1
- =begin
2
- This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
-
4
- Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License");
7
- you may not use this file except in compliance with the License.
8
- You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- =end
18
-
19
- # This class is inherited by all Item subtypes such as Message, Event,
20
- # and Task. It will serve as the brain for all of the methods that
21
- # each of these Item types have in common.
22
- module Viewpoint
23
- module EWS
24
- class Item
25
- include Model
26
- include ItemFieldUriMap
27
-
28
- # This is a class method that fetches an existing Item from the
29
- # Exchange Store.
30
- # @param [String] item_id The id of the item.
31
- # @param [Symbol] shape The optional shape of the item :id_only/:default/:all_properties
32
- # @return [Item] Returns an Item or subclass of Item
33
- # @todo Add support to fetch an item with a ChangeKey
34
- def self.get_item(item_id, shape = :default)
35
- item_shape = {:base_shape => shape.to_s.camel_case}
36
- shallow = item_shape[:base_shape] != 'AllProperties'
37
- resp = (Viewpoint::EWS::EWS.instance).ews.get_item([item_id], item_shape)
38
- if(resp.status == 'Success')
39
- item = resp.items.shift
40
- type = item.keys.first
41
- eval "#{type.to_s.camel_case}.new(item[type], :shallow => #{shallow})"
42
- else
43
- raise EwsError, "Could not retrieve item. #{resp.code}: #{resp.message}"
44
- end
45
- end
46
-
47
- # Add attachments to the passed in ParentId
48
- # @param [String,Hash] parent_id Either a String ItemId or a Hash ItemId with a ChangeKey
49
- # @option parent_id [String] :id The Id
50
- # @option parent_id [String] :change_key The ChangeKey
51
- # @param [Array<File>] attachments An Array of File objects to read in.
52
- def self.add_attachments(parent_id, attachments)
53
- conn = Viewpoint::EWS::EWS.instance
54
- b64attach = []
55
- attachments.each do |a|
56
- b64attach << {:name => {:text =>(File.basename a.path)}, :content => {:text => Base64.encode64(a.read)}}
57
- end
58
- resp = conn.ews.create_attachment(parent_id, b64attach)
59
- (resp.status == 'Success') || (raise EwsError, "Could not create attachments. #{resp.code}: #{resp.message}")
60
- {:id => resp.items.first[:attachment_id][:root_item_id], :change_key => resp.items.first[:attachment_id][:root_item_change_key]}
61
- end
62
-
63
- attr_reader :item_id, :change_key, :parent_folder_id
64
- alias :id :item_id
65
-
66
- # Initialize an Exchange Web Services item
67
- # @param [Hash] ews_item A hash representing this item
68
- # @param [Boolean] shallow Whether or not we have retrieved all the elements for this object
69
- def initialize(ews_item, opts={})
70
- super() # Calls initialize in Model (creates @ews_methods Array)
71
- @ews_item = ews_item
72
- @shallow = opts.has_key?(:shallow) ? opts[:shallow] : true
73
- @item_id = ews_item[:item_id][:id]
74
- @change_key = ews_item[:item_id][:change_key]
75
- @text_only = false
76
- @updates = {}
77
-
78
- init_methods
79
- end
80
-
81
-
82
- # See if this item is set to return only text in its body.
83
- # @return [Boolean] if true the body will return only text, otherwise it may be HTML or text.
84
- def text_only?
85
- @text_only
86
- end
87
-
88
- # Set whether or not the body should be text-only or not
89
- # @param [Boolean] txt if true the body will return only text, otherwise it may be HTML or text.
90
- def text_only=(txt)
91
- @text_only = ( txt == true ? true : false)
92
- end
93
-
94
- # Save any pending updates that were manipulated via setter methods.
95
- def save!
96
- return true if @updates.empty?
97
- if update_attribs!(@updates)
98
- @updates = {}
99
- true
100
- else
101
- false
102
- end
103
- end
104
-
105
- # Clear out any pending updates
106
- # @return [TrueClass]
107
- def clear_updates!
108
- @updates = {}
109
- true
110
- end
111
-
112
- # Call UpdateItem for this item with the passed updates
113
- # @param [Hash] updates a well-formed update hash
114
- # @example {:set_item_field=>{:field_uRI=>{:field_uRI=>"message:IsRead"}, :message=>{:is_read=>{:text=>"true"}}}}
115
- def update!(updates)
116
- conn = Viewpoint::EWS::EWS.instance
117
- resp = conn.ews.update_item([{:id => @item_id, :change_key => @change_key}], {:updates => updates})
118
- if resp.status == 'Success'
119
- @item_id = resp.items.first[resp.items.first.keys.first][:item_id][:id]
120
- @change_key = resp.items.first[resp.items.first.keys.first][:item_id][:change_key]
121
- @shallow = true
122
- deepen!
123
- else
124
- raise EwsError, "Trouble updating Item. #{resp.code}: #{resp.message}"
125
- end
126
-
127
- end
128
-
129
- # This takes a hash of attributes with new values and builds the appropriate udpate hash.
130
- # It does not commit the changes to Exchange, call #update! with the returned values from
131
- # this method or look at #update_attribs! for a version of this method that autocommits the
132
- # changes back.
133
- #
134
- # You can also specify a preformatted Array of data like so:
135
- # {:preformatted => [misc data]}
136
- # This will simply be passed to the update! method
137
- # @param [Hash] updates a hash that is formed like so :item_attr => newvalue
138
- # @param [Symbol] update_type :append, :replace, :delete
139
- # @example {:sensitivity => {:text => 'Normal'}, :display_name => {:text => 'Test User'}}
140
- def update_attribs(updates, update_type = :replace)
141
- utype_map = {:append => :append_to_item_field, :replace => :set_item_field, :delete => :delete_item_field}
142
- changes = []
143
- type = self.class.name.split(/::/).last.ruby_case.to_sym
144
-
145
- updates.each_pair do |k,v|
146
- if(k == :preformatted)
147
- changes += v
148
- next
149
- end
150
- raise EwsError, "Field (#{FIELD_URIS[k][:text]}) not writable by update." unless FIELD_URIS[k][:writable]
151
- changes << {utype_map[update_type]=>[{:field_uRI => {:field_uRI=>FIELD_URIS[k][:text]}}, {type=>{k => v}}]}
152
- end
153
-
154
- changes
155
- end
156
-
157
- # This is the same as #update_attribs, but it will commit the changes back to Exchange.
158
- # @see #update_attribs
159
- def update_attribs!(updates, update_type = :replace)
160
- changes = update_attribs(updates, update_type)
161
- update!(changes)
162
- end
163
-
164
- # Mark this Item as read
165
- def mark_read!
166
- field = :is_read
167
- update!({:set_item_field=>{:field_uRI=>{:field_uRI=>FIELD_URIS[field][:text]}, :message=>{field=>{:text=>"true"}}}})
168
- @is_read = true
169
- end
170
-
171
- # Mark this Item as unread
172
- def mark_unread!
173
- field = :is_read
174
- update!({:set_item_field=>{:field_uRI=>{:field_uRI=>FIELD_URIS[field][:text]}, :message=>{field=>{:text=>"false"}}}})
175
- @is_read = false
176
- true
177
- end
178
-
179
- def deepen!
180
- return true unless @shallow
181
- conn = Viewpoint::EWS::EWS.instance
182
- shape = {:base_shape => 'AllProperties', :body_type => (@text_only ? 'Text' : 'Best')}
183
- resp = conn.ews.get_item([@item_id], shape)
184
- resp = resp.items.shift
185
- @ews_item = resp[resp.keys.first]
186
- @shallow = false
187
- @ews_methods = []
188
- @ews_methods_undef = []
189
- init_methods
190
- true
191
- end
192
-
193
- # Move this item to a new folder
194
- # @param [String,Symbol,GenericFolder] new_folder The new folder to move it to. This should
195
- # be a subclass of GenericFolder, a DistinguishedFolderId (must me a Symbol) or a FolderId (String)
196
- def move!(new_folder)
197
- new_folder = new_folder.id if new_folder.kind_of?(GenericFolder)
198
- resp = (Viewpoint::EWS::EWS.instance).ews.move_item([@item_id], new_folder)
199
- if(resp.status == 'Success')
200
- @item_id = resp.items.first[resp.items.first.keys.first][:item_id][:id]
201
- @change_key = resp.items.first[resp.items.first.keys.first][:item_id][:change_key]
202
- true
203
- else
204
- raise EwsError, "Could not move item. #{resp.code}: #{resp.message}"
205
- end
206
- end
207
-
208
- # Copy this item to a new folder
209
- # @param [String,Symbol,GenericFolder] new_folder The new folder to move it to. This should
210
- # be a subclass of GenericFolder, a DistinguishedFolderId (must me a Symbol) or a FolderId (String)
211
- # @return [Item] The Item object of the copy
212
- def copy(new_folder)
213
- new_folder = new_folder.id if new_folder.kind_of?(GenericFolder)
214
- resp = (Viewpoint::EWS::EWS.instance).ews.copy_item([@item_id], new_folder)
215
- if(resp.status == 'Success')
216
- item = resp.items.first
217
- i_type = item.keys.first.to_s.camel_case
218
- return(eval "#{i_type}.new(item[item.keys.first])")
219
- else
220
- raise EwsError, "Could not copy item. #{resp.code}: #{resp.message}"
221
- end
222
- end
223
-
224
- # Return the attachments for this Item
225
- # @return [Array,Attachment] An array of Attachments for this Item
226
- def attachments
227
- # TODO: should an exception be raised if someone calls this method without first
228
- # checking has_attachments?
229
- return [] unless has_attachments?
230
-
231
- # If we've already called this don't waste the time to process attachments again.
232
- return @attachments if defined?(@attachments)
233
-
234
- deepen!
235
- @attachments = []
236
- @ews_item[:attachments].each_pair do |k,v|
237
- # k should be file_attachment or item_attachment
238
- if(v.is_a?(Hash))
239
- @attachments << (eval "#{k.to_s.camel_case}.new(v[:attachment_id][:id])")
240
- else
241
- v.each do |att|
242
- @attachments << (eval "#{k.to_s.camel_case}.new(att[:attachment_id][:id])")
243
- end
244
- end
245
- end
246
- @attachments
247
- end
248
-
249
- # Delete this item
250
- # @param [Boolean] soft Whether or not to do a soft delete. By default EWS will do a
251
- # hard delete of this item. See the MSDN docs for more info:
252
- # http://msdn.microsoft.com/en-us/library/aa562961.aspx
253
- # @return [Boolean] Whether or not the item was deleted
254
- # @todo Add exception handling for failed deletes
255
- def delete!(soft=false)
256
- deltype = soft ? 'SoftDelete' : 'HardDelete'
257
- resp = (Viewpoint::EWS::EWS.instance).ews.delete_item([@item_id], deltype)
258
- self.clear_object!
259
- (resp.status == 'Success') || (raise EwsError, "Could not delete message. #{resp.code}: #{resp.message}")
260
- end
261
-
262
- # Delete this item by moving it to the Deleted Items folder
263
- # @see http://msdn.microsoft.com/en-us/library/aa562961.aspx
264
- # @return [Boolean] Whether or not the item was deleted
265
- # @todo Add exception handling for failed deletes
266
- def recycle!
267
- resp = (Viewpoint::EWS::EWS.instance).ews.delete_item([@item_id], 'MoveToDeletedItems')
268
- self.clear_object!
269
- (resp.status == 'Success') || (raise EwsError, "Could not recycle message. #{resp.code}: #{resp.message}")
270
- end
271
-
272
- # Get the parent folder of this item
273
- # @return [GenericFolder] returns a GenericFolder of subclass of that type.
274
- def parent_folder
275
- #deepen!
276
- GenericFolder.get_folder @parent_folder_id
277
- end
278
-
279
-
280
-
281
- private
282
-
283
- # @todo Handle:
284
- # <Attachments/> <Categories/> <InternetMessageHeaders/> <ResponseObjects/>
285
- # <ExtendedProperty/> <EffectiveRights/>
286
- def init_methods
287
- @parent_folder_id = @ews_item[:parent_folder_id][:id] if @ews_item[:parent_folder_id].is_a?(Hash)
288
- @conversation_id = @ews_item[:conversation_id][:id] if @ews_item[:conversation_id].is_a?(Hash)
289
- @ews_methods << :item_id
290
- define_str_var :subject, :sensitivity, :body, :item_class, :importance, :in_reply_to, :unique_body
291
- define_str_var :display_cc, :display_to, :culture, :last_modified_name, :mime_content
292
- define_str_var :web_client_read_form_query_string, :web_client_edit_form_query_string
293
- define_attr_str_var :body, :body_type
294
- define_attr_str_var :unique_body, :body_type
295
- define_attr_str_var :mime_content, :character_set
296
- define_int_var :size, :reminder_minutes_before_start
297
- define_bool_var :has_attachments, :is_submitted, :is_draft, :is_from_me, :is_resend, :is_unmodified, :reminder_is_set, :is_associated
298
- define_datetime_var :date_time_sent, :date_time_created, :date_time_received, :reminder_due_by, :last_modified_time
299
- end
300
-
301
- def method_missing(m, *args, &block)
302
- if(@shallow)
303
- deepen!
304
- send(m, *args, &block)
305
- else
306
- warn "!!! No such method: #{m}" if $DEBUG
307
- nil
308
- end
309
- end
310
-
311
- end # Item
312
- end # EWS
313
- end # Viewpoint
@@ -1,146 +0,0 @@
1
- =begin
2
- This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
-
4
- Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License");
7
- you may not use this file except in compliance with the License.
8
- You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- =end
18
-
19
- module Viewpoint
20
- module EWS
21
-
22
- # This represents a Mailbox object in the Exchange data store
23
- # @see http://msdn.microsoft.com/en-us/library/aa565036.aspx MSDN docs
24
- # @todo Design a Class method that resolves to an Array of MailboxUsers
25
- class MailboxUser
26
- include Model
27
-
28
- # Resolve a user in the Exchange Data Store
29
- # @param [String] resolve A user to resolve to.
30
- # @return [MailboxUser,Array] If it resolves to one user then it returns a MailboxUser.
31
- # If it resolves to more than one user an Array of MailboxUsers are returned. If an
32
- # error ocurrs an exception is raised.
33
- # @todo - rename "resolve" to something more descriptive
34
- # - standardize on a common return type???
35
- def self.find_user(resolve)
36
- resp = (Viewpoint::EWS::EWS.instance).ews.resolve_names(resolve)
37
- if(resp.status == 'Success')
38
- return self.new(resp.items.first[:mailbox])
39
- elsif(resp.code == 'ErrorNameResolutionMultipleResults')
40
- users = []
41
- resp.items.each do |u|
42
- users << self.new(u[:mailbox])
43
- end
44
- return users
45
- else
46
- raise EwsError, "Find User produced an error: #{resp.code}: #{resp.message}"
47
- end
48
- end
49
-
50
- # Get information about when the user with the given email address is available.
51
- # @param [String] email_address The email address of the person to find availability for.
52
- # @param [String] start_time The start of the time range to check as an xs:dateTime.
53
- # @param [String] end_time The end of the time range to check as an xs:dateTime.
54
- # @see http://msdn.microsoft.com/en-us/library/aa494212.aspx
55
- def self.get_user_availability(email_address, start_time, end_time)
56
- resp = (Viewpoint::EWS::EWS.instance).ews.get_user_availability(email_address, start_time, end_time)
57
- if(resp.status == 'Success')
58
- return resp.items
59
- else
60
- raise EwsError, "GetUserAvailability produced an error: #{resp.code}: #{resp.message}"
61
- end
62
- end
63
-
64
- def initialize(mbox_user)
65
- super() # Calls initialize in Model (creates @ews_methods Array)
66
- @ews_item = mbox_user
67
- define_str_var :name, :email_address, :routing_type, :mailbox_type, :item_id
68
- end
69
-
70
- def get_oof
71
- mailbox = {:mailbox => {:address => {:text => email_address}}}
72
- resp = (Viewpoint::EWS::EWS.instance).ews.get_user_oof_settings(mailbox)
73
- s = resp[:oof_settings]
74
- @oof_state = s[:oof_state][:text]
75
- @oof_ext_audience = s[:external_audience][:text]
76
- @oof_start = DateTime.parse(s[:duration][:start_time][:text])
77
- @oof_end = DateTime.parse(s[:duration][:end_time][:text])
78
- @oof_internal_reply = s[:internal_reply][:message][:text]
79
- @oof_external_reply = s[:internal_reply][:message][:text]
80
- true
81
- end
82
-
83
- # Get information about when this user is available.
84
- # @param [String] start_time The start of the time range to check as an xs:dateTime.
85
- # @param [String] end_time The end of the time range to check as an xs:dateTime.
86
- # @see http://msdn.microsoft.com/en-us/library/aa494212.aspx
87
- def get_user_availability(start_time, end_time)
88
- return MailboxUser.get_user_availability(self.email_address, start_time, end_time)
89
- end
90
-
91
- # Adds one or more delegates to a principal's mailbox and sets specific access permissions
92
- # @see http://msdn.microsoft.com/en-us/library/bb856527.aspx
93
- #
94
- # @param [String,MailboxUser] delegate_email The user you would like to give delegate access to.
95
- # This can either be a simple String e-mail address or you can pass in a MailboxUser object.
96
- # @param [Hash] permissions A hash of folder type keys and permission type values. An example
97
- # would be {:calendar_folder_permission_level => 'Editor'}. Possible keys are:
98
- # :calendar_folder_permission_level, :tasks_folder_permission_level, :inbox_folder_permission_level
99
- # :contacts_folder_permission_level, :notes_folder_permission_level, :journal_folder_permission_level
100
- # and possible values are: None/Editor/Reviewer/Author/Custom
101
- # @return [true] This method either returns true or raises an error with the message
102
- # as to why this operation did not succeed.
103
- def add_delegate!(delegate_email, permissions)
104
- # Use a new hash so the passed hash is not modified in case we are in a loop.
105
- # Thanks to Markus Roberts for pointing this out.
106
- formatted_perms = {}
107
- # Modify permissions so we can pass it to the builders
108
- permissions.each_pair do |k,v|
109
- formatted_perms[k] = {:text => v}
110
- end
111
-
112
- resp = (Viewpoint::EWS::EWS.instance).ews.add_delegate(self.email_address, delegate_email, formatted_perms)
113
- if(resp.status == 'Success')
114
- return true
115
- else
116
- raise EwsError, "Could not add delegate access for user #{delegate_email}: #{resp.code}, #{resp.message}"
117
- end
118
- end
119
-
120
- def update_delegate!(delegate_email, permissions)
121
- # Modify permissions so we can pass it to the builders
122
- formatted_perms = {}
123
- permissions.each_pair do |k,v|
124
- formatted_perms[k] = {:text => v}
125
- end
126
-
127
- resp = (Viewpoint::EWS::EWS.instance).ews.update_delegate(self.email_address, delegate_email, formatted_perms)
128
- if(resp.status == 'Success')
129
- return true
130
- else
131
- raise EwsError, "Could not update delegate access for user #{delegate_email}: #{resp.code}, #{resp.message}"
132
- end
133
- end
134
-
135
- def get_delegate_info()
136
- resp = (Viewpoint::EWS::EWS.instance).ews.get_delegate(self.email_address)
137
- # if(resp.status == 'Success')
138
- # return true
139
- # else
140
- # raise EwsError, "Could not update delegate access for user #{delegate_email}: #{resp.code}, #{resp.message}"
141
- # end
142
- end
143
-
144
- end # MailboxUser
145
- end # EWS
146
- end # Viewpoint