viewpoint 0.1.26 → 1.1.1
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.
- checksums.yaml +7 -0
- data/README.md +203 -0
- data/lib/ews/calendar_accessors.rb +34 -0
- data/lib/ews/connection.rb +140 -0
- data/lib/ews/connection_helper.rb +35 -0
- data/lib/ews/convert_accessors.rb +56 -0
- data/lib/{exceptions/exceptions.rb → ews/errors.rb} +29 -19
- data/lib/ews/ews_client.rb +105 -0
- data/lib/ews/exceptions/exceptions.rb +61 -0
- data/lib/ews/folder_accessors.rb +264 -0
- data/lib/ews/impersonation.rb +30 -0
- data/lib/ews/item_accessors.rb +242 -0
- data/lib/ews/mailbox_accessors.rb +92 -0
- data/lib/ews/meeting_accessors.rb +39 -0
- data/lib/ews/message_accessors.rb +93 -0
- data/lib/ews/push_subscription_accessors.rb +33 -0
- data/lib/ews/room_accessors.rb +48 -0
- data/lib/ews/roomlist_accessors.rb +47 -0
- data/lib/ews/soap.rb +64 -0
- data/lib/ews/soap/builders/ews_builder.rb +1384 -0
- data/lib/ews/soap/ews_response.rb +84 -0
- data/lib/ews/soap/ews_soap_availability_response.rb +58 -0
- data/lib/ews/soap/ews_soap_free_busy_response.rb +119 -0
- data/lib/ews/soap/ews_soap_response.rb +103 -0
- data/lib/ews/soap/ews_soap_room_response.rb +53 -0
- data/lib/ews/soap/ews_soap_roomlist_response.rb +54 -0
- data/lib/ews/soap/exchange_availability.rb +61 -0
- data/lib/ews/soap/exchange_data_services.rb +780 -0
- data/lib/ews/soap/exchange_notification.rb +146 -0
- data/lib/ews/soap/exchange_synchronization.rb +93 -0
- data/lib/ews/soap/exchange_time_zones.rb +56 -0
- data/lib/ews/soap/exchange_user_configuration.rb +33 -0
- data/lib/ews/soap/exchange_web_service.rb +264 -0
- data/lib/{model/item_attachment.rb → ews/soap/parsers/ews_parser.rb} +24 -14
- data/lib/ews/soap/parsers/ews_sax_document.rb +70 -0
- data/lib/ews/soap/response_message.rb +80 -0
- data/lib/ews/soap/responses/create_attachment_response_message.rb +47 -0
- data/lib/{model/meeting_message.rb → ews/soap/responses/create_item_response_message.rb} +7 -10
- data/lib/ews/soap/responses/find_item_response_message.rb +80 -0
- data/lib/ews/soap/responses/get_events_response_message.rb +53 -0
- data/lib/ews/soap/responses/send_notification_response_message.rb +59 -0
- data/lib/{model/attachment.rb → ews/soap/responses/subscribe_response_message.rb} +17 -13
- data/lib/{model/attendee.rb → ews/soap/responses/sync_folder_hierarchy_response_message.rb} +14 -15
- data/lib/ews/soap/responses/sync_folder_items_response_message.rb +36 -0
- data/lib/ews/templates/calendar_item.rb +79 -0
- data/lib/ews/templates/forward_item.rb +24 -0
- data/lib/ews/templates/message.rb +85 -0
- data/lib/ews/templates/reply_to_item.rb +25 -0
- data/lib/ews/templates/task.rb +74 -0
- data/lib/ews/types.rb +194 -0
- data/lib/ews/types/attachment.rb +77 -0
- data/lib/{model/meeting_cancellation.rb → ews/types/attendee.rb} +9 -8
- data/lib/ews/types/calendar_folder.rb +50 -0
- data/lib/ews/types/calendar_item.rb +130 -0
- data/lib/ews/types/contact.rb +7 -0
- data/lib/ews/types/contacts_folder.rb +8 -0
- data/lib/ews/types/copied_event.rb +51 -0
- data/lib/{soap/handsoap/builder.rb → ews/types/created_event.rb} +5 -2
- data/lib/ews/types/deleted_event.rb +24 -0
- data/lib/ews/types/distribution_list.rb +7 -0
- data/lib/ews/types/event.rb +62 -0
- data/lib/ews/types/export_items_response_message.rb +52 -0
- data/lib/ews/types/file_attachment.rb +65 -0
- data/lib/ews/types/folder.rb +60 -0
- data/lib/ews/types/free_busy_changed_event.rb +24 -0
- data/lib/ews/types/generic_folder.rb +418 -0
- data/lib/ews/types/item.rb +447 -0
- data/lib/ews/types/item_attachment.rb +84 -0
- data/lib/{model → ews/types}/item_field_uri_map.rb +2 -18
- data/lib/ews/types/mailbox_user.rb +156 -0
- data/lib/ews/types/meeting_cancellation.rb +7 -0
- data/lib/ews/types/meeting_message.rb +7 -0
- data/lib/ews/types/meeting_request.rb +7 -0
- data/lib/ews/types/meeting_response.rb +7 -0
- data/lib/ews/types/message.rb +7 -0
- data/lib/ews/types/modified_event.rb +48 -0
- data/lib/{extensions/string.rb → ews/types/moved_event.rb} +31 -15
- data/lib/ews/types/new_mail_event.rb +24 -0
- data/lib/ews/types/out_of_office.rb +147 -0
- data/lib/ews/types/post_item.rb +7 -0
- data/lib/ews/types/search_folder.rb +8 -0
- data/lib/ews/types/status_event.rb +39 -0
- data/lib/ews/types/task.rb +41 -0
- data/lib/ews/types/tasks_folder.rb +27 -0
- data/lib/viewpoint.rb +85 -108
- data/lib/{model/distribution_list.rb → viewpoint/logging.rb} +6 -3
- data/lib/{model/meeting_response.rb → viewpoint/logging/config.rb} +3 -3
- data/lib/viewpoint/string_utils.rb +76 -0
- metadata +156 -123
- data/README +0 -114
- data/lib/model/calendar_folder.rb +0 -67
- data/lib/model/calendar_item.rb +0 -267
- data/lib/model/contact.rb +0 -238
- data/lib/model/contacts_folder.rb +0 -46
- data/lib/model/event.rb +0 -116
- data/lib/model/file_attachment.rb +0 -53
- data/lib/model/folder.rb +0 -47
- data/lib/model/generic_folder.rb +0 -461
- data/lib/model/item.rb +0 -312
- data/lib/model/mailbox_user.rb +0 -146
- data/lib/model/meeting_request.rb +0 -39
- data/lib/model/message.rb +0 -142
- data/lib/model/model.rb +0 -269
- data/lib/model/search_folder.rb +0 -48
- data/lib/model/task.rb +0 -121
- data/lib/model/tasks_folder.rb +0 -44
- data/lib/soap/handsoap/builders/ews_build_helpers.rb +0 -383
- data/lib/soap/handsoap/builders/ews_builder.rb +0 -146
- data/lib/soap/handsoap/ews_service.rb +0 -790
- data/lib/soap/handsoap/parser.rb +0 -104
- data/lib/soap/handsoap/parsers/ews_parser.rb +0 -245
- data/lib/soap/soap_provider.rb +0 -64
data/lib/model/item.rb
DELETED
|
@@ -1,312 +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.camelcase}
|
|
36
|
-
resp = (Viewpoint::EWS::EWS.instance).ews.get_item([item_id], item_shape)
|
|
37
|
-
if(resp.status == 'Success')
|
|
38
|
-
item = resp.items.shift
|
|
39
|
-
type = item.keys.first
|
|
40
|
-
eval "#{type.to_s.camel_case}.new(item[type])"
|
|
41
|
-
else
|
|
42
|
-
raise EwsError, "Could not retrieve item. #{resp.code}: #{resp.message}"
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Add attachments to the passed in ParentId
|
|
47
|
-
# @param [String,Hash] parent_id Either a String ItemId or a Hash ItemId with a ChangeKey
|
|
48
|
-
# @option parent_id [String] :id The Id
|
|
49
|
-
# @option parent_id [String] :change_key The ChangeKey
|
|
50
|
-
# @param [Array<File>] attachments An Array of File objects to read in.
|
|
51
|
-
def self.add_attachments(parent_id, attachments)
|
|
52
|
-
conn = Viewpoint::EWS::EWS.instance
|
|
53
|
-
b64attach = []
|
|
54
|
-
attachments.each do |a|
|
|
55
|
-
b64attach << {:name => {:text =>(File.basename a.path)}, :content => {:text => Base64.encode64(a.read)}}
|
|
56
|
-
end
|
|
57
|
-
resp = conn.ews.create_attachment(parent_id, b64attach)
|
|
58
|
-
(resp.status == 'Success') || (raise EwsError, "Could not create attachments. #{resp.code}: #{resp.message}")
|
|
59
|
-
{:id => resp.items.first[:attachment_id][:root_item_id], :change_key => resp.items.first[:attachment_id][:root_item_change_key]}
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
attr_reader :item_id, :change_key, :parent_folder_id
|
|
63
|
-
alias :id :item_id
|
|
64
|
-
|
|
65
|
-
# Initialize an Exchange Web Services item
|
|
66
|
-
# @param [Hash] ews_item A hash representing this item
|
|
67
|
-
# @param [Boolean] shallow Whether or not we have retrieved all the elements for this object
|
|
68
|
-
def initialize(ews_item, opts={})
|
|
69
|
-
super() # Calls initialize in Model (creates @ews_methods Array)
|
|
70
|
-
@ews_item = ews_item
|
|
71
|
-
@shallow = opts.has_key?(:shallow) ? opts[:shallow] : true
|
|
72
|
-
@item_id = ews_item[:item_id][:id]
|
|
73
|
-
@change_key = ews_item[:item_id][:change_key]
|
|
74
|
-
@text_only = false
|
|
75
|
-
@updates = {}
|
|
76
|
-
|
|
77
|
-
init_methods
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
# See if this item is set to return only text in its body.
|
|
82
|
-
# @return [Boolean] if true the body will return only text, otherwise it may be HTML or text.
|
|
83
|
-
def text_only?
|
|
84
|
-
@text_only
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Set whether or not the body should be text-only or not
|
|
88
|
-
# @param [Boolean] txt if true the body will return only text, otherwise it may be HTML or text.
|
|
89
|
-
def text_only=(txt)
|
|
90
|
-
@text_only = ( txt == true ? true : false)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# Save any pending updates that were manipulated via setter methods.
|
|
94
|
-
def save!
|
|
95
|
-
return true if @updates.empty?
|
|
96
|
-
if update_attribs!(@updates)
|
|
97
|
-
@updates = {}
|
|
98
|
-
true
|
|
99
|
-
else
|
|
100
|
-
false
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
# Clear out any pending updates
|
|
105
|
-
# @return [TrueClass]
|
|
106
|
-
def clear_updates!
|
|
107
|
-
@updates = {}
|
|
108
|
-
true
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
# Call UpdateItem for this item with the passed updates
|
|
112
|
-
# @param [Hash] updates a well-formed update hash
|
|
113
|
-
# @example {:set_item_field=>{:field_uRI=>{:field_uRI=>"message:IsRead"}, :message=>{:is_read=>{:text=>"true"}}}}
|
|
114
|
-
def update!(updates)
|
|
115
|
-
conn = Viewpoint::EWS::EWS.instance
|
|
116
|
-
resp = conn.ews.update_item([{:id => @item_id, :change_key => @change_key}], {:updates => updates})
|
|
117
|
-
if resp.status == 'Success'
|
|
118
|
-
@item_id = resp.items.first[resp.items.first.keys.first][:item_id][:id]
|
|
119
|
-
@change_key = resp.items.first[resp.items.first.keys.first][:item_id][:change_key]
|
|
120
|
-
@shallow = true
|
|
121
|
-
deepen!
|
|
122
|
-
else
|
|
123
|
-
raise EwsError, "Trouble updating Item. #{resp.code}: #{resp.message}"
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
# This takes a hash of attributes with new values and builds the appropriate udpate hash.
|
|
129
|
-
# It does not commit the changes to Exchange, call #update! with the returned values from
|
|
130
|
-
# this method or look at #update_attribs! for a version of this method that autocommits the
|
|
131
|
-
# changes back.
|
|
132
|
-
#
|
|
133
|
-
# You can also specify a preformatted Array of data like so:
|
|
134
|
-
# {:preformatted => [misc data]}
|
|
135
|
-
# This will simply be passed to the update! method
|
|
136
|
-
# @param [Hash] updates a hash that is formed like so :item_attr => newvalue
|
|
137
|
-
# @param [Symbol] update_type :append, :replace, :delete
|
|
138
|
-
# @example {:sensitivity => {:text => 'Normal'}, :display_name => {:text => 'Test User'}}
|
|
139
|
-
def update_attribs(updates, update_type = :replace)
|
|
140
|
-
utype_map = {:append => :append_to_item_field, :replace => :set_item_field, :delete => :delete_item_field}
|
|
141
|
-
changes = []
|
|
142
|
-
type = self.class.name.split(/::/).last.ruby_case.to_sym
|
|
143
|
-
|
|
144
|
-
updates.each_pair do |k,v|
|
|
145
|
-
if(k == :preformatted)
|
|
146
|
-
changes += v
|
|
147
|
-
next
|
|
148
|
-
end
|
|
149
|
-
raise EwsError, "Field (#{FIELD_URIS[k][:text]}) not writable by update." unless FIELD_URIS[k][:writable]
|
|
150
|
-
changes << {utype_map[update_type]=>[{:field_uRI => {:field_uRI=>FIELD_URIS[k][:text]}}, {type=>{k => v}}]}
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
changes
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
# This is the same as #update_attribs, but it will commit the changes back to Exchange.
|
|
157
|
-
# @see #update_attribs
|
|
158
|
-
def update_attribs!(updates, update_type = :replace)
|
|
159
|
-
changes = update_attribs(updates, update_type)
|
|
160
|
-
update!(changes)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
# Mark this Item as read
|
|
164
|
-
def mark_read!
|
|
165
|
-
field = :is_read
|
|
166
|
-
update!({:set_item_field=>{:field_uRI=>{:field_uRI=>FIELD_URIS[field][:text]}, :message=>{field=>{:text=>"true"}}}})
|
|
167
|
-
@is_read = true
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
# Mark this Item as unread
|
|
171
|
-
def mark_unread!
|
|
172
|
-
field = :is_read
|
|
173
|
-
update!({:set_item_field=>{:field_uRI=>{:field_uRI=>FIELD_URIS[field][:text]}, :message=>{field=>{:text=>"false"}}}})
|
|
174
|
-
@is_read = false
|
|
175
|
-
true
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
def deepen!
|
|
179
|
-
return true unless @shallow
|
|
180
|
-
conn = Viewpoint::EWS::EWS.instance
|
|
181
|
-
shape = {:base_shape => 'AllProperties', :body_type => (@text_only ? 'Text' : 'Best')}
|
|
182
|
-
resp = conn.ews.get_item([@item_id], shape)
|
|
183
|
-
resp = resp.items.shift
|
|
184
|
-
@ews_item = resp[resp.keys.first]
|
|
185
|
-
@shallow = false
|
|
186
|
-
@ews_methods = []
|
|
187
|
-
@ews_methods_undef = []
|
|
188
|
-
init_methods
|
|
189
|
-
true
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
# Move this item to a new folder
|
|
193
|
-
# @param [String,Symbol,GenericFolder] new_folder The new folder to move it to. This should
|
|
194
|
-
# be a subclass of GenericFolder, a DistinguishedFolderId (must me a Symbol) or a FolderId (String)
|
|
195
|
-
def move!(new_folder)
|
|
196
|
-
new_folder = new_folder.id if new_folder.kind_of?(GenericFolder)
|
|
197
|
-
resp = (Viewpoint::EWS::EWS.instance).ews.move_item([@item_id], new_folder)
|
|
198
|
-
if(resp.status == 'Success')
|
|
199
|
-
@item_id = resp.items.first[resp.items.first.keys.first][:item_id][:id]
|
|
200
|
-
@change_key = resp.items.first[resp.items.first.keys.first][:item_id][:change_key]
|
|
201
|
-
true
|
|
202
|
-
else
|
|
203
|
-
raise EwsError, "Could not move item. #{resp.code}: #{resp.message}"
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
# Copy this item to a new folder
|
|
208
|
-
# @param [String,Symbol,GenericFolder] new_folder The new folder to move it to. This should
|
|
209
|
-
# be a subclass of GenericFolder, a DistinguishedFolderId (must me a Symbol) or a FolderId (String)
|
|
210
|
-
# @return [Item] The Item object of the copy
|
|
211
|
-
def copy(new_folder)
|
|
212
|
-
new_folder = new_folder.id if new_folder.kind_of?(GenericFolder)
|
|
213
|
-
resp = (Viewpoint::EWS::EWS.instance).ews.copy_item([@item_id], new_folder)
|
|
214
|
-
if(resp.status == 'Success')
|
|
215
|
-
item = resp.items.first
|
|
216
|
-
i_type = item.keys.first.to_s.camel_case
|
|
217
|
-
return(eval "#{i_type}.new(item[item.keys.first])")
|
|
218
|
-
else
|
|
219
|
-
raise EwsError, "Could not copy item. #{resp.code}: #{resp.message}"
|
|
220
|
-
end
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
# Return the attachments for this Item
|
|
224
|
-
# @return [Array,Attachment] An array of Attachments for this Item
|
|
225
|
-
def attachments
|
|
226
|
-
# TODO: should an exception be raised if someone calls this method without first
|
|
227
|
-
# checking has_attachments?
|
|
228
|
-
return [] unless has_attachments?
|
|
229
|
-
|
|
230
|
-
# If we've already called this don't waste the time to process attachments again.
|
|
231
|
-
return @attachments if defined?(@attachments)
|
|
232
|
-
|
|
233
|
-
deepen!
|
|
234
|
-
@attachments = []
|
|
235
|
-
@ews_item[:attachments].each_pair do |k,v|
|
|
236
|
-
# k should be file_attachment or item_attachment
|
|
237
|
-
if(v.is_a?(Hash))
|
|
238
|
-
@attachments << (eval "#{k.to_s.camel_case}.new(v[:attachment_id][:id])")
|
|
239
|
-
else
|
|
240
|
-
v.each do |att|
|
|
241
|
-
@attachments << (eval "#{k.to_s.camel_case}.new(att[:attachment_id][:id])")
|
|
242
|
-
end
|
|
243
|
-
end
|
|
244
|
-
end
|
|
245
|
-
@attachments
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
# Delete this item
|
|
249
|
-
# @param [Boolean] soft Whether or not to do a soft delete. By default EWS will do a
|
|
250
|
-
# hard delete of this item. See the MSDN docs for more info:
|
|
251
|
-
# http://msdn.microsoft.com/en-us/library/aa562961.aspx
|
|
252
|
-
# @return [Boolean] Whether or not the item was deleted
|
|
253
|
-
# @todo Add exception handling for failed deletes
|
|
254
|
-
def delete!(soft=false)
|
|
255
|
-
deltype = soft ? 'SoftDelete' : 'HardDelete'
|
|
256
|
-
resp = (Viewpoint::EWS::EWS.instance).ews.delete_item([@item_id], deltype)
|
|
257
|
-
self.clear_object!
|
|
258
|
-
(resp.status == 'Success') || (raise EwsError, "Could not delete message. #{resp.code}: #{resp.message}")
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
# Delete this item by moving it to the Deleted Items folder
|
|
262
|
-
# @see http://msdn.microsoft.com/en-us/library/aa562961.aspx
|
|
263
|
-
# @return [Boolean] Whether or not the item was deleted
|
|
264
|
-
# @todo Add exception handling for failed deletes
|
|
265
|
-
def recycle!
|
|
266
|
-
resp = (Viewpoint::EWS::EWS.instance).ews.delete_item([@item_id], 'MoveToDeletedItems')
|
|
267
|
-
self.clear_object!
|
|
268
|
-
(resp.status == 'Success') || (raise EwsError, "Could not recycle message. #{resp.code}: #{resp.message}")
|
|
269
|
-
end
|
|
270
|
-
|
|
271
|
-
# Get the parent folder of this item
|
|
272
|
-
# @return [GenericFolder] returns a GenericFolder of subclass of that type.
|
|
273
|
-
def parent_folder
|
|
274
|
-
#deepen!
|
|
275
|
-
GenericFolder.get_folder @parent_folder_id
|
|
276
|
-
end
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
private
|
|
281
|
-
|
|
282
|
-
# @todo Handle:
|
|
283
|
-
# <Attachments/> <Categories/> <InternetMessageHeaders/> <ResponseObjects/>
|
|
284
|
-
# <ExtendedProperty/> <EffectiveRights/>
|
|
285
|
-
def init_methods
|
|
286
|
-
@parent_folder_id = @ews_item[:parent_folder_id][:id] if @ews_item[:parent_folder_id].is_a?(Hash)
|
|
287
|
-
@conversation_id = @ews_item[:conversation_id][:id] if @ews_item[:conversation_id].is_a?(Hash)
|
|
288
|
-
@ews_methods << :item_id
|
|
289
|
-
define_str_var :subject, :sensitivity, :body, :item_class, :importance, :in_reply_to, :unique_body
|
|
290
|
-
define_str_var :display_cc, :display_to, :culture, :last_modified_name, :mime_content
|
|
291
|
-
define_str_var :web_client_read_form_query_string, :web_client_edit_form_query_string
|
|
292
|
-
define_attr_str_var :body, :body_type
|
|
293
|
-
define_attr_str_var :unique_body, :body_type
|
|
294
|
-
define_attr_str_var :mime_content, :character_set
|
|
295
|
-
define_int_var :size, :reminder_minutes_before_start
|
|
296
|
-
define_bool_var :has_attachments, :is_submitted, :is_draft, :is_from_me, :is_resend, :is_unmodified, :reminder_is_set, :is_associated
|
|
297
|
-
define_datetime_var :date_time_sent, :date_time_created, :date_time_received, :reminder_due_by, :last_modified_time
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
def method_missing(m, *args, &block)
|
|
301
|
-
if(@shallow)
|
|
302
|
-
deepen!
|
|
303
|
-
send(m, *args, &block)
|
|
304
|
-
else
|
|
305
|
-
warn "!!! No such method: #{m}" if $DEBUG
|
|
306
|
-
nil
|
|
307
|
-
end
|
|
308
|
-
end
|
|
309
|
-
|
|
310
|
-
end # Item
|
|
311
|
-
end # EWS
|
|
312
|
-
end # Viewpoint
|
data/lib/model/mailbox_user.rb
DELETED
|
@@ -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
|