viewpoint 1.2.0 → 2.0.0
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 +4 -4
- data/README.md +11 -6
- data/lib/ews/calendar_accessors.rb +37 -33
- data/lib/ews/connection.rb +152 -125
- data/lib/ews/connection_helper.rb +36 -33
- data/lib/ews/convert_accessors.rb +58 -54
- data/lib/ews/errors.rb +59 -53
- data/lib/ews/ews_client.rb +92 -79
- data/lib/ews/exceptions/exceptions.rb +61 -61
- data/lib/ews/folder_accessors.rb +235 -234
- data/lib/ews/impersonation.rb +29 -23
- data/lib/ews/item_accessors.rb +215 -213
- data/lib/ews/mailbox_accessors.rb +82 -79
- data/lib/ews/meeting_accessors.rb +38 -31
- data/lib/ews/message_accessors.rb +83 -81
- data/lib/ews/push_subscription_accessors.rb +29 -27
- data/lib/ews/room_accessors.rb +48 -46
- data/lib/ews/roomlist_accessors.rb +47 -45
- data/lib/ews/soap/builders/ews_builder.rb +1191 -1176
- data/lib/ews/soap/ews_response.rb +68 -73
- data/lib/ews/soap/ews_soap_availability_response.rb +57 -57
- data/lib/ews/soap/ews_soap_free_busy_response.rb +115 -117
- data/lib/ews/soap/ews_soap_response.rb +99 -101
- data/lib/ews/soap/ews_soap_room_response.rb +45 -45
- data/lib/ews/soap/ews_soap_roomlist_response.rb +45 -46
- data/lib/ews/soap/exchange_availability.rb +54 -52
- data/lib/ews/soap/exchange_data_services.rb +693 -711
- data/lib/ews/soap/exchange_notification.rb +123 -128
- data/lib/ews/soap/exchange_synchronization.rb +82 -82
- data/lib/ews/soap/exchange_time_zones.rb +41 -44
- data/lib/ews/soap/exchange_user_configuration.rb +30 -27
- data/lib/ews/soap/exchange_web_service.rb +237 -233
- data/lib/ews/soap/parsers/ews_parser.rb +46 -42
- data/lib/ews/soap/parsers/ews_sax_document.rb +63 -58
- data/lib/ews/soap/response_message.rb +69 -68
- data/lib/ews/soap/responses/create_attachment_response_message.rb +45 -45
- data/lib/ews/soap/responses/create_item_response_message.rb +26 -25
- data/lib/ews/soap/responses/find_item_response_message.rb +76 -78
- data/lib/ews/soap/responses/get_events_response_message.rb +52 -51
- data/lib/ews/soap/responses/send_notification_response_message.rb +53 -51
- data/lib/ews/soap/responses/subscribe_response_message.rb +37 -34
- data/lib/ews/soap/responses/sync_folder_hierarchy_response_message.rb +38 -35
- data/lib/ews/soap/responses/sync_folder_items_response_message.rb +38 -35
- data/lib/ews/soap.rb +27 -26
- data/lib/ews/templates/calendar_item.rb +64 -60
- data/lib/ews/templates/forward_item.rb +19 -17
- data/lib/ews/templates/message.rb +61 -58
- data/lib/ews/templates/reply_to_item.rb +20 -18
- data/lib/ews/templates/task.rb +55 -55
- data/lib/ews/types/attachment.rb +75 -74
- data/lib/ews/types/attendee.rb +27 -25
- data/lib/ews/types/calendar_folder.rb +58 -59
- data/lib/ews/types/calendar_item.rb +133 -131
- data/lib/ews/types/contact.rb +11 -5
- data/lib/ews/types/contacts_folder.rb +10 -5
- data/lib/ews/types/copied_event.rb +47 -48
- data/lib/ews/types/created_event.rb +22 -20
- data/lib/ews/types/deleted_event.rb +22 -20
- data/lib/ews/types/distribution_list.rb +11 -5
- data/lib/ews/types/event.rb +60 -59
- data/lib/ews/types/export_items_response_message.rb +54 -50
- data/lib/ews/types/file_attachment.rb +63 -61
- data/lib/ews/types/folder.rb +58 -57
- data/lib/ews/types/free_busy_changed_event.rb +22 -20
- data/lib/ews/types/generic_folder.rb +348 -372
- data/lib/ews/types/item.rb +401 -397
- data/lib/ews/types/item_attachment.rb +87 -80
- data/lib/ews/types/item_field_uri_map.rb +201 -200
- data/lib/ews/types/mailbox_user.rb +146 -154
- data/lib/ews/types/meeting_cancellation.rb +11 -5
- data/lib/ews/types/meeting_message.rb +11 -5
- data/lib/ews/types/meeting_request.rb +11 -5
- data/lib/ews/types/meeting_response.rb +11 -5
- data/lib/ews/types/message.rb +11 -5
- data/lib/ews/types/modified_event.rb +43 -45
- data/lib/ews/types/moved_event.rb +47 -48
- data/lib/ews/types/new_mail_event.rb +22 -20
- data/lib/ews/types/out_of_office.rb +145 -144
- data/lib/ews/types/post_item.rb +11 -5
- data/lib/ews/types/search_folder.rb +10 -5
- data/lib/ews/types/status_event.rb +37 -36
- data/lib/ews/types/task.rb +39 -33
- data/lib/ews/types/tasks_folder.rb +31 -25
- data/lib/ews/types.rb +134 -139
- data/lib/viewpoint/logging/config.rb +19 -19
- data/lib/viewpoint/logging.rb +23 -17
- data/lib/viewpoint/string_utils.rb +31 -32
- data/lib/viewpoint.rb +18 -18
- metadata +50 -25
- data/Changelog.txt +0 -1004
|
@@ -1,1367 +1,1382 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
module Viewpoint
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
|
|
4
|
+
#
|
|
5
|
+
# Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
module Viewpoint
|
|
19
|
+
module EWS
|
|
20
|
+
module SOAP
|
|
21
|
+
# This class includes the element builders. The idea is that each element should
|
|
22
|
+
# know how to build themselves so each parent element can delegate creation of
|
|
23
|
+
# subelements to a method of the same name with a '!' after it.
|
|
24
|
+
class EwsBuilder
|
|
25
|
+
include Viewpoint::EWS
|
|
26
|
+
include Viewpoint::StringUtils
|
|
27
|
+
|
|
28
|
+
attr_reader :nbuild
|
|
29
|
+
|
|
30
|
+
def initialize
|
|
31
|
+
@nbuild = Nokogiri::XML::Builder.new
|
|
32
|
+
end
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
34
|
+
# Build the SOAP envelope and yield this object so subelements can be built. Once
|
|
35
|
+
# you have the EwsBuilder object you can use the nbuild object like shown in the
|
|
36
|
+
# example for the Header section. The nbuild object is the underlying
|
|
37
|
+
# Nokogiri::XML::Builder object.
|
|
38
|
+
# @param [Hash] opts
|
|
39
|
+
# @option opts [String] :server_version The version string that should get
|
|
40
|
+
# set in the Header. See ExchangeWebService#initialize
|
|
41
|
+
# @option opts [Hash] :time_zone_context TimeZoneDefinition. Format: !{id: time_zone_identifier}
|
|
42
|
+
# @example
|
|
43
|
+
# xb = EwsBuilder.new
|
|
44
|
+
# xb.build! do |part, b|
|
|
45
|
+
# if(part == :header)
|
|
46
|
+
# b.nbuild.MyVar('blablabla')
|
|
47
|
+
# else
|
|
48
|
+
# b.folder_shape!({:base_shape => 'Default'})
|
|
49
|
+
# end
|
|
50
|
+
# end
|
|
51
|
+
def build!(opts = {}, &block)
|
|
52
|
+
@nbuild.Envelope(NAMESPACES) do |node|
|
|
53
|
+
node.parent.namespace = parent_namespace(node)
|
|
54
|
+
node.Header do
|
|
55
|
+
set_version_header! opts[:server_version]
|
|
56
|
+
set_impersonation! opts[:impersonation_type], opts[:impersonation_mail]
|
|
57
|
+
set_time_zone_context_header! opts[:time_zone_context]
|
|
58
|
+
yield(:header, self) if block_given?
|
|
59
|
+
end
|
|
60
|
+
node.Body {
|
|
61
|
+
yield(:body, self) if block_given?
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
@nbuild.doc
|
|
65
|
+
end
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
end
|
|
67
|
+
# Build XML from a passed in Hash or Array in a specified format.
|
|
68
|
+
# @param [Array,Hash] elems The elements to add to the Builder. They must
|
|
69
|
+
# be specified like so:
|
|
70
|
+
#
|
|
71
|
+
# !{:top =>
|
|
72
|
+
# { :xmlns => 'http://stonesthrow/soap',
|
|
73
|
+
# :sub_elements => [
|
|
74
|
+
# {:elem1 => {:text => 'inside'}},
|
|
75
|
+
# {:elem2 => {:text => 'inside2'}}
|
|
76
|
+
# ],
|
|
77
|
+
# :id => '3232', :tx_dd => 23, :asdf => 'turkey'
|
|
78
|
+
# }
|
|
79
|
+
# }
|
|
80
|
+
# or
|
|
81
|
+
# [ {:first => {:text => 'hello'}},
|
|
82
|
+
# {:second => {:text => 'world'}}
|
|
83
|
+
# ]
|
|
84
|
+
#
|
|
85
|
+
# NOTE: there are specialized keys for text (:text), child elements
|
|
86
|
+
# (:sub_elements) and namespaces (:xmlns).
|
|
87
|
+
def build_xml!(elems)
|
|
88
|
+
case elems.class.name
|
|
89
|
+
when 'Hash'
|
|
90
|
+
keys = elems.keys
|
|
91
|
+
vals = elems.values
|
|
92
|
+
raise "invalid input: #{elems}" if keys.length > 1 && !vals.is_a?(Hash)
|
|
93
|
+
|
|
94
|
+
vals = vals.first.clone
|
|
95
|
+
se = vals.delete(:sub_elements)
|
|
96
|
+
txt = vals.delete(:text)
|
|
97
|
+
xmlns_attribute = vals.delete(:xmlns_attribute)
|
|
98
|
+
|
|
99
|
+
node = @nbuild.send(camel_case(keys.first), txt, vals) { |_x|
|
|
100
|
+
build_xml!(se) if se
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# Set node level namespace
|
|
104
|
+
node.xmlns = NAMESPACES["xmlns:#{xmlns_attribute}"] if xmlns_attribute
|
|
105
|
+
when 'Array'
|
|
106
|
+
elems.each do |e|
|
|
107
|
+
build_xml!(e)
|
|
108
|
+
end
|
|
109
|
+
else
|
|
110
|
+
raise "Unsupported type: #{elems.class.name}"
|
|
111
|
+
end
|
|
112
|
+
end
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
end
|
|
124
|
-
}
|
|
125
|
-
end
|
|
114
|
+
# Build the FolderShape element
|
|
115
|
+
# @see http://msdn.microsoft.com/en-us/library/aa494311.aspx
|
|
116
|
+
# @param [Hash] folder_shape The folder shape structure to build from
|
|
117
|
+
# @todo need fully support all options
|
|
118
|
+
def folder_shape!(folder_shape)
|
|
119
|
+
@nbuild.FolderShape {
|
|
120
|
+
@nbuild.parent.default_namespace = @default_ns
|
|
121
|
+
base_shape!(folder_shape[:base_shape])
|
|
122
|
+
additional_properties!(folder_shape[:additional_properties]) if folder_shape[:additional_properties]
|
|
123
|
+
}
|
|
124
|
+
end
|
|
126
125
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
end
|
|
140
|
-
}
|
|
141
|
-
end
|
|
126
|
+
# Build the ItemShape element
|
|
127
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565261.aspx
|
|
128
|
+
# @param [Hash] item_shape The item shape structure to build from
|
|
129
|
+
# @todo need fully support all options
|
|
130
|
+
def item_shape!(item_shape)
|
|
131
|
+
@nbuild[NS_EWS_MESSAGES].ItemShape {
|
|
132
|
+
@nbuild.parent.default_namespace = @default_ns
|
|
133
|
+
base_shape!(item_shape[:base_shape])
|
|
134
|
+
include_mime_content!(item_shape[:include_mime_content]) if item_shape.key?(:include_mime_content)
|
|
135
|
+
body_type!(item_shape[:body_type]) if item_shape[:body_type]
|
|
136
|
+
additional_properties!(item_shape[:additional_properties]) if item_shape[:additional_properties]
|
|
137
|
+
}
|
|
138
|
+
end
|
|
142
139
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
# Build the IndexedPageItemView element
|
|
141
|
+
# @see http://msdn.microsoft.com/en-us/library/exchange/aa563549(v=exchg.150).aspx
|
|
142
|
+
# @todo needs peer check
|
|
143
|
+
def indexed_page_item_view!(indexed_page_item_view)
|
|
144
|
+
attribs = {}
|
|
145
|
+
indexed_page_item_view.each_pair do |k, v| attribs[camel_case(k)] = v.to_s end
|
|
146
|
+
@nbuild[NS_EWS_MESSAGES].IndexedPageItemView(attribs)
|
|
147
|
+
end
|
|
151
148
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
149
|
+
# Build the BaseShape element
|
|
150
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580545.aspx
|
|
151
|
+
def base_shape!(base_shape)
|
|
152
|
+
@nbuild[NS_EWS_TYPES].BaseShape(camel_case(base_shape))
|
|
153
|
+
end
|
|
157
154
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
def include_mime_content!(include_mime_content)
|
|
156
|
+
@nbuild[NS_EWS_TYPES].IncludeMimeContent(include_mime_content.to_s.downcase)
|
|
157
|
+
end
|
|
161
158
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
159
|
+
def body_type!(body_type)
|
|
160
|
+
body_type = body_type.to_s
|
|
161
|
+
body_type = if body_type =~ /html/i
|
|
162
|
+
body_type.upcase
|
|
163
|
+
else
|
|
164
|
+
body_type.downcase.capitalize
|
|
165
|
+
end
|
|
166
|
+
nbuild[NS_EWS_TYPES].BodyType(body_type)
|
|
167
|
+
end
|
|
171
168
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
169
|
+
# Build the ParentFolderIds element
|
|
170
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565998.aspx
|
|
171
|
+
def parent_folder_ids!(pfids)
|
|
172
|
+
@nbuild[NS_EWS_MESSAGES].ParentFolderIds {
|
|
173
|
+
pfids.each do |pfid|
|
|
174
|
+
dispatch_folder_id!(pfid)
|
|
175
|
+
end
|
|
176
|
+
}
|
|
178
177
|
end
|
|
179
|
-
}
|
|
180
|
-
end
|
|
181
178
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
179
|
+
# Build the ParentFolderId element
|
|
180
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563268.aspx
|
|
181
|
+
def parent_folder_id!(pfid)
|
|
182
|
+
@nbuild.ParentFolderId {
|
|
183
|
+
dispatch_folder_id!(pfid)
|
|
184
|
+
}
|
|
185
|
+
end
|
|
189
186
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
187
|
+
# Build the FolderIds element
|
|
188
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580509.aspx
|
|
189
|
+
def folder_ids!(fids, act_as = nil)
|
|
190
|
+
ns = @nbuild.parent.name.match(/subscription/i) ? NS_EWS_TYPES : NS_EWS_MESSAGES
|
|
191
|
+
@nbuild[ns].FolderIds {
|
|
192
|
+
fids.each do |fid|
|
|
193
|
+
fid[:act_as] = act_as unless act_as.nil?
|
|
194
|
+
dispatch_folder_id!(fid)
|
|
195
|
+
end
|
|
196
|
+
}
|
|
198
197
|
end
|
|
199
|
-
}
|
|
200
|
-
end
|
|
201
198
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
199
|
+
# Build the SyncFolderId element
|
|
200
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580296.aspx
|
|
201
|
+
def sync_folder_id!(fid)
|
|
202
|
+
@nbuild.SyncFolderId {
|
|
203
|
+
dispatch_folder_id!(fid)
|
|
204
|
+
}
|
|
205
|
+
end
|
|
209
206
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
end
|
|
220
|
-
}
|
|
221
|
-
end
|
|
207
|
+
# Build the DistinguishedFolderId element
|
|
208
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580808.aspx
|
|
209
|
+
# @todo add support for the Mailbox child object
|
|
210
|
+
def distinguished_folder_id!(dfid, change_key = nil, act_as = nil)
|
|
211
|
+
attribs = { 'Id' => dfid.to_s }
|
|
212
|
+
attribs['ChangeKey'] = change_key if change_key
|
|
213
|
+
@nbuild[NS_EWS_TYPES].DistinguishedFolderId(attribs) {
|
|
214
|
+
mailbox!({ email_address: act_as }) unless act_as.nil?
|
|
215
|
+
}
|
|
216
|
+
end
|
|
222
217
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
218
|
+
# Build the FolderId element
|
|
219
|
+
# @see http://msdn.microsoft.com/en-us/library/aa579461.aspx
|
|
220
|
+
def folder_id!(fid, change_key = nil)
|
|
221
|
+
attribs = { 'Id' => fid }
|
|
222
|
+
attribs['ChangeKey'] = change_key if change_key
|
|
223
|
+
@nbuild[NS_EWS_TYPES].FolderId(attribs)
|
|
224
|
+
end
|
|
230
225
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
226
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563525(v=EXCHG.140).aspx
|
|
227
|
+
def item_ids!(item_ids)
|
|
228
|
+
@nbuild.ItemIds {
|
|
229
|
+
item_ids.each do |iid|
|
|
230
|
+
dispatch_item_id!(iid)
|
|
231
|
+
end
|
|
232
|
+
}
|
|
236
233
|
end
|
|
237
|
-
}
|
|
238
|
-
end
|
|
239
234
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
235
|
+
def parent_item_id!(id)
|
|
236
|
+
nbuild.ParentItemId { |x|
|
|
237
|
+
x.parent['Id'] = id[:id]
|
|
238
|
+
x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
|
|
239
|
+
}
|
|
240
|
+
end
|
|
246
241
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
242
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580234(v=EXCHG.140).aspx
|
|
243
|
+
def item_id!(id)
|
|
244
|
+
nbuild[NS_EWS_TYPES].ItemId { |x|
|
|
245
|
+
x.parent['Id'] = id[:id]
|
|
246
|
+
x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
|
|
247
|
+
}
|
|
248
|
+
end
|
|
254
249
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
250
|
+
# @see http://msdn.microsoft.com/en-us/library/ff709503(v=exchg.140).aspx
|
|
251
|
+
def export_item_ids!(item_ids)
|
|
252
|
+
ns = @nbuild.parent.name.match(/subscription/i) ? NS_EWS_TYPES : NS_EWS_MESSAGES
|
|
253
|
+
@nbuild[ns].ExportItems {
|
|
254
|
+
@nbuild.ItemIds {
|
|
255
|
+
item_ids.each do |iid|
|
|
256
|
+
dispatch_item_id!(iid)
|
|
257
|
+
end
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
end
|
|
266
261
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
262
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580744(v=EXCHG.140).aspx
|
|
263
|
+
def occurrence_item_id!(id)
|
|
264
|
+
@nbuild[NS_EWS_TYPES].OccurrenceItemId { |x|
|
|
265
|
+
x.parent['RecurringMasterId'] = id[:recurring_master_id]
|
|
266
|
+
x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
|
|
267
|
+
x.parent['InstanceIndex'] = id[:instance_index]
|
|
268
|
+
}
|
|
269
|
+
end
|
|
275
270
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
271
|
+
# @see http://msdn.microsoft.com/en-us/library/aa581019(v=EXCHG.140).aspx
|
|
272
|
+
def recurring_master_item_id!(id)
|
|
273
|
+
@nbuild[NS_EWS_TYPES].RecurringMasterItemId { |x|
|
|
274
|
+
x.parent['OccurrenceId'] = id[:occurrence_id]
|
|
275
|
+
x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
|
|
276
|
+
}
|
|
277
|
+
end
|
|
283
278
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
279
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565020(v=EXCHG.140).aspx
|
|
280
|
+
def to_folder_id!(to_fid)
|
|
281
|
+
@nbuild[NS_EWS_MESSAGES].ToFolderId {
|
|
282
|
+
dispatch_folder_id!(to_fid)
|
|
283
|
+
}
|
|
284
|
+
end
|
|
290
285
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
286
|
+
# @see http://msdn.microsoft.com/en-us/library/aa564009.aspx
|
|
287
|
+
def folders!(folders)
|
|
288
|
+
@nbuild.Folders { |_x|
|
|
289
|
+
folders.each do |fold|
|
|
290
|
+
fold.each_pair do |ftype, vars| # convenience, should only be one pair
|
|
291
|
+
ftype = "#{ftype}!".to_sym
|
|
292
|
+
if respond_to? ftype
|
|
293
|
+
send ftype, vars
|
|
294
|
+
else
|
|
295
|
+
raise Viewpoint::EWS::EwsNotImplemented,
|
|
296
|
+
"#{ftype} not implemented as a builder."
|
|
297
|
+
end
|
|
298
|
+
end
|
|
302
299
|
end
|
|
303
|
-
|
|
300
|
+
}
|
|
304
301
|
end
|
|
305
|
-
}
|
|
306
|
-
end
|
|
307
302
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
303
|
+
def folder!(folder, type = :Folder)
|
|
304
|
+
nbuild[NS_EWS_TYPES].send(type) { |_x|
|
|
305
|
+
folder.each_pair do |e, v|
|
|
306
|
+
ftype = "#{e}!".to_sym
|
|
307
|
+
if e == :folder_id
|
|
308
|
+
dispatch_folder_id!(v)
|
|
309
|
+
elsif respond_to?(ftype)
|
|
310
|
+
send ftype, v
|
|
311
|
+
else
|
|
312
|
+
raise Viewpoint::EWS::EwsNotImplemented,
|
|
313
|
+
"#{ftype} not implemented as a builder."
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
}
|
|
320
317
|
end
|
|
321
|
-
}
|
|
322
|
-
end
|
|
323
318
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
319
|
+
def calendar_folder!(folder)
|
|
320
|
+
folder! folder, :CalendarFolder
|
|
321
|
+
end
|
|
327
322
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
323
|
+
def contacts_folder!(folder)
|
|
324
|
+
folder! folder, :ContactsFolder
|
|
325
|
+
end
|
|
331
326
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
327
|
+
def search_folder!(folder)
|
|
328
|
+
folder! folder, :SearchFolder
|
|
329
|
+
end
|
|
335
330
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
331
|
+
def tasks_folder!(folder)
|
|
332
|
+
folder! folder, :TasksFolder
|
|
333
|
+
end
|
|
339
334
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
335
|
+
def display_name!(name)
|
|
336
|
+
nbuild[NS_EWS_TYPES].DisplayName(name)
|
|
337
|
+
end
|
|
343
338
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
339
|
+
# Build the AdditionalProperties element
|
|
340
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563810.aspx
|
|
341
|
+
def additional_properties!(addprops)
|
|
342
|
+
@nbuild[NS_EWS_TYPES].AdditionalProperties {
|
|
343
|
+
addprops.each_pair { |k, v|
|
|
344
|
+
dispatch_field_uri!({ k => v }, NS_EWS_TYPES)
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
end
|
|
353
348
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
349
|
+
# Build the Mailbox element.
|
|
350
|
+
# This element is commonly used for delegation. Typically passing an
|
|
351
|
+
# email_address is sufficient
|
|
352
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565036.aspx
|
|
353
|
+
# @param [Hash] mailbox A well-formated hash
|
|
354
|
+
def mailbox!(mbox)
|
|
355
|
+
nbuild[NS_EWS_TYPES].Mailbox {
|
|
356
|
+
name!(mbox[:name]) if mbox[:name]
|
|
357
|
+
email_address!(mbox[:email_address]) if mbox[:email_address]
|
|
358
|
+
address!(mbox[:address]) if mbox[:address] # for Availability query
|
|
359
|
+
routing_type!(mbox[:routing_type]) if mbox[:routing_type]
|
|
360
|
+
mailbox_type!(mbox[:mailbox_type]) if mbox[:mailbox_type]
|
|
361
|
+
item_id!(mbox[:item_id]) if mbox[:item_id]
|
|
362
|
+
}
|
|
363
|
+
end
|
|
369
364
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
365
|
+
def name!(name)
|
|
366
|
+
nbuild[NS_EWS_TYPES].Name(name)
|
|
367
|
+
end
|
|
373
368
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
369
|
+
def email_address!(email)
|
|
370
|
+
nbuild[NS_EWS_TYPES].EmailAddress(email)
|
|
371
|
+
end
|
|
377
372
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
373
|
+
def address!(email)
|
|
374
|
+
nbuild[NS_EWS_TYPES].Address(email)
|
|
375
|
+
end
|
|
381
376
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
377
|
+
# This is stupid. The only valid value is "SMTP"
|
|
378
|
+
def routing_type!(type)
|
|
379
|
+
nbuild[NS_EWS_TYPES].RoutingType(type)
|
|
380
|
+
end
|
|
386
381
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
382
|
+
def mailbox_type!(type)
|
|
383
|
+
nbuild[NS_EWS_TYPES].MailboxType(type)
|
|
384
|
+
end
|
|
390
385
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
386
|
+
def user_oof_settings!(opts)
|
|
387
|
+
nbuild[NS_EWS_TYPES].UserOofSettings {
|
|
388
|
+
nbuild.OofState(camel_case(opts[:oof_state]))
|
|
389
|
+
nbuild.ExternalAudience(camel_case(opts[:external_audience])) if opts[:external_audience]
|
|
390
|
+
duration!(opts[:duration]) if opts[:duration]
|
|
391
|
+
if opts[:external_reply]
|
|
392
|
+
nbuild.InternalReply {
|
|
393
|
+
nbuild.Message(opts[:internal_reply])
|
|
394
|
+
}
|
|
395
|
+
end
|
|
396
|
+
if opts[:external_reply]
|
|
397
|
+
nbuild.ExternalReply {
|
|
398
|
+
nbuild.Message(opts[:external_reply])
|
|
399
|
+
}
|
|
400
|
+
end
|
|
401
|
+
}
|
|
402
|
+
end
|
|
404
403
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
404
|
+
def duration!(opts)
|
|
405
|
+
nbuild.Duration {
|
|
406
|
+
nbuild.StartTime(format_time(opts[:start_time]))
|
|
407
|
+
nbuild.EndTime(format_time(opts[:end_time]))
|
|
408
|
+
}
|
|
409
|
+
end
|
|
411
410
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
411
|
+
def mailbox_data!(mailbox_data)
|
|
412
|
+
nbuild[NS_EWS_TYPES].MailboxData {
|
|
413
|
+
nbuild[NS_EWS_TYPES].Email do
|
|
414
|
+
mbox = mailbox_data[:email]
|
|
415
|
+
name!(mbox[:name]) if mbox[:name]
|
|
416
|
+
address!(mbox[:address]) if mbox[:address] # for Availability query
|
|
417
|
+
routing_type!(mbox[:routing_type]) if mbox[:routing_type]
|
|
418
|
+
end
|
|
419
|
+
nbuild[NS_EWS_TYPES].AttendeeType 'Required'
|
|
420
|
+
}
|
|
421
|
+
end
|
|
423
422
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
423
|
+
def free_busy_view_options!(opts)
|
|
424
|
+
nbuild[NS_EWS_TYPES].FreeBusyViewOptions {
|
|
425
|
+
nbuild[NS_EWS_TYPES].TimeWindow do
|
|
426
|
+
nbuild[NS_EWS_TYPES].StartTime(format_time(opts[:time_window][:start_time]))
|
|
427
|
+
nbuild[NS_EWS_TYPES].EndTime(format_time(opts[:time_window][:end_time]))
|
|
428
|
+
end
|
|
429
|
+
nbuild[NS_EWS_TYPES].RequestedView(camel_case(opts[:requested_view][:requested_free_busy_view]))
|
|
430
|
+
}
|
|
431
|
+
end
|
|
433
432
|
|
|
434
|
-
|
|
435
|
-
|
|
433
|
+
def suggestions_view_options!(opts); end
|
|
434
|
+
|
|
435
|
+
def time_zone!(zone)
|
|
436
|
+
zone ||= {}
|
|
437
|
+
zone = {
|
|
438
|
+
bias: zone[:bias] || 480,
|
|
439
|
+
standard_time: {
|
|
440
|
+
bias: 0,
|
|
441
|
+
time: '02:00:00',
|
|
442
|
+
day_order: 5,
|
|
443
|
+
month: 10,
|
|
444
|
+
day_of_week: 'Sunday'
|
|
445
|
+
}.merge(zone[:standard_time] || {}),
|
|
446
|
+
daylight_time: {
|
|
447
|
+
bias: -60,
|
|
448
|
+
time: '02:00:00',
|
|
449
|
+
day_order: 1,
|
|
450
|
+
month: 4,
|
|
451
|
+
day_of_week: 'Sunday'
|
|
452
|
+
}.merge(zone[:daylight_time] || {})
|
|
453
|
+
}
|
|
436
454
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
nbuild[NS_EWS_TYPES].TimeZone {
|
|
458
|
-
nbuild[NS_EWS_TYPES].Bias(zone[:bias])
|
|
459
|
-
nbuild[NS_EWS_TYPES].StandardTime {
|
|
460
|
-
nbuild[NS_EWS_TYPES].Bias(zone[:standard_time][:bias])
|
|
461
|
-
nbuild[NS_EWS_TYPES].Time(zone[:standard_time][:time])
|
|
462
|
-
nbuild[NS_EWS_TYPES].DayOrder(zone[:standard_time][:day_order])
|
|
463
|
-
nbuild[NS_EWS_TYPES].Month(zone[:standard_time][:month])
|
|
464
|
-
nbuild[NS_EWS_TYPES].DayOfWeek(zone[:standard_time][:day_of_week])
|
|
465
|
-
}
|
|
466
|
-
nbuild[NS_EWS_TYPES].DaylightTime {
|
|
467
|
-
nbuild[NS_EWS_TYPES].Bias(zone[:daylight_time][:bias])
|
|
468
|
-
nbuild[NS_EWS_TYPES].Time(zone[:daylight_time][:time])
|
|
469
|
-
nbuild[NS_EWS_TYPES].DayOrder(zone[:daylight_time][:day_order])
|
|
470
|
-
nbuild[NS_EWS_TYPES].Month(zone[:daylight_time][:month])
|
|
471
|
-
nbuild[NS_EWS_TYPES].DayOfWeek(zone[:daylight_time][:day_of_week])
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
end
|
|
455
|
+
nbuild[NS_EWS_TYPES].TimeZone {
|
|
456
|
+
nbuild[NS_EWS_TYPES].Bias(zone[:bias])
|
|
457
|
+
nbuild[NS_EWS_TYPES].StandardTime do
|
|
458
|
+
nbuild[NS_EWS_TYPES].Bias(zone[:standard_time][:bias])
|
|
459
|
+
nbuild[NS_EWS_TYPES].Time(zone[:standard_time][:time])
|
|
460
|
+
nbuild[NS_EWS_TYPES].DayOrder(zone[:standard_time][:day_order])
|
|
461
|
+
nbuild[NS_EWS_TYPES].Month(zone[:standard_time][:month])
|
|
462
|
+
nbuild[NS_EWS_TYPES].DayOfWeek(zone[:standard_time][:day_of_week])
|
|
463
|
+
end
|
|
464
|
+
nbuild[NS_EWS_TYPES].DaylightTime {
|
|
465
|
+
nbuild[NS_EWS_TYPES].Bias(zone[:daylight_time][:bias])
|
|
466
|
+
nbuild[NS_EWS_TYPES].Time(zone[:daylight_time][:time])
|
|
467
|
+
nbuild[NS_EWS_TYPES].DayOrder(zone[:daylight_time][:day_order])
|
|
468
|
+
nbuild[NS_EWS_TYPES].Month(zone[:daylight_time][:month])
|
|
469
|
+
nbuild[NS_EWS_TYPES].DayOfWeek(zone[:daylight_time][:day_of_week])
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
end
|
|
475
473
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
474
|
+
# Request all known time_zones from server
|
|
475
|
+
def get_server_time_zones!(get_time_zone_options)
|
|
476
|
+
nbuild[NS_EWS_MESSAGES].GetServerTimeZones('ReturnFullTimeZoneData' => get_time_zone_options[:full]) do
|
|
477
|
+
if get_time_zone_options[:ids]&.any?
|
|
478
|
+
nbuild[NS_EWS_MESSAGES].Ids do
|
|
479
|
+
get_time_zone_options[:ids].each do |id|
|
|
480
|
+
nbuild[NS_EWS_TYPES].Id id
|
|
481
|
+
end
|
|
482
|
+
end
|
|
483
483
|
end
|
|
484
484
|
end
|
|
485
485
|
end
|
|
486
|
-
end
|
|
487
|
-
end
|
|
488
486
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
487
|
+
# Specifies an optional time zone for the start time
|
|
488
|
+
# @param [Hash] attributes
|
|
489
|
+
# @option attributes :id [String] ID of the Microsoft well known time zone
|
|
490
|
+
# @option attributes :name [String] Optional name of the time zone
|
|
491
|
+
# @todo Implement sub elements Periods, TransitionsGroups and Transitions to override zone
|
|
492
|
+
# @see http://msdn.microsoft.com/en-us/library/exchange/dd899524.aspx
|
|
493
|
+
def start_time_zone!(zone)
|
|
494
|
+
attributes = {}
|
|
495
|
+
attributes['Id'] = zone[:id] if zone[:id]
|
|
496
|
+
attributes['Name'] = zone[:name] if zone[:name]
|
|
497
|
+
nbuild[NS_EWS_TYPES].StartTimeZone(attributes)
|
|
498
|
+
end
|
|
501
499
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
500
|
+
# Specifies an optional time zone for the end time
|
|
501
|
+
# @param [Hash] attributes
|
|
502
|
+
# @option attributes :id [String] ID of the Microsoft well known time zone
|
|
503
|
+
# @option attributes :name [String] Optional name of the time zone
|
|
504
|
+
# @todo Implement sub elements Periods, TransitionsGroups and Transitions to override zone
|
|
505
|
+
# @see http://msdn.microsoft.com/en-us/library/exchange/dd899434.aspx
|
|
506
|
+
def end_time_zone!(zone)
|
|
507
|
+
attributes = {}
|
|
508
|
+
attributes['Id'] = zone[:id] if zone[:id]
|
|
509
|
+
attributes['Name'] = zone[:name] if zone[:name]
|
|
510
|
+
nbuild[NS_EWS_TYPES].EndTimeZone(attributes)
|
|
511
|
+
end
|
|
514
512
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
513
|
+
# Specify a time zone
|
|
514
|
+
# @todo Implement subelements Periods, TransitionsGroups and Transitions to override zone
|
|
515
|
+
# @see http://msdn.microsoft.com/en-us/library/exchange/dd899488.aspx
|
|
516
|
+
def time_zone_definition!(zone)
|
|
517
|
+
attributes = { 'Id' => zone[:id] }
|
|
518
|
+
attributes['Name'] = zone[:name] if zone[:name]
|
|
519
|
+
nbuild[NS_EWS_TYPES].TimeZoneDefinition(attributes)
|
|
520
|
+
end
|
|
523
521
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
522
|
+
# Build the Restriction element
|
|
523
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563791.aspx
|
|
524
|
+
# @param [Hash] restriction a well-formatted Hash that can be fed to #build_xml!
|
|
525
|
+
def restriction!(restriction)
|
|
526
|
+
@nbuild[NS_EWS_MESSAGES].Restriction {
|
|
527
|
+
restriction.each_pair do |k, v|
|
|
528
|
+
send normalize_type(k), v
|
|
529
|
+
end
|
|
530
|
+
}
|
|
531
531
|
end
|
|
532
|
-
}
|
|
533
|
-
end
|
|
534
532
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
533
|
+
def and_r(expr)
|
|
534
|
+
and_or('And', expr)
|
|
535
|
+
end
|
|
538
536
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
537
|
+
def or_r(expr)
|
|
538
|
+
and_or('Or', expr)
|
|
539
|
+
end
|
|
542
540
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
541
|
+
def and_or(type, expr)
|
|
542
|
+
@nbuild[NS_EWS_TYPES].send(type) {
|
|
543
|
+
expr.each do |e|
|
|
544
|
+
type = e.keys.first
|
|
545
|
+
send normalize_type(type), e[type]
|
|
546
|
+
end
|
|
547
|
+
}
|
|
548
548
|
end
|
|
549
|
-
}
|
|
550
|
-
end
|
|
551
549
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
550
|
+
def not_r(expr)
|
|
551
|
+
@nbuild[NS_EWS_TYPES].Not {
|
|
552
|
+
type = expr.keys.first
|
|
553
|
+
send(type, expr[type])
|
|
554
|
+
}
|
|
555
|
+
end
|
|
558
556
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
557
|
+
def contains(expr)
|
|
558
|
+
@nbuild[NS_EWS_TYPES].Contains(
|
|
559
|
+
'ContainmentMode' => expr.delete(:containment_mode),
|
|
560
|
+
'ContainmentComparison' => expr.delete(:containment_comparison)
|
|
561
|
+
) {
|
|
562
|
+
c = expr.delete(:constant) # remove constant 1st for ordering
|
|
563
|
+
type = expr.keys.first
|
|
564
|
+
send(type, expr[type])
|
|
565
|
+
constant(c)
|
|
566
|
+
}
|
|
567
|
+
end
|
|
569
568
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
569
|
+
def excludes(expr)
|
|
570
|
+
@nbuild[NS_EWS_TYPES].Excludes {
|
|
571
|
+
b = expr.delete(:bitmask) # remove bitmask 1st for ordering
|
|
572
|
+
type = expr.keys.first
|
|
573
|
+
send(type, expr[type])
|
|
574
|
+
bitmask(b)
|
|
575
|
+
}
|
|
576
|
+
end
|
|
578
577
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
578
|
+
def exists(expr)
|
|
579
|
+
@nbuild[NS_EWS_TYPES].Exists {
|
|
580
|
+
type = expr.keys.first
|
|
581
|
+
send(type, expr[type])
|
|
582
|
+
}
|
|
583
|
+
end
|
|
585
584
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
585
|
+
def bitmask(expr)
|
|
586
|
+
@nbuild[NS_EWS_TYPES].Bitmask('Value' => expr[:value])
|
|
587
|
+
end
|
|
589
588
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
589
|
+
# rubocop:disable Naming/PredicatePrefix -- public API name
|
|
590
|
+
def is_equal_to(expr)
|
|
591
|
+
restriction_compare('IsEqualTo', expr)
|
|
592
|
+
end
|
|
593
593
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
594
|
+
def is_greater_than(expr)
|
|
595
|
+
restriction_compare('IsGreaterThan', expr)
|
|
596
|
+
end
|
|
597
597
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
598
|
+
def is_greater_than_or_equal_to(expr)
|
|
599
|
+
restriction_compare('IsGreaterThanOrEqualTo', expr)
|
|
600
|
+
end
|
|
601
601
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
602
|
+
def is_less_than(expr)
|
|
603
|
+
restriction_compare('IsLessThan', expr)
|
|
604
|
+
end
|
|
605
605
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
606
|
+
def is_less_than_or_equal_to(expr)
|
|
607
|
+
restriction_compare('IsLessThanOrEqualTo', expr)
|
|
608
|
+
end
|
|
609
609
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
610
|
+
def is_not_equal_to(expr)
|
|
611
|
+
restriction_compare('IsNotEqualTo', expr)
|
|
612
|
+
end
|
|
613
|
+
# rubocop:enable Naming/PredicatePrefix
|
|
614
|
+
|
|
615
|
+
def restriction_compare(type, expr)
|
|
616
|
+
nbuild[NS_EWS_TYPES].send(type) {
|
|
617
|
+
expr.each do |e|
|
|
618
|
+
e.each_pair do |k, v|
|
|
619
|
+
send(k, v)
|
|
620
|
+
end
|
|
621
|
+
end
|
|
622
|
+
}
|
|
623
|
+
end
|
|
613
624
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
expr.each do |e|
|
|
617
|
-
e.each_pair do |k,v|
|
|
618
|
-
self.send(k, v)
|
|
619
|
-
end
|
|
625
|
+
def ews_types_builder
|
|
626
|
+
nbuild[NS_EWS_TYPES]
|
|
620
627
|
end
|
|
621
|
-
}
|
|
622
|
-
end
|
|
623
628
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
629
|
+
def field_uRI(expr) # rubocop:disable Naming/MethodName -- public API name
|
|
630
|
+
value = expr.is_a?(Hash) ? (expr[:field_uRI] || expr[:field_uri]) : expr
|
|
631
|
+
ews_types_builder.FieldURI('FieldURI' => value)
|
|
632
|
+
end
|
|
627
633
|
|
|
628
|
-
|
|
629
|
-
value = expr.is_a?(Hash) ? (expr[:field_uRI] || expr[:field_uri]) : expr
|
|
630
|
-
ews_types_builder.FieldURI('FieldURI' => value)
|
|
631
|
-
end
|
|
634
|
+
alias field_uri field_uRI
|
|
632
635
|
|
|
633
|
-
|
|
636
|
+
def indexed_field_uRI(expr) # rubocop:disable Naming/MethodName -- public API name
|
|
637
|
+
nbuild[NS_EWS_TYPES].IndexedFieldURI(
|
|
638
|
+
'FieldURI' => expr[:field_uRI] || expr[:field_uri],
|
|
639
|
+
'FieldIndex' => expr[:field_index]
|
|
640
|
+
)
|
|
641
|
+
end
|
|
634
642
|
|
|
635
|
-
|
|
636
|
-
nbuild[NS_EWS_TYPES].IndexedFieldURI(
|
|
637
|
-
'FieldURI' => (expr[:field_uRI] || expr[:field_uri]),
|
|
638
|
-
'FieldIndex' => expr[:field_index]
|
|
639
|
-
)
|
|
640
|
-
end
|
|
643
|
+
alias indexed_field_uri indexed_field_uRI
|
|
641
644
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
645
|
+
def extended_field_uRI(expr) # rubocop:disable Naming/MethodName -- public API name
|
|
646
|
+
nbuild[NS_EWS_TYPES].ExtendedFieldURI {
|
|
647
|
+
if expr[:distinguished_property_set_id]
|
|
648
|
+
nbuild.parent['DistinguishedPropertySetId'] =
|
|
649
|
+
expr[:distinguished_property_set_id]
|
|
650
|
+
end
|
|
651
|
+
nbuild.parent['PropertySetId'] = expr[:property_set_id] if expr[:property_set_id]
|
|
652
|
+
nbuild.parent['PropertyTag'] = expr[:property_tag] if expr[:property_tag]
|
|
653
|
+
nbuild.parent['PropertyName'] = expr[:property_name] if expr[:property_name]
|
|
654
|
+
nbuild.parent['PropertyId'] = expr[:property_id] if expr[:property_id]
|
|
655
|
+
nbuild.parent['PropertyType'] = expr[:property_type] if expr[:property_type]
|
|
656
|
+
}
|
|
657
|
+
end
|
|
654
658
|
|
|
655
|
-
|
|
659
|
+
alias extended_field_uri extended_field_uRI
|
|
656
660
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
661
|
+
def extended_properties!(eprops)
|
|
662
|
+
eprops.each { |ep| extended_property!(ep) }
|
|
663
|
+
end
|
|
660
664
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
665
|
+
def extended_property!(eprop)
|
|
666
|
+
nbuild[NS_EWS_TYPES].ExtendedProperty {
|
|
667
|
+
key = eprop.keys.grep(/extended/i).first
|
|
668
|
+
dispatch_field_uri!({ key => eprop[key] }, NS_EWS_TYPES)
|
|
669
|
+
if eprop[:values]
|
|
670
|
+
nbuild.Values {
|
|
671
|
+
eprop[:values].each do |v|
|
|
672
|
+
value! v
|
|
673
|
+
end
|
|
674
|
+
}
|
|
675
|
+
elsif eprop[:value]
|
|
676
|
+
value! eprop[:value]
|
|
669
677
|
end
|
|
670
678
|
}
|
|
671
|
-
elsif eprop[:value]
|
|
672
|
-
value! eprop[:value]
|
|
673
679
|
end
|
|
674
|
-
}
|
|
675
|
-
end
|
|
676
680
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
681
|
+
def value!(val)
|
|
682
|
+
nbuild[NS_EWS_TYPES].Value(val)
|
|
683
|
+
end
|
|
680
684
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
685
|
+
def field_uRI_or_constant(expr) # rubocop:disable Naming/MethodName -- public API name
|
|
686
|
+
nbuild[NS_EWS_TYPES].FieldURIOrConstant {
|
|
687
|
+
type = expr.keys.first
|
|
688
|
+
send(type, expr[type])
|
|
689
|
+
}
|
|
690
|
+
end
|
|
687
691
|
|
|
688
|
-
|
|
692
|
+
alias field_uri_or_constant field_uRI_or_constant
|
|
689
693
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
694
|
+
def constant(expr)
|
|
695
|
+
nbuild[NS_EWS_TYPES].Constant('Value' => expr[:value])
|
|
696
|
+
end
|
|
693
697
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
698
|
+
# Build the CalendarView element
|
|
699
|
+
def calendar_view!(cal_view)
|
|
700
|
+
attribs = {}
|
|
701
|
+
cal_view.each_pair do |k, v| attribs[camel_case(k)] = v.to_s end
|
|
702
|
+
@nbuild[NS_EWS_MESSAGES].CalendarView(attribs)
|
|
703
|
+
end
|
|
700
704
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
705
|
+
# Build the ContactsView element
|
|
706
|
+
def contacts_view!(con_view)
|
|
707
|
+
attribs = {}
|
|
708
|
+
con_view.each_pair do |k, v| attribs[camel_case(k)] = v.to_s end
|
|
709
|
+
@nbuild[NS_EWS_MESSAGES].ContactsView(attribs)
|
|
710
|
+
end
|
|
707
711
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
712
|
+
# @see https://msdn.microsoft.com/en-us/library/aa565683(v=exchg.140).aspx
|
|
713
|
+
def categories!(category)
|
|
714
|
+
@nbuild[NS_EWS_TYPES].Categories {
|
|
715
|
+
@nbuild[NS_EWS_TYPES].String(category)
|
|
716
|
+
}
|
|
717
|
+
end
|
|
714
718
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
719
|
+
# @see http://msdn.microsoft.com/en-us/library/aa579678(v=EXCHG.140).aspx
|
|
720
|
+
def event_types!(evtypes)
|
|
721
|
+
@nbuild[NS_EWS_TYPES].EventTypes {
|
|
722
|
+
evtypes.each do |et|
|
|
723
|
+
@nbuild[NS_EWS_TYPES].EventType(camel_case(et))
|
|
724
|
+
end
|
|
725
|
+
}
|
|
720
726
|
end
|
|
721
|
-
}
|
|
722
|
-
end
|
|
723
727
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565886(v=EXCHG.140).aspx
|
|
729
|
+
def watermark!(watermark, namespace = NS_EWS_TYPES)
|
|
730
|
+
@nbuild[namespace].Watermark(watermark)
|
|
731
|
+
end
|
|
728
732
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565201(v=EXCHG.140).aspx
|
|
734
|
+
def timeout!(tout)
|
|
735
|
+
@nbuild[NS_EWS_TYPES].Timeout(tout)
|
|
736
|
+
end
|
|
733
737
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
+
# @see http://msdn.microsoft.com/en-us/library/aa564048(v=EXCHG.140).aspx
|
|
739
|
+
def status_frequency!(freq)
|
|
740
|
+
@nbuild[NS_EWS_TYPES].StatusFrequency(freq)
|
|
741
|
+
end
|
|
738
742
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
+
# @see http://msdn.microsoft.com/en-us/library/aa566309(v=EXCHG.140).aspx
|
|
744
|
+
def uRL!(url) # rubocop:disable Naming/MethodName -- public API name
|
|
745
|
+
@nbuild[NS_EWS_TYPES].URL(url)
|
|
746
|
+
end
|
|
743
747
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563790(v=EXCHG.140).aspx
|
|
749
|
+
def subscription_id!(subid)
|
|
750
|
+
@nbuild.SubscriptionId(subid)
|
|
751
|
+
end
|
|
748
752
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
753
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563455(v=EXCHG.140).aspx
|
|
754
|
+
def pull_subscription_request(subopts)
|
|
755
|
+
subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
|
|
756
|
+
@nbuild.PullSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
|
|
757
|
+
folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
|
|
758
|
+
event_types!(subopts[:event_types]) if subopts[:event_types]
|
|
759
|
+
watermark!(subopts[:watermark]) if subopts[:watermark]
|
|
760
|
+
timeout!(subopts[:timeout]) if subopts[:timeout]
|
|
761
|
+
}
|
|
762
|
+
end
|
|
759
763
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
764
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563599(v=EXCHG.140).aspx
|
|
765
|
+
def push_subscription_request(subopts)
|
|
766
|
+
subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
|
|
767
|
+
@nbuild.PushSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
|
|
768
|
+
folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
|
|
769
|
+
event_types!(subopts[:event_types]) if subopts[:event_types]
|
|
770
|
+
watermark!(subopts[:watermark]) if subopts[:watermark]
|
|
771
|
+
status_frequency!(subopts[:status_frequency]) if subopts[:status_frequency]
|
|
772
|
+
uRL!(subopts[:uRL]) if subopts[:uRL]
|
|
773
|
+
}
|
|
774
|
+
end
|
|
771
775
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
776
|
+
# @see http://msdn.microsoft.com/en-us/library/ff406182(v=EXCHG.140).aspx
|
|
777
|
+
def streaming_subscription_request(subopts)
|
|
778
|
+
subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
|
|
779
|
+
@nbuild.StreamingSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
|
|
780
|
+
folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
|
|
781
|
+
event_types!(subopts[:event_types]) if subopts[:event_types]
|
|
782
|
+
}
|
|
783
|
+
end
|
|
780
784
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565970(v=EXCHG.140).aspx
|
|
786
|
+
def sync_state!(syncstate)
|
|
787
|
+
@nbuild.SyncState(syncstate)
|
|
788
|
+
end
|
|
789
|
+
|
|
790
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563785(v=EXCHG.140).aspx
|
|
791
|
+
def ignore!(item_ids)
|
|
792
|
+
@nbuild.Ignore {
|
|
793
|
+
item_ids.each do |iid|
|
|
794
|
+
item_id!(iid)
|
|
795
|
+
end
|
|
796
|
+
}
|
|
797
|
+
end
|
|
785
798
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
item_ids.each do |iid|
|
|
790
|
-
item_id!(iid)
|
|
799
|
+
# @see http://msdn.microsoft.com/en-us/library/aa566325(v=EXCHG.140).aspx
|
|
800
|
+
def max_changes_returned!(cnum)
|
|
801
|
+
@nbuild[NS_EWS_MESSAGES].MaxChangesReturned(cnum)
|
|
791
802
|
end
|
|
792
|
-
}
|
|
793
|
-
end
|
|
794
803
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
804
|
+
# @see http://msdn.microsoft.com/en-us/library/dd899531(v=EXCHG.140).aspx
|
|
805
|
+
def sync_scope!(scope)
|
|
806
|
+
@nbuild.SyncScope(scope)
|
|
807
|
+
end
|
|
799
808
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
809
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580758(v=EXCHG.140).aspx
|
|
810
|
+
def saved_item_folder_id!(fid)
|
|
811
|
+
@nbuild.SavedItemFolderId {
|
|
812
|
+
dispatch_folder_id!(fid)
|
|
813
|
+
}
|
|
814
|
+
end
|
|
804
815
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
816
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565652(v=exchg.140).aspx
|
|
817
|
+
def item!(item)
|
|
818
|
+
nbuild.Item {
|
|
819
|
+
item.each_pair { |k, v|
|
|
820
|
+
send("#{k}!", v)
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
end
|
|
811
824
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
825
|
+
def message!(item)
|
|
826
|
+
nbuild[NS_EWS_TYPES].Message {
|
|
827
|
+
extended_properties! item.delete(:extended_properties) if item[:extended_properties]
|
|
828
|
+
item.each_pair { |k, v|
|
|
829
|
+
send("#{k}!", v)
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
end
|
|
820
833
|
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
if item[:extended_properties]
|
|
824
|
-
extended_properties! item.delete(:extended_properties)
|
|
834
|
+
def is_read!(read) # rubocop:disable Naming/PredicatePrefix -- public API name
|
|
835
|
+
nbuild[NS_EWS_TYPES].IsRead(read)
|
|
825
836
|
end
|
|
826
|
-
item.each_pair {|k,v|
|
|
827
|
-
self.send("#{k}!", v)
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
end
|
|
831
837
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
838
|
+
def calendar_item!(item)
|
|
839
|
+
nbuild[NS_EWS_TYPES].CalendarItem {
|
|
840
|
+
item.each_pair { |k, v|
|
|
841
|
+
send("#{k}!", v)
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
end
|
|
835
845
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
self.send("#{k}!", v)
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
end
|
|
846
|
+
def calendar_item_type!(type)
|
|
847
|
+
nbuild[NS_EWS_TYPES].CalendarItemType(type)
|
|
848
|
+
end
|
|
843
849
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
850
|
+
def recurrence!(item)
|
|
851
|
+
nbuild[NS_EWS_TYPES].Recurrence {
|
|
852
|
+
item.each_pair { |k, v|
|
|
853
|
+
send("#{k}!", v)
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
end
|
|
847
857
|
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
858
|
+
def daily_recurrence!(item)
|
|
859
|
+
nbuild[NS_EWS_TYPES].DailyRecurrence {
|
|
860
|
+
item.each_pair { |k, v|
|
|
861
|
+
send("#{k}!", v)
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
end
|
|
855
865
|
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
866
|
+
def weekly_recurrence!(item)
|
|
867
|
+
nbuild[NS_EWS_TYPES].WeeklyRecurrence {
|
|
868
|
+
item.each_pair { |k, v|
|
|
869
|
+
send("#{k}!", v)
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
end
|
|
863
873
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
self.send("#{k}!", v)
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
end
|
|
874
|
+
def interval!(num)
|
|
875
|
+
nbuild[NS_EWS_TYPES].Interval(num)
|
|
876
|
+
end
|
|
871
877
|
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
878
|
+
def no_end_recurrence!(item)
|
|
879
|
+
nbuild[NS_EWS_TYPES].NoEndRecurrence {
|
|
880
|
+
item.each_pair { |k, v|
|
|
881
|
+
send("#{k}!", v)
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
end
|
|
875
885
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
886
|
+
def numbered_recurrence!(item)
|
|
887
|
+
nbuild[NS_EWS_TYPES].NumberedRecurrence {
|
|
888
|
+
item.each_pair { |k, v|
|
|
889
|
+
send("#{k}!", v)
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
end
|
|
883
893
|
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
self.send("#{k}!", v)
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
end
|
|
894
|
+
def number_of_occurrences!(count)
|
|
895
|
+
nbuild[NS_EWS_TYPES].NumberOfOccurrences(count)
|
|
896
|
+
end
|
|
891
897
|
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
898
|
+
def task!(item)
|
|
899
|
+
nbuild[NS_EWS_TYPES].Task {
|
|
900
|
+
item.each_pair { |k, v|
|
|
901
|
+
send("#{k}!", v)
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
end
|
|
895
905
|
|
|
906
|
+
def forward_item!(item)
|
|
907
|
+
nbuild[NS_EWS_TYPES].ForwardItem {
|
|
908
|
+
item.each_pair { |k, v|
|
|
909
|
+
send("#{k}!", v)
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
end
|
|
896
913
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
914
|
+
def reply_to_item!(item)
|
|
915
|
+
nbuild[NS_EWS_TYPES].ReplyToItem {
|
|
916
|
+
item.each_pair { |k, v|
|
|
917
|
+
send("#{k}!", v)
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
end
|
|
904
921
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
922
|
+
def reply_all_to_item!(item)
|
|
923
|
+
nbuild[NS_EWS_TYPES].ReplyAllToItem {
|
|
924
|
+
item.each_pair { |k, v|
|
|
925
|
+
send("#{k}!", v)
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
end
|
|
912
929
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
end
|
|
930
|
+
def reference_item_id!(id)
|
|
931
|
+
nbuild[NS_EWS_TYPES].ReferenceItemId { |x|
|
|
932
|
+
x.parent['Id'] = id[:id]
|
|
933
|
+
x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
|
|
934
|
+
}
|
|
935
|
+
end
|
|
920
936
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
self.send("#{k}!", v)
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
end
|
|
937
|
+
def subject!(sub)
|
|
938
|
+
nbuild[NS_EWS_TYPES].Subject(sub)
|
|
939
|
+
end
|
|
928
940
|
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
|
|
933
|
-
}
|
|
934
|
-
end
|
|
941
|
+
def importance!(sub)
|
|
942
|
+
nbuild[NS_EWS_TYPES].Importance(sub)
|
|
943
|
+
end
|
|
935
944
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
945
|
+
def body!(body)
|
|
946
|
+
nbuild[NS_EWS_TYPES].Body(body[:text]) { |x|
|
|
947
|
+
x.parent['BodyType'] = body[:body_type] if body[:body_type]
|
|
948
|
+
}
|
|
949
|
+
end
|
|
939
950
|
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
951
|
+
# @see https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/mimecontent
|
|
952
|
+
def mime_content!(mime_content)
|
|
953
|
+
nbuild[NS_EWS_TYPES].MimeContent(mime_content[:text]) { |x|
|
|
954
|
+
x.parent['CharacterSet'] = mime_content[:character_set] if mime_content[:character_set]
|
|
955
|
+
}
|
|
956
|
+
end
|
|
943
957
|
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
958
|
+
def new_body_content!(body)
|
|
959
|
+
nbuild[NS_EWS_TYPES].NewBodyContent(body[:text]) { |x|
|
|
960
|
+
x.parent['BodyType'] = body[:body_type] if body[:body_type]
|
|
961
|
+
}
|
|
962
|
+
end
|
|
949
963
|
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
964
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563719(v=exchg.140).aspx
|
|
965
|
+
# @param [Array] r An array of Mailbox type hashes to send to #mailbox!
|
|
966
|
+
def to_recipients!(recipients)
|
|
967
|
+
nbuild[NS_EWS_TYPES].ToRecipients {
|
|
968
|
+
recipients.each { |mbox| mailbox!(mbox[:mailbox]) }
|
|
969
|
+
}
|
|
970
|
+
end
|
|
955
971
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
}
|
|
962
|
-
end
|
|
972
|
+
def cc_recipients!(recipients)
|
|
973
|
+
nbuild[NS_EWS_TYPES].CcRecipients {
|
|
974
|
+
recipients.each { |mbox| mailbox!(mbox[:mailbox]) }
|
|
975
|
+
}
|
|
976
|
+
end
|
|
963
977
|
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
978
|
+
def bcc_recipients!(recipients)
|
|
979
|
+
nbuild[NS_EWS_TYPES].BccRecipients {
|
|
980
|
+
recipients.each { |mbox| mailbox!(mbox[:mailbox]) }
|
|
981
|
+
}
|
|
982
|
+
end
|
|
969
983
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
984
|
+
def from!(sender)
|
|
985
|
+
nbuild[NS_EWS_TYPES].From {
|
|
986
|
+
mailbox! sender
|
|
987
|
+
}
|
|
988
|
+
end
|
|
975
989
|
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
990
|
+
def required_attendees!(attendees)
|
|
991
|
+
nbuild[NS_EWS_TYPES].RequiredAttendees {
|
|
992
|
+
attendees.each { |a| attendee!(a[:attendee]) }
|
|
993
|
+
}
|
|
994
|
+
end
|
|
981
995
|
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
996
|
+
def optional_attendees!(attendees)
|
|
997
|
+
nbuild[NS_EWS_TYPES].OptionalAttendees {
|
|
998
|
+
attendees.each { |a| attendee!(a[:attendee]) }
|
|
999
|
+
}
|
|
1000
|
+
end
|
|
987
1001
|
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1002
|
+
def resources!(attendees)
|
|
1003
|
+
nbuild[NS_EWS_TYPES].Resources {
|
|
1004
|
+
attendees.each { |a| attendee!(a[:attendee]) }
|
|
1005
|
+
}
|
|
1006
|
+
end
|
|
993
1007
|
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1008
|
+
# @todo support ResponseType, LastResponseTime: http://msdn.microsoft.com/en-us/library/aa580339.aspx
|
|
1009
|
+
def attendee!(attendee)
|
|
1010
|
+
nbuild[NS_EWS_TYPES].Attendee {
|
|
1011
|
+
mailbox!(attendee[:mailbox])
|
|
1012
|
+
}
|
|
1013
|
+
end
|
|
999
1014
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
mailbox!(a[:mailbox])
|
|
1004
|
-
}
|
|
1005
|
-
end
|
|
1015
|
+
def start!(start_time)
|
|
1016
|
+
nbuild[NS_EWS_TYPES].Start(start_time[:text])
|
|
1017
|
+
end
|
|
1006
1018
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1019
|
+
def end!(end_time)
|
|
1020
|
+
nbuild[NS_EWS_TYPES].End(end_time[:text])
|
|
1021
|
+
end
|
|
1010
1022
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1023
|
+
def start_date!(start_date)
|
|
1024
|
+
nbuild[NS_EWS_TYPES].StartDate start_date[:text]
|
|
1025
|
+
end
|
|
1014
1026
|
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1027
|
+
def due_date!(due_date)
|
|
1028
|
+
nbuild[NS_EWS_TYPES].DueDate format_time(due_date[:text])
|
|
1029
|
+
end
|
|
1018
1030
|
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1031
|
+
def location!(loc)
|
|
1032
|
+
nbuild[NS_EWS_TYPES].Location(loc)
|
|
1033
|
+
end
|
|
1022
1034
|
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1035
|
+
def is_all_day_event!(all_day) # rubocop:disable Naming/PredicatePrefix -- public API name
|
|
1036
|
+
nbuild[NS_EWS_TYPES].IsAllDayEvent(all_day)
|
|
1037
|
+
end
|
|
1026
1038
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1039
|
+
def is_response_requested!(response_requested) # rubocop:disable Naming/PredicatePrefix -- public API name
|
|
1040
|
+
nbuild[NS_EWS_TYPES].IsResponseRequested(response_requested)
|
|
1041
|
+
end
|
|
1030
1042
|
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1043
|
+
def reminder_is_set!(reminder)
|
|
1044
|
+
nbuild[NS_EWS_TYPES].ReminderIsSet reminder
|
|
1045
|
+
end
|
|
1034
1046
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1047
|
+
def reminder_due_by!(date)
|
|
1048
|
+
nbuild[NS_EWS_TYPES].ReminderDueBy format_time(date)
|
|
1049
|
+
end
|
|
1038
1050
|
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1051
|
+
def reminder_minutes_before_start!(minutes)
|
|
1052
|
+
nbuild[NS_EWS_TYPES].ReminderMinutesBeforeStart minutes
|
|
1053
|
+
end
|
|
1042
1054
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1055
|
+
# @see http://msdn.microsoft.com/en-us/library/aa566143(v=exchg.150).aspx
|
|
1056
|
+
# possible values Exchange Server 2010 = [Free, Tentative, Busy, OOF, NoData]
|
|
1057
|
+
# Exchange Server 2013 = [Free, Tentative, Busy, OOF, WorkingElsewhere, NoData]
|
|
1058
|
+
def legacy_free_busy_status!(state)
|
|
1059
|
+
nbuild[NS_EWS_TYPES].LegacyFreeBusyStatus(state)
|
|
1060
|
+
end
|
|
1046
1061
|
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1062
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565428(v=exchg.140).aspx
|
|
1063
|
+
def item_changes!(changes)
|
|
1064
|
+
nbuild.ItemChanges {
|
|
1065
|
+
changes.each do |chg|
|
|
1066
|
+
item_change!(chg)
|
|
1067
|
+
end
|
|
1068
|
+
}
|
|
1069
|
+
end
|
|
1053
1070
|
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1071
|
+
# @see http://msdn.microsoft.com/en-us/library/aa581081(v=exchg.140).aspx
|
|
1072
|
+
def item_change!(change)
|
|
1073
|
+
@nbuild[NS_EWS_TYPES].ItemChange {
|
|
1074
|
+
updates = change.delete(:updates) # Remove updates so dispatch_item_id works correctly
|
|
1075
|
+
dispatch_item_id!(change)
|
|
1076
|
+
updates!(updates)
|
|
1077
|
+
}
|
|
1059
1078
|
end
|
|
1060
|
-
}
|
|
1061
|
-
end
|
|
1062
1079
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1080
|
+
# @see http://msdn.microsoft.com/en-us/library/aa581074(v=exchg.140).aspx
|
|
1081
|
+
def updates!(updates)
|
|
1082
|
+
@nbuild[NS_EWS_TYPES].Updates {
|
|
1083
|
+
updates.each do |update|
|
|
1084
|
+
dispatch_update_type!(update)
|
|
1085
|
+
end
|
|
1086
|
+
}
|
|
1087
|
+
end
|
|
1071
1088
|
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1089
|
+
# @see http://msdn.microsoft.com/en-us/library/aa581317(v=exchg.140).aspx
|
|
1090
|
+
def append_to_item_field!(upd)
|
|
1091
|
+
uri = upd.select { |k, _v| k =~ /_uri/i }
|
|
1092
|
+
raise EwsBadArgumentError, 'Bad argument given for AppendToItemField.' if uri.keys.length != 1
|
|
1093
|
+
|
|
1094
|
+
upd.delete(uri.keys.first)
|
|
1095
|
+
@nbuild.AppendToItemField {
|
|
1096
|
+
dispatch_field_uri!(uri)
|
|
1097
|
+
dispatch_field_item!(upd)
|
|
1098
|
+
}
|
|
1077
1099
|
end
|
|
1078
|
-
}
|
|
1079
|
-
end
|
|
1080
1100
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
upd.delete(uri.keys.first)
|
|
1086
|
-
@nbuild.AppendToItemField {
|
|
1087
|
-
dispatch_field_uri!(uri)
|
|
1088
|
-
dispatch_field_item!(upd)
|
|
1089
|
-
}
|
|
1090
|
-
end
|
|
1101
|
+
# @see http://msdn.microsoft.com/en-us/library/aa581487(v=exchg.140).aspx
|
|
1102
|
+
def set_item_field!(upd)
|
|
1103
|
+
uri = upd.select { |k, _v| k =~ /_uri/i }
|
|
1104
|
+
raise EwsBadArgumentError, 'Bad argument given for SetItemField.' if uri.keys.length != 1
|
|
1091
1105
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
dispatch_field_uri!(uri, NS_EWS_TYPES)
|
|
1099
|
-
dispatch_field_item!(upd, NS_EWS_TYPES)
|
|
1100
|
-
}
|
|
1101
|
-
end
|
|
1106
|
+
upd.delete(uri.keys.first)
|
|
1107
|
+
@nbuild[NS_EWS_TYPES].SetItemField {
|
|
1108
|
+
dispatch_field_uri!(uri, NS_EWS_TYPES)
|
|
1109
|
+
dispatch_field_item!(upd, NS_EWS_TYPES)
|
|
1110
|
+
}
|
|
1111
|
+
end
|
|
1102
1112
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
@nbuild[NS_EWS_TYPES].DeleteItemField {
|
|
1108
|
-
dispatch_field_uri!(uri, NS_EWS_TYPES)
|
|
1109
|
-
}
|
|
1110
|
-
end
|
|
1113
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580330(v=exchg.140).aspx
|
|
1114
|
+
def delete_item_field!(upd)
|
|
1115
|
+
uri = upd.select { |k, _v| k =~ /_uri/i }
|
|
1116
|
+
raise EwsBadArgumentError, 'Bad argument given for SetItemField.' if uri.keys.length != 1
|
|
1111
1117
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1118
|
+
@nbuild[NS_EWS_TYPES].DeleteItemField {
|
|
1119
|
+
dispatch_field_uri!(uri, NS_EWS_TYPES)
|
|
1120
|
+
}
|
|
1121
|
+
end
|
|
1116
1122
|
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
@nbuild[NS_EWS_TYPES].IsInline(true)
|
|
1122
|
-
@nbuild[NS_EWS_TYPES].Content(fa.content)
|
|
1123
|
-
}
|
|
1124
|
-
end
|
|
1123
|
+
# @see http://msdn.microsoft.com/en-us/library/ff709497(v=exchg.140).aspx
|
|
1124
|
+
def return_new_item_ids!(retval)
|
|
1125
|
+
@nbuild.ReturnNewItemIds(retval)
|
|
1126
|
+
end
|
|
1125
1127
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1128
|
+
def inline_attachment!(attachment)
|
|
1129
|
+
@nbuild[NS_EWS_TYPES].FileAttachment {
|
|
1130
|
+
@nbuild[NS_EWS_TYPES].Name(attachment.name)
|
|
1131
|
+
@nbuild[NS_EWS_TYPES].ContentId(attachment.name)
|
|
1132
|
+
@nbuild[NS_EWS_TYPES].IsInline(true)
|
|
1133
|
+
@nbuild[NS_EWS_TYPES].Content(attachment.content)
|
|
1134
|
+
}
|
|
1135
|
+
end
|
|
1132
1136
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
}
|
|
1140
|
-
end
|
|
1137
|
+
def file_attachment!(attachment)
|
|
1138
|
+
@nbuild[NS_EWS_TYPES].FileAttachment {
|
|
1139
|
+
@nbuild[NS_EWS_TYPES].Name(attachment.name)
|
|
1140
|
+
@nbuild[NS_EWS_TYPES].Content(attachment.content)
|
|
1141
|
+
}
|
|
1142
|
+
end
|
|
1141
1143
|
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1144
|
+
def item_attachment!(attachment)
|
|
1145
|
+
@nbuild[NS_EWS_TYPES].ItemAttachment {
|
|
1146
|
+
@nbuild[NS_EWS_TYPES].Name(attachment.name)
|
|
1147
|
+
@nbuild[NS_EWS_TYPES].Item {
|
|
1148
|
+
item_id!(attachment.item)
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1149
1151
|
end
|
|
1150
|
-
}
|
|
1151
|
-
end
|
|
1152
1152
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1153
|
+
# Build the AttachmentIds element
|
|
1154
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580686.aspx
|
|
1155
|
+
def attachment_ids!(aids)
|
|
1156
|
+
@nbuild.AttachmentIds {
|
|
1157
|
+
@nbuild.parent.default_namespace = @default_ns
|
|
1158
|
+
aids.each do |aid|
|
|
1159
|
+
attachment_id!(aid)
|
|
1160
|
+
end
|
|
1161
|
+
}
|
|
1162
|
+
end
|
|
1159
1163
|
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
end
|
|
1164
|
+
# Build the AttachmentId element
|
|
1165
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580764.aspx
|
|
1166
|
+
def attachment_id!(aid)
|
|
1167
|
+
attribs = { 'Id' => aid }
|
|
1168
|
+
@nbuild[NS_EWS_TYPES].AttachmentId(attribs)
|
|
1169
|
+
end
|
|
1167
1170
|
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
+
def user_configuration_name!(cfg_name)
|
|
1172
|
+
attribs = { 'Name' => cfg_name.delete(:name) }
|
|
1173
|
+
@nbuild[NS_EWS_MESSAGES].UserConfigurationName(attribs) {
|
|
1174
|
+
fid = cfg_name.keys.first
|
|
1175
|
+
send "#{fid}!", cfg_name[fid][:id], cfg_name[fid][:change_key]
|
|
1176
|
+
}
|
|
1177
|
+
end
|
|
1171
1178
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
# @param [Hash] fid A folder_id
|
|
1176
|
-
# Ex: {:id => myid, :change_key => ck}
|
|
1177
|
-
def dispatch_folder_id!(fid)
|
|
1178
|
-
if(fid[:id].is_a?(String))
|
|
1179
|
-
folder_id!(fid[:id], fid[:change_key])
|
|
1180
|
-
elsif(fid[:id].is_a?(Symbol))
|
|
1181
|
-
distinguished_folder_id!(fid[:id], fid[:change_key], fid[:act_as])
|
|
1182
|
-
else
|
|
1183
|
-
raise EwsBadArgumentError, "Bad argument given for a FolderId. #{fid[:id].class}"
|
|
1184
|
-
end
|
|
1185
|
-
end
|
|
1179
|
+
def user_configuration_properties!(cfg_prop)
|
|
1180
|
+
@nbuild[NS_EWS_MESSAGES].UserConfigurationProperties(cfg_prop)
|
|
1181
|
+
end
|
|
1186
1182
|
|
|
1187
|
-
|
|
1188
|
-
# @param [Hash] iid The item id of some type
|
|
1189
|
-
def dispatch_item_id!(iid)
|
|
1190
|
-
type = iid.keys.first
|
|
1191
|
-
item = iid[type]
|
|
1192
|
-
case type
|
|
1193
|
-
when :item_id
|
|
1194
|
-
item_id!(item)
|
|
1195
|
-
when :occurrence_item_id
|
|
1196
|
-
occurrence_item_id!(item)
|
|
1197
|
-
when :recurring_master_item_id
|
|
1198
|
-
recurring_master_item_id!(item)
|
|
1199
|
-
else
|
|
1200
|
-
raise EwsBadArgumentError, "Bad ItemId type. #{type}"
|
|
1201
|
-
end
|
|
1202
|
-
end
|
|
1183
|
+
# ---------------------- Helpers -------------------- #
|
|
1203
1184
|
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
delete_item_field!(upd)
|
|
1217
|
-
else
|
|
1218
|
-
raise EwsBadArgumentError, "Bad Update type. #{type}"
|
|
1219
|
-
end
|
|
1220
|
-
end
|
|
1185
|
+
# A helper method to dispatch to a FolderId or DistinguishedFolderId correctly
|
|
1186
|
+
# @param [Hash] fid A folder_id
|
|
1187
|
+
# Ex: {:id => myid, :change_key => ck}
|
|
1188
|
+
def dispatch_folder_id!(fid)
|
|
1189
|
+
if fid[:id].is_a?(String)
|
|
1190
|
+
folder_id!(fid[:id], fid[:change_key])
|
|
1191
|
+
elsif fid[:id].is_a?(Symbol)
|
|
1192
|
+
distinguished_folder_id!(fid[:id], fid[:change_key], fid[:act_as])
|
|
1193
|
+
else
|
|
1194
|
+
raise EwsBadArgumentError, "Bad argument given for a FolderId. #{fid[:id].class}"
|
|
1195
|
+
end
|
|
1196
|
+
end
|
|
1221
1197
|
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1198
|
+
# A helper method to dispatch to an ItemId, OccurrenceItemId, or a RecurringMasterItemId
|
|
1199
|
+
# @param [Hash] iid The item id of some type
|
|
1200
|
+
def dispatch_item_id!(iid)
|
|
1201
|
+
type = iid.keys.first
|
|
1202
|
+
item = iid[type]
|
|
1203
|
+
case type
|
|
1204
|
+
when :item_id
|
|
1205
|
+
item_id!(item)
|
|
1206
|
+
when :occurrence_item_id
|
|
1207
|
+
occurrence_item_id!(item)
|
|
1208
|
+
when :recurring_master_item_id
|
|
1209
|
+
recurring_master_item_id!(item)
|
|
1210
|
+
else
|
|
1211
|
+
raise EwsBadArgumentError, "Bad ItemId type. #{type}"
|
|
1212
|
+
end
|
|
1213
|
+
end
|
|
1214
|
+
|
|
1215
|
+
# A helper method to dispatch to a AppendToItemField, SetItemField, or
|
|
1216
|
+
# DeleteItemField
|
|
1217
|
+
# @param [Hash] update An update of some type
|
|
1218
|
+
def dispatch_update_type!(update)
|
|
1219
|
+
type = update.keys.first
|
|
1220
|
+
upd = update[type]
|
|
1221
|
+
case type
|
|
1222
|
+
when :append_to_item_field
|
|
1223
|
+
append_to_item_field!(upd)
|
|
1224
|
+
when :set_item_field
|
|
1225
|
+
set_item_field!(upd)
|
|
1226
|
+
when :delete_item_field
|
|
1227
|
+
delete_item_field!(upd)
|
|
1228
|
+
else
|
|
1229
|
+
raise EwsBadArgumentError, "Bad Update type. #{type}"
|
|
1230
|
+
end
|
|
1231
|
+
end
|
|
1232
|
+
|
|
1233
|
+
# A helper to dispatch to a FieldURI, IndexedFieldURI, or an ExtendedFieldURI
|
|
1234
|
+
# @todo Implement ExtendedFieldURI
|
|
1235
|
+
def dispatch_field_uri!(uri, namespace = NS_EWS_MESSAGES)
|
|
1236
|
+
type = uri.keys.first
|
|
1237
|
+
vals = uri[type].is_a?(Array) ? uri[type] : [uri[type]]
|
|
1238
|
+
case type
|
|
1239
|
+
when :field_uRI, :field_uri
|
|
1240
|
+
vals.each do |val|
|
|
1241
|
+
value = val.is_a?(Hash) ? val[type] : val
|
|
1242
|
+
nbuild[namespace].FieldURI('FieldURI' => value)
|
|
1243
|
+
end
|
|
1244
|
+
when :indexed_field_uRI, :indexed_field_uri
|
|
1245
|
+
vals.each do |val|
|
|
1246
|
+
nbuild[namespace].IndexedFieldURI(
|
|
1247
|
+
'FieldURI' => val[:field_uRI] || val[:field_uri],
|
|
1248
|
+
'FieldIndex' => val[:field_index]
|
|
1249
|
+
)
|
|
1250
|
+
end
|
|
1251
|
+
when :extended_field_uRI, :extended_field_uri
|
|
1252
|
+
vals.each do |val|
|
|
1253
|
+
nbuild[namespace].ExtendedFieldURI {
|
|
1254
|
+
if val[:distinguished_property_set_id]
|
|
1255
|
+
nbuild.parent['DistinguishedPropertySetId'] =
|
|
1256
|
+
val[:distinguished_property_set_id]
|
|
1257
|
+
end
|
|
1258
|
+
nbuild.parent['PropertySetId'] = val[:property_set_id] if val[:property_set_id]
|
|
1259
|
+
nbuild.parent['PropertyTag'] = val[:property_tag] if val[:property_tag]
|
|
1260
|
+
nbuild.parent['PropertyName'] = val[:property_name] if val[:property_name]
|
|
1261
|
+
nbuild.parent['PropertyId'] = val[:property_id] if val[:property_id]
|
|
1262
|
+
nbuild.parent['PropertyType'] = val[:property_type] if val[:property_type]
|
|
1263
|
+
}
|
|
1264
|
+
end
|
|
1265
|
+
else
|
|
1266
|
+
raise EwsBadArgumentError, "Bad URI type. #{type}"
|
|
1267
|
+
end
|
|
1268
|
+
end
|
|
1269
|
+
|
|
1270
|
+
# Insert item, enforce xmlns attribute if prefix is present
|
|
1271
|
+
def dispatch_field_item!(item, ns_prefix = nil)
|
|
1272
|
+
item.values.first[:xmlns_attribute] = ns_prefix if ns_prefix
|
|
1273
|
+
build_xml!(item)
|
|
1239
1274
|
end
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
nbuild[
|
|
1243
|
-
|
|
1244
|
-
nbuild.parent['PropertySetId'] = val[:property_set_id] if val[:property_set_id]
|
|
1245
|
-
nbuild.parent['PropertyTag'] = val[:property_tag] if val[:property_tag]
|
|
1246
|
-
nbuild.parent['PropertyName'] = val[:property_name] if val[:property_name]
|
|
1247
|
-
nbuild.parent['PropertyId'] = val[:property_id] if val[:property_id]
|
|
1248
|
-
nbuild.parent['PropertyType'] = val[:property_type] if val[:property_type]
|
|
1275
|
+
|
|
1276
|
+
def room_list!(cfg_prop)
|
|
1277
|
+
@nbuild[NS_EWS_MESSAGES].RoomList {
|
|
1278
|
+
email_address!(cfg_prop)
|
|
1249
1279
|
}
|
|
1250
1280
|
end
|
|
1251
|
-
else
|
|
1252
|
-
raise EwsBadArgumentError, "Bad URI type. #{type}"
|
|
1253
|
-
end
|
|
1254
|
-
end
|
|
1255
1281
|
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
build_xml!(item)
|
|
1260
|
-
end
|
|
1282
|
+
def room_lists!
|
|
1283
|
+
@nbuild[NS_EWS_MESSAGES].GetRoomLists
|
|
1284
|
+
end
|
|
1261
1285
|
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1286
|
+
def accept_item!(opts)
|
|
1287
|
+
@nbuild[NS_EWS_TYPES].AcceptItem {
|
|
1288
|
+
sensitivity!(opts)
|
|
1289
|
+
body!(opts) if opts[:text]
|
|
1290
|
+
reference_item_id!(opts)
|
|
1291
|
+
}
|
|
1292
|
+
end
|
|
1267
1293
|
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1294
|
+
def tentatively_accept_item!(opts)
|
|
1295
|
+
@nbuild[NS_EWS_TYPES].TentativelyAcceptItem {
|
|
1296
|
+
sensitivity!(opts)
|
|
1297
|
+
body!(opts) if opts[:text]
|
|
1298
|
+
reference_item_id!(opts)
|
|
1299
|
+
}
|
|
1300
|
+
end
|
|
1271
1301
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1302
|
+
def decline_item!(opts)
|
|
1303
|
+
@nbuild[NS_EWS_TYPES].DeclineItem {
|
|
1304
|
+
sensitivity!(opts)
|
|
1305
|
+
body!(opts) if opts[:text]
|
|
1306
|
+
reference_item_id!(opts)
|
|
1307
|
+
}
|
|
1308
|
+
end
|
|
1279
1309
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
body!(opts) if opts[:text]
|
|
1284
|
-
reference_item_id!(opts)
|
|
1285
|
-
}
|
|
1286
|
-
end
|
|
1310
|
+
def sensitivity!(value)
|
|
1311
|
+
nbuild[NS_EWS_TYPES].Sensitivity(value[:sensitivity])
|
|
1312
|
+
end
|
|
1287
1313
|
|
|
1288
|
-
|
|
1289
|
-
@nbuild[NS_EWS_TYPES].DeclineItem {
|
|
1290
|
-
sensitivity!(opts)
|
|
1291
|
-
body!(opts) if opts[:text]
|
|
1292
|
-
reference_item_id!(opts)
|
|
1293
|
-
}
|
|
1294
|
-
end
|
|
1314
|
+
private
|
|
1295
1315
|
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1316
|
+
def parent_namespace(node)
|
|
1317
|
+
node.parent.namespace_definitions.find { |ns| ns.prefix == NS_SOAP }
|
|
1318
|
+
end
|
|
1299
1319
|
|
|
1300
|
-
|
|
1320
|
+
def set_version_header!(version)
|
|
1321
|
+
return unless version && version != 'none'
|
|
1301
1322
|
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1323
|
+
nbuild[NS_EWS_TYPES].RequestServerVersion { |x|
|
|
1324
|
+
x.parent['Version'] = version
|
|
1325
|
+
}
|
|
1326
|
+
end
|
|
1305
1327
|
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
nbuild[NS_EWS_TYPES].RequestServerVersion {|x|
|
|
1309
|
-
x.parent['Version'] = version
|
|
1310
|
-
}
|
|
1311
|
-
end
|
|
1312
|
-
end
|
|
1328
|
+
def set_impersonation!(type, address)
|
|
1329
|
+
return unless type && type != ''
|
|
1313
1330
|
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1331
|
+
nbuild[NS_EWS_TYPES].ExchangeImpersonation {
|
|
1332
|
+
nbuild[NS_EWS_TYPES].ConnectingSID {
|
|
1333
|
+
nbuild[NS_EWS_TYPES].method_missing type, address
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
end
|
|
1337
|
+
|
|
1338
|
+
# Set TimeZoneContext Header
|
|
1339
|
+
# @param time_zone_def [Hash] !{id: time_zone_identifier, name: time_zone_name}
|
|
1340
|
+
def set_time_zone_context_header!(time_zone_def)
|
|
1341
|
+
return unless time_zone_def
|
|
1323
1342
|
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
if time_zone_def
|
|
1328
|
-
nbuild[NS_EWS_TYPES].TimeZoneContext do
|
|
1329
|
-
time_zone_definition! time_zone_def
|
|
1343
|
+
nbuild[NS_EWS_TYPES].TimeZoneContext do
|
|
1344
|
+
time_zone_definition! time_zone_def
|
|
1345
|
+
end
|
|
1330
1346
|
end
|
|
1331
|
-
end
|
|
1332
|
-
end
|
|
1333
1347
|
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1348
|
+
def meeting_time_zone!(mtz)
|
|
1349
|
+
nbuild[NS_EWS_TYPES].MeetingTimeZone do |x|
|
|
1350
|
+
x.parent['TimeZoneName'] = mtz[:time_zone_name] if mtz[:time_zone_name]
|
|
1351
|
+
nbuild[NS_EWS_TYPES].BaseOffset(mtz[:base_offset][:text]) if mtz[:base_offset]
|
|
1352
|
+
end
|
|
1353
|
+
end
|
|
1340
1354
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1355
|
+
# some methods need special naming so they use the '_r' suffix like 'and'
|
|
1356
|
+
def normalize_type(type)
|
|
1357
|
+
case type
|
|
1358
|
+
when :and, :or, :not
|
|
1359
|
+
"#{type}_r".to_sym
|
|
1360
|
+
else
|
|
1361
|
+
type
|
|
1362
|
+
end
|
|
1363
|
+
end
|
|
1350
1364
|
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1365
|
+
def format_time(time)
|
|
1366
|
+
case time
|
|
1367
|
+
when Time, Date, DateTime
|
|
1368
|
+
time.to_datetime.new_offset(0).iso8601
|
|
1369
|
+
when String
|
|
1370
|
+
begin
|
|
1371
|
+
DateTime.parse(time).new_offset(0).iso8601
|
|
1372
|
+
rescue ArgumentError
|
|
1373
|
+
raise EwsBadArgumentError, "Invalid Time argument (#{time})"
|
|
1374
|
+
end
|
|
1375
|
+
else
|
|
1376
|
+
raise EwsBadArgumentError, "Invalid Time argument (#{time})"
|
|
1377
|
+
end
|
|
1378
|
+
end
|
|
1363
1379
|
end
|
|
1364
1380
|
end
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
end # Viewpoint::EWS::SOAP
|
|
1381
|
+
end
|
|
1382
|
+
end
|