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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -6
  3. data/lib/ews/calendar_accessors.rb +37 -33
  4. data/lib/ews/connection.rb +152 -125
  5. data/lib/ews/connection_helper.rb +36 -33
  6. data/lib/ews/convert_accessors.rb +58 -54
  7. data/lib/ews/errors.rb +59 -53
  8. data/lib/ews/ews_client.rb +92 -79
  9. data/lib/ews/exceptions/exceptions.rb +61 -61
  10. data/lib/ews/folder_accessors.rb +235 -234
  11. data/lib/ews/impersonation.rb +29 -23
  12. data/lib/ews/item_accessors.rb +215 -213
  13. data/lib/ews/mailbox_accessors.rb +82 -79
  14. data/lib/ews/meeting_accessors.rb +38 -31
  15. data/lib/ews/message_accessors.rb +83 -81
  16. data/lib/ews/push_subscription_accessors.rb +29 -27
  17. data/lib/ews/room_accessors.rb +48 -46
  18. data/lib/ews/roomlist_accessors.rb +47 -45
  19. data/lib/ews/soap/builders/ews_builder.rb +1191 -1176
  20. data/lib/ews/soap/ews_response.rb +68 -73
  21. data/lib/ews/soap/ews_soap_availability_response.rb +57 -57
  22. data/lib/ews/soap/ews_soap_free_busy_response.rb +115 -117
  23. data/lib/ews/soap/ews_soap_response.rb +99 -101
  24. data/lib/ews/soap/ews_soap_room_response.rb +45 -45
  25. data/lib/ews/soap/ews_soap_roomlist_response.rb +45 -46
  26. data/lib/ews/soap/exchange_availability.rb +54 -52
  27. data/lib/ews/soap/exchange_data_services.rb +693 -711
  28. data/lib/ews/soap/exchange_notification.rb +123 -128
  29. data/lib/ews/soap/exchange_synchronization.rb +82 -82
  30. data/lib/ews/soap/exchange_time_zones.rb +41 -44
  31. data/lib/ews/soap/exchange_user_configuration.rb +30 -27
  32. data/lib/ews/soap/exchange_web_service.rb +237 -233
  33. data/lib/ews/soap/parsers/ews_parser.rb +46 -42
  34. data/lib/ews/soap/parsers/ews_sax_document.rb +63 -58
  35. data/lib/ews/soap/response_message.rb +69 -68
  36. data/lib/ews/soap/responses/create_attachment_response_message.rb +45 -45
  37. data/lib/ews/soap/responses/create_item_response_message.rb +26 -25
  38. data/lib/ews/soap/responses/find_item_response_message.rb +76 -78
  39. data/lib/ews/soap/responses/get_events_response_message.rb +52 -51
  40. data/lib/ews/soap/responses/send_notification_response_message.rb +53 -51
  41. data/lib/ews/soap/responses/subscribe_response_message.rb +37 -34
  42. data/lib/ews/soap/responses/sync_folder_hierarchy_response_message.rb +38 -35
  43. data/lib/ews/soap/responses/sync_folder_items_response_message.rb +38 -35
  44. data/lib/ews/soap.rb +27 -26
  45. data/lib/ews/templates/calendar_item.rb +64 -60
  46. data/lib/ews/templates/forward_item.rb +19 -17
  47. data/lib/ews/templates/message.rb +61 -58
  48. data/lib/ews/templates/reply_to_item.rb +20 -18
  49. data/lib/ews/templates/task.rb +55 -55
  50. data/lib/ews/types/attachment.rb +75 -74
  51. data/lib/ews/types/attendee.rb +27 -25
  52. data/lib/ews/types/calendar_folder.rb +58 -59
  53. data/lib/ews/types/calendar_item.rb +133 -131
  54. data/lib/ews/types/contact.rb +11 -5
  55. data/lib/ews/types/contacts_folder.rb +10 -5
  56. data/lib/ews/types/copied_event.rb +47 -48
  57. data/lib/ews/types/created_event.rb +22 -20
  58. data/lib/ews/types/deleted_event.rb +22 -20
  59. data/lib/ews/types/distribution_list.rb +11 -5
  60. data/lib/ews/types/event.rb +60 -59
  61. data/lib/ews/types/export_items_response_message.rb +54 -50
  62. data/lib/ews/types/file_attachment.rb +63 -61
  63. data/lib/ews/types/folder.rb +58 -57
  64. data/lib/ews/types/free_busy_changed_event.rb +22 -20
  65. data/lib/ews/types/generic_folder.rb +348 -372
  66. data/lib/ews/types/item.rb +401 -397
  67. data/lib/ews/types/item_attachment.rb +87 -80
  68. data/lib/ews/types/item_field_uri_map.rb +201 -200
  69. data/lib/ews/types/mailbox_user.rb +146 -154
  70. data/lib/ews/types/meeting_cancellation.rb +11 -5
  71. data/lib/ews/types/meeting_message.rb +11 -5
  72. data/lib/ews/types/meeting_request.rb +11 -5
  73. data/lib/ews/types/meeting_response.rb +11 -5
  74. data/lib/ews/types/message.rb +11 -5
  75. data/lib/ews/types/modified_event.rb +43 -45
  76. data/lib/ews/types/moved_event.rb +47 -48
  77. data/lib/ews/types/new_mail_event.rb +22 -20
  78. data/lib/ews/types/out_of_office.rb +145 -144
  79. data/lib/ews/types/post_item.rb +11 -5
  80. data/lib/ews/types/search_folder.rb +10 -5
  81. data/lib/ews/types/status_event.rb +37 -36
  82. data/lib/ews/types/task.rb +39 -33
  83. data/lib/ews/types/tasks_folder.rb +31 -25
  84. data/lib/ews/types.rb +134 -139
  85. data/lib/viewpoint/logging/config.rb +19 -19
  86. data/lib/viewpoint/logging.rb +23 -17
  87. data/lib/viewpoint/string_utils.rb +31 -32
  88. data/lib/viewpoint.rb +18 -18
  89. metadata +50 -25
  90. data/Changelog.txt +0 -1004
@@ -1,1367 +1,1382 @@
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
- module Viewpoint::EWS::SOAP
19
-
20
- # This class includes the element builders. The idea is that each element should
21
- # know how to build themselves so each parent element can delegate creation of
22
- # subelements to a method of the same name with a '!' after it.
23
- class EwsBuilder
24
- include Viewpoint::EWS
25
- include Viewpoint::StringUtils
26
-
27
- attr_reader :nbuild
28
- def initialize
29
- @nbuild = Nokogiri::XML::Builder.new
30
- end
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
- # Build the SOAP envelope and yield this object so subelements can be built. Once
33
- # you have the EwsBuilder object you can use the nbuild object like shown in the
34
- # example for the Header section. The nbuild object is the underlying
35
- # Nokogiri::XML::Builder object.
36
- # @param [Hash] opts
37
- # @option opts [String] :server_version The version string that should get
38
- # set in the Header. See ExchangeWebService#initialize
39
- # @option opts [Hash] :time_zone_context TimeZoneDefinition. Format: !{id: time_zone_identifier}
40
- # @example
41
- # xb = EwsBuilder.new
42
- # xb.build! do |part, b|
43
- # if(part == :header)
44
- # b.nbuild.MyVar('blablabla')
45
- # else
46
- # b.folder_shape!({:base_shape => 'Default'})
47
- # end
48
- # end
49
- def build!(opts = {}, &block)
50
- @nbuild.Envelope(NAMESPACES) do |node|
51
- node.parent.namespace = parent_namespace(node)
52
- node.Header {
53
- set_version_header! opts[:server_version]
54
- set_impersonation! opts[:impersonation_type], opts[:impersonation_mail]
55
- set_time_zone_context_header! opts[:time_zone_context]
56
- yield(:header, self) if block_given?
57
- }
58
- node.Body {
59
- yield(:body, self) if block_given?
60
- }
61
- end
62
- @nbuild.doc
63
- end
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
- # Build XML from a passed in Hash or Array in a specified format.
66
- # @param [Array,Hash] elems The elements to add to the Builder. They must
67
- # be specified like so:
68
- #
69
- # !{:top =>
70
- # { :xmlns => 'http://stonesthrow/soap',
71
- # :sub_elements => [
72
- # {:elem1 => {:text => 'inside'}},
73
- # {:elem2 => {:text => 'inside2'}}
74
- # ],
75
- # :id => '3232', :tx_dd => 23, :asdf => 'turkey'
76
- # }
77
- # }
78
- # or
79
- # [ {:first => {:text => 'hello'}},
80
- # {:second => {:text => 'world'}}
81
- # ]
82
- #
83
- # NOTE: there are specialized keys for text (:text), child elements
84
- # (:sub_elements) and namespaces (:xmlns).
85
- def build_xml!(elems)
86
- case elems.class.name
87
- when 'Hash'
88
- keys = elems.keys
89
- vals = elems.values
90
- if(keys.length > 1 && !vals.is_a?(Hash))
91
- raise "invalid input: #{elems}"
92
- end
93
- vals = vals.first.clone
94
- se = vals.delete(:sub_elements)
95
- txt = vals.delete(:text)
96
- xmlns_attribute = vals.delete(:xmlns_attribute)
97
-
98
- node = @nbuild.send(camel_case(keys.first), txt, vals) {|x|
99
- build_xml!(se) if se
100
- }
101
-
102
- # Set node level namespace
103
- node.xmlns = NAMESPACES["xmlns:#{xmlns_attribute}"] if xmlns_attribute
104
- when 'Array'
105
- elems.each do |e|
106
- build_xml!(e)
107
- end
108
- else
109
- raise "Unsupported type: #{elems.class.name}"
110
- end
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
- # Build the FolderShape element
114
- # @see http://msdn.microsoft.com/en-us/library/aa494311.aspx
115
- # @param [Hash] folder_shape The folder shape structure to build from
116
- # @todo need fully support all options
117
- def folder_shape!(folder_shape)
118
- @nbuild.FolderShape {
119
- @nbuild.parent.default_namespace = @default_ns
120
- base_shape!(folder_shape[:base_shape])
121
- if(folder_shape[:additional_properties])
122
- additional_properties!(folder_shape[:additional_properties])
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
- # Build the ItemShape element
128
- # @see http://msdn.microsoft.com/en-us/library/aa565261.aspx
129
- # @param [Hash] item_shape The item shape structure to build from
130
- # @todo need fully support all options
131
- def item_shape!(item_shape)
132
- @nbuild[NS_EWS_MESSAGES].ItemShape {
133
- @nbuild.parent.default_namespace = @default_ns
134
- base_shape!(item_shape[:base_shape])
135
- mime_content!(item_shape[:include_mime_content]) if item_shape.has_key?(:include_mime_content)
136
- body_type!(item_shape[:body_type]) if item_shape[:body_type]
137
- if(item_shape[:additional_properties])
138
- additional_properties!(item_shape[:additional_properties])
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
- # Build the IndexedPageItemView element
144
- # @see http://msdn.microsoft.com/en-us/library/exchange/aa563549(v=exchg.150).aspx
145
- # @todo needs peer check
146
- def indexed_page_item_view!(indexed_page_item_view)
147
- attribs = {}
148
- indexed_page_item_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s}
149
- @nbuild[NS_EWS_MESSAGES].IndexedPageItemView(attribs)
150
- end
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
- # Build the BaseShape element
153
- # @see http://msdn.microsoft.com/en-us/library/aa580545.aspx
154
- def base_shape!(base_shape)
155
- @nbuild[NS_EWS_TYPES].BaseShape(camel_case(base_shape))
156
- end
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
- def mime_content!(include_mime_content)
159
- @nbuild[NS_EWS_TYPES].IncludeMimeContent(include_mime_content.to_s.downcase)
160
- end
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
- def body_type!(body_type)
163
- body_type = body_type.to_s
164
- if body_type =~ /html/i
165
- body_type = body_type.upcase
166
- else
167
- body_type = body_type.downcase.capitalize
168
- end
169
- nbuild[NS_EWS_TYPES].BodyType(body_type)
170
- end
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
- # Build the ParentFolderIds element
173
- # @see http://msdn.microsoft.com/en-us/library/aa565998.aspx
174
- def parent_folder_ids!(pfids)
175
- @nbuild[NS_EWS_MESSAGES].ParentFolderIds {
176
- pfids.each do |pfid|
177
- dispatch_folder_id!(pfid)
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
- # Build the ParentFolderId element
183
- # @see http://msdn.microsoft.com/en-us/library/aa563268.aspx
184
- def parent_folder_id!(pfid)
185
- @nbuild.ParentFolderId {
186
- dispatch_folder_id!(pfid)
187
- }
188
- end
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
- # Build the FolderIds element
191
- # @see http://msdn.microsoft.com/en-us/library/aa580509.aspx
192
- def folder_ids!(fids, act_as=nil)
193
- ns = @nbuild.parent.name.match(/subscription/i) ? NS_EWS_TYPES : NS_EWS_MESSAGES
194
- @nbuild[ns].FolderIds {
195
- fids.each do |fid|
196
- fid[:act_as] = act_as if act_as != nil
197
- dispatch_folder_id!(fid)
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
- # Build the SyncFolderId element
203
- # @see http://msdn.microsoft.com/en-us/library/aa580296.aspx
204
- def sync_folder_id!(fid)
205
- @nbuild.SyncFolderId {
206
- dispatch_folder_id!(fid)
207
- }
208
- end
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
- # Build the DistinguishedFolderId element
211
- # @see http://msdn.microsoft.com/en-us/library/aa580808.aspx
212
- # @todo add support for the Mailbox child object
213
- def distinguished_folder_id!(dfid, change_key = nil, act_as = nil)
214
- attribs = {'Id' => dfid.to_s}
215
- attribs['ChangeKey'] = change_key if change_key
216
- @nbuild[NS_EWS_TYPES].DistinguishedFolderId(attribs) {
217
- if ! act_as.nil?
218
- mailbox!({:email_address => act_as})
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
- # Build the FolderId element
224
- # @see http://msdn.microsoft.com/en-us/library/aa579461.aspx
225
- def folder_id!(fid, change_key = nil)
226
- attribs = {'Id' => fid}
227
- attribs['ChangeKey'] = change_key if change_key
228
- @nbuild[NS_EWS_TYPES].FolderId(attribs)
229
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa563525(v=EXCHG.140).aspx
232
- def item_ids!(item_ids)
233
- @nbuild.ItemIds {
234
- item_ids.each do |iid|
235
- dispatch_item_id!(iid)
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
- def parent_item_id!(id)
241
- nbuild.ParentItemId {|x|
242
- x.parent['Id'] = id[:id]
243
- x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
244
- }
245
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa580234(v=EXCHG.140).aspx
248
- def item_id!(id)
249
- nbuild[NS_EWS_TYPES].ItemId {|x|
250
- x.parent['Id'] = id[:id]
251
- x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
252
- }
253
- end
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
- # @see http://msdn.microsoft.com/en-us/library/ff709503(v=exchg.140).aspx
256
- def export_item_ids!(item_ids)
257
- ns = @nbuild.parent.name.match(/subscription/i) ? NS_EWS_TYPES : NS_EWS_MESSAGES
258
- @nbuild[ns].ExportItems{
259
- @nbuild.ItemIds {
260
- item_ids.each do |iid|
261
- dispatch_item_id!(iid)
262
- end
263
- }
264
- }
265
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa580744(v=EXCHG.140).aspx
268
- def occurrence_item_id!(id)
269
- @nbuild[NS_EWS_TYPES].OccurrenceItemId {|x|
270
- x.parent['RecurringMasterId'] = id[:recurring_master_id]
271
- x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
272
- x.parent['InstanceIndex'] = id[:instance_index]
273
- }
274
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa581019(v=EXCHG.140).aspx
277
- def recurring_master_item_id!(id)
278
- @nbuild[NS_EWS_TYPES].RecurringMasterItemId {|x|
279
- x.parent['OccurrenceId'] = id[:occurrence_id]
280
- x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
281
- }
282
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa565020(v=EXCHG.140).aspx
285
- def to_folder_id!(to_fid)
286
- @nbuild[NS_EWS_MESSAGES].ToFolderId {
287
- dispatch_folder_id!(to_fid)
288
- }
289
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa564009.aspx
292
- def folders!(folders)
293
- @nbuild.Folders {|x|
294
- folders.each do |fold|
295
- fold.each_pair do |ftype, vars| # convenience, should only be one pair
296
- ftype = "#{ftype}!".to_sym
297
- if self.respond_to? ftype
298
- self.send ftype, vars
299
- else
300
- raise Viewpoint::EWS::EwsNotImplemented,
301
- "#{ftype} not implemented as a builder."
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
- end
300
+ }
304
301
  end
305
- }
306
- end
307
302
 
308
- def folder!(folder, type = :Folder)
309
- nbuild[NS_EWS_TYPES].send(type) {|x|
310
- folder.each_pair do |e,v|
311
- ftype = "#{e}!".to_sym
312
- if e == :folder_id
313
- dispatch_folder_id!(v)
314
- elsif self.respond_to?(ftype)
315
- self.send ftype, v
316
- else
317
- raise Viewpoint::EWS::EwsNotImplemented,
318
- "#{ftype} not implemented as a builder."
319
- end
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
- def calendar_folder!(folder)
325
- folder! folder, :CalendarFolder
326
- end
319
+ def calendar_folder!(folder)
320
+ folder! folder, :CalendarFolder
321
+ end
327
322
 
328
- def contacts_folder!(folder)
329
- folder! folder, :ContactsFolder
330
- end
323
+ def contacts_folder!(folder)
324
+ folder! folder, :ContactsFolder
325
+ end
331
326
 
332
- def search_folder!(folder)
333
- folder! folder, :SearchFolder
334
- end
327
+ def search_folder!(folder)
328
+ folder! folder, :SearchFolder
329
+ end
335
330
 
336
- def tasks_folder!(folder)
337
- folder! folder, :TasksFolder
338
- end
331
+ def tasks_folder!(folder)
332
+ folder! folder, :TasksFolder
333
+ end
339
334
 
340
- def display_name!(name)
341
- nbuild[NS_EWS_TYPES].DisplayName(name)
342
- end
335
+ def display_name!(name)
336
+ nbuild[NS_EWS_TYPES].DisplayName(name)
337
+ end
343
338
 
344
- # Build the AdditionalProperties element
345
- # @see http://msdn.microsoft.com/en-us/library/aa563810.aspx
346
- def additional_properties!(addprops)
347
- @nbuild[NS_EWS_TYPES].AdditionalProperties {
348
- addprops.each_pair {|k,v|
349
- dispatch_field_uri!({k => v}, NS_EWS_TYPES)
350
- }
351
- }
352
- end
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
- # Build the Mailbox element.
355
- # This element is commonly used for delegation. Typically passing an
356
- # email_address is sufficient
357
- # @see http://msdn.microsoft.com/en-us/library/aa565036.aspx
358
- # @param [Hash] mailbox A well-formated hash
359
- def mailbox!(mbox)
360
- nbuild[NS_EWS_TYPES].Mailbox {
361
- name!(mbox[:name]) if mbox[:name]
362
- email_address!(mbox[:email_address]) if mbox[:email_address]
363
- address!(mbox[:address]) if mbox[:address] # for Availability query
364
- routing_type!(mbox[:routing_type]) if mbox[:routing_type]
365
- mailbox_type!(mbox[:mailbox_type]) if mbox[:mailbox_type]
366
- item_id!(mbox[:item_id]) if mbox[:item_id]
367
- }
368
- end
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
- def name!(name)
371
- nbuild[NS_EWS_TYPES].Name(name)
372
- end
365
+ def name!(name)
366
+ nbuild[NS_EWS_TYPES].Name(name)
367
+ end
373
368
 
374
- def email_address!(email)
375
- nbuild[NS_EWS_TYPES].EmailAddress(email)
376
- end
369
+ def email_address!(email)
370
+ nbuild[NS_EWS_TYPES].EmailAddress(email)
371
+ end
377
372
 
378
- def address!(email)
379
- nbuild[NS_EWS_TYPES].Address(email)
380
- end
373
+ def address!(email)
374
+ nbuild[NS_EWS_TYPES].Address(email)
375
+ end
381
376
 
382
- # This is stupid. The only valid value is "SMTP"
383
- def routing_type!(type)
384
- nbuild[NS_EWS_TYPES].RoutingType(type)
385
- end
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
- def mailbox_type!(type)Standard
388
- nbuild[NS_EWS_TYPES].MailboxType(type)
389
- end
382
+ def mailbox_type!(type)
383
+ nbuild[NS_EWS_TYPES].MailboxType(type)
384
+ end
390
385
 
391
- def user_oof_settings!(opts)
392
- nbuild[NS_EWS_TYPES].UserOofSettings {
393
- nbuild.OofState(camel_case(opts[:oof_state]))
394
- nbuild.ExternalAudience(camel_case(opts[:external_audience])) if opts[:external_audience]
395
- duration!(opts[:duration]) if opts[:duration]
396
- nbuild.InternalReply {
397
- nbuild.Message(opts[:internal_reply])
398
- } if opts[:external_reply]
399
- nbuild.ExternalReply {
400
- nbuild.Message(opts[:external_reply])
401
- } if opts[:external_reply]
402
- }
403
- end
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
- def duration!(opts)
406
- nbuild.Duration {
407
- nbuild.StartTime(format_time opts[:start_time])
408
- nbuild.EndTime(format_time opts[:end_time])
409
- }
410
- end
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
- def mailbox_data!(md)
413
- nbuild[NS_EWS_TYPES].MailboxData {
414
- nbuild[NS_EWS_TYPES].Email {
415
- mbox = md[:email]
416
- name!(mbox[:name]) if mbox[:name]
417
- address!(mbox[:address]) if mbox[:address] # for Availability query
418
- routing_type!(mbox[:routing_type]) if mbox[:routing_type]
419
- }
420
- nbuild[NS_EWS_TYPES].AttendeeType 'Required'
421
- }
422
- end
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
- def free_busy_view_options!(opts)
425
- nbuild[NS_EWS_TYPES].FreeBusyViewOptions {
426
- nbuild[NS_EWS_TYPES].TimeWindow {
427
- nbuild[NS_EWS_TYPES].StartTime(format_time opts[:time_window][:start_time])
428
- nbuild[NS_EWS_TYPES].EndTime(format_time opts[:time_window][:end_time])
429
- }
430
- nbuild[NS_EWS_TYPES].RequestedView(camel_case(opts[:requested_view][:requested_free_busy_view]))
431
- }
432
- end
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
- def suggestions_view_options!(opts)
435
- end
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
- def time_zone!(zone)
438
- zone ||= {}
439
- zone = {
440
- bias: zone[:bias] || 480,
441
- standard_time: {
442
- bias: 0,
443
- time: "02:00:00",
444
- day_order: 5,
445
- month: 10,
446
- day_of_week: 'Sunday'
447
- }.merge(zone[:standard_time] || {}),
448
- daylight_time: {
449
- bias: -60,
450
- time: "02:00:00",
451
- day_order: 1,
452
- month: 4,
453
- day_of_week: 'Sunday'
454
- }.merge(zone[:daylight_time] || {})
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
- # Request all known time_zones from server
477
- def get_server_time_zones!(get_time_zone_options)
478
- nbuild[NS_EWS_MESSAGES].GetServerTimeZones('ReturnFullTimeZoneData' => get_time_zone_options[:full]) do
479
- if get_time_zone_options[:ids] && get_time_zone_options[:ids].any?
480
- nbuild[NS_EWS_MESSAGES].Ids do
481
- get_time_zone_options[:ids].each do |id|
482
- nbuild[NS_EWS_TYPES].Id id
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
- # Specifies an optional time zone for the start time
490
- # @param [Hash] attributes
491
- # @option attributes :id [String] ID of the Microsoft well known time zone
492
- # @option attributes :name [String] Optional name of the time zone
493
- # @todo Implement sub elements Periods, TransitionsGroups and Transitions to override zone
494
- # @see http://msdn.microsoft.com/en-us/library/exchange/dd899524.aspx
495
- def start_time_zone!(zone)
496
- attributes = {}
497
- attributes['Id'] = zone[:id] if zone[:id]
498
- attributes['Name'] = zone[:name] if zone[:name]
499
- nbuild[NS_EWS_TYPES].StartTimeZone(attributes)
500
- end
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
- # Specifies an optional time zone for the end time
503
- # @param [Hash] attributes
504
- # @option attributes :id [String] ID of the Microsoft well known time zone
505
- # @option attributes :name [String] Optional name of the time zone
506
- # @todo Implement sub elements Periods, TransitionsGroups and Transitions to override zone
507
- # @see http://msdn.microsoft.com/en-us/library/exchange/dd899434.aspx
508
- def end_time_zone!(zone)
509
- attributes = {}
510
- attributes['Id'] = zone[:id] if zone[:id]
511
- attributes['Name'] = zone[:name] if zone[:name]
512
- nbuild[NS_EWS_TYPES].EndTimeZone(attributes)
513
- end
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
- # Specify a time zone
516
- # @todo Implement subelements Periods, TransitionsGroups and Transitions to override zone
517
- # @see http://msdn.microsoft.com/en-us/library/exchange/dd899488.aspx
518
- def time_zone_definition!(zone)
519
- attributes = {'Id' => zone[:id]}
520
- attributes['Name'] = zone[:name] if zone[:name]
521
- nbuild[NS_EWS_TYPES].TimeZoneDefinition(attributes)
522
- end
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
- # Build the Restriction element
525
- # @see http://msdn.microsoft.com/en-us/library/aa563791.aspx
526
- # @param [Hash] restriction a well-formatted Hash that can be fed to #build_xml!
527
- def restriction!(restriction)
528
- @nbuild[NS_EWS_MESSAGES].Restriction {
529
- restriction.each_pair do |k,v|
530
- self.send normalize_type(k), v
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
- def and_r(expr)
536
- and_or('And', expr)
537
- end
533
+ def and_r(expr)
534
+ and_or('And', expr)
535
+ end
538
536
 
539
- def or_r(expr)
540
- and_or('Or', expr)
541
- end
537
+ def or_r(expr)
538
+ and_or('Or', expr)
539
+ end
542
540
 
543
- def and_or(type, expr)
544
- @nbuild[NS_EWS_TYPES].send(type) {
545
- expr.each do |e|
546
- type = e.keys.first
547
- self.send normalize_type(type), e[type]
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
- def not_r(expr)
553
- @nbuild[NS_EWS_TYPES].Not {
554
- type = expr.keys.first
555
- self.send(type, expr[type])
556
- }
557
- end
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
- def contains(expr)
560
- @nbuild[NS_EWS_TYPES].Contains(
561
- 'ContainmentMode' => expr.delete(:containment_mode),
562
- 'ContainmentComparison' => expr.delete(:containment_comparison)) {
563
- c = expr.delete(:constant) # remove constant 1st for ordering
564
- type = expr.keys.first
565
- self.send(type, expr[type])
566
- constant(c)
567
- }
568
- end
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
- def excludes(expr)
571
- @nbuild[NS_EWS_TYPES].Excludes {
572
- b = expr.delete(:bitmask) # remove bitmask 1st for ordering
573
- type = expr.keys.first
574
- self.send(type, expr[type])
575
- bitmask(b)
576
- }
577
- end
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
- def exists(expr)
580
- @nbuild[NS_EWS_TYPES].Exists {
581
- type = expr.keys.first
582
- self.send(type, expr[type])
583
- }
584
- end
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
- def bitmask(expr)
587
- @nbuild[NS_EWS_TYPES].Bitmask('Value' => expr[:value])
588
- end
585
+ def bitmask(expr)
586
+ @nbuild[NS_EWS_TYPES].Bitmask('Value' => expr[:value])
587
+ end
589
588
 
590
- def is_equal_to(expr)
591
- restriction_compare('IsEqualTo',expr)
592
- end
589
+ # rubocop:disable Naming/PredicatePrefix -- public API name
590
+ def is_equal_to(expr)
591
+ restriction_compare('IsEqualTo', expr)
592
+ end
593
593
 
594
- def is_greater_than(expr)
595
- restriction_compare('IsGreaterThan',expr)
596
- end
594
+ def is_greater_than(expr)
595
+ restriction_compare('IsGreaterThan', expr)
596
+ end
597
597
 
598
- def is_greater_than_or_equal_to(expr)
599
- restriction_compare('IsGreaterThanOrEqualTo',expr)
600
- end
598
+ def is_greater_than_or_equal_to(expr)
599
+ restriction_compare('IsGreaterThanOrEqualTo', expr)
600
+ end
601
601
 
602
- def is_less_than(expr)
603
- restriction_compare('IsLessThan',expr)
604
- end
602
+ def is_less_than(expr)
603
+ restriction_compare('IsLessThan', expr)
604
+ end
605
605
 
606
- def is_less_than_or_equal_to(expr)
607
- restriction_compare('IsLessThanOrEqualTo',expr)
608
- end
606
+ def is_less_than_or_equal_to(expr)
607
+ restriction_compare('IsLessThanOrEqualTo', expr)
608
+ end
609
609
 
610
- def is_not_equal_to(expr)
611
- restriction_compare('IsNotEqualTo',expr)
612
- end
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
- def restriction_compare(type,expr)
615
- nbuild[NS_EWS_TYPES].send(type) {
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
- def ews_types_builder
625
- nbuild[NS_EWS_TYPES]
626
- end
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
- def field_uRI(expr)
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
- alias_method :field_uri, :field_uRI
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
- def indexed_field_uRI(expr)
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
- alias_method :indexed_field_uri, :indexed_field_uRI
643
-
644
- def extended_field_uRI(expr)
645
- nbuild[NS_EWS_TYPES].ExtendedFieldURI {
646
- nbuild.parent['DistinguishedPropertySetId'] = expr[:distinguished_property_set_id] if expr[:distinguished_property_set_id]
647
- nbuild.parent['PropertySetId'] = expr[:property_set_id] if expr[:property_set_id]
648
- nbuild.parent['PropertyTag'] = expr[:property_tag] if expr[:property_tag]
649
- nbuild.parent['PropertyName'] = expr[:property_name] if expr[:property_name]
650
- nbuild.parent['PropertyId'] = expr[:property_id] if expr[:property_id]
651
- nbuild.parent['PropertyType'] = expr[:property_type] if expr[:property_type]
652
- }
653
- end
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
- alias_method :extended_field_uri, :extended_field_uRI
659
+ alias extended_field_uri extended_field_uRI
656
660
 
657
- def extended_properties!(eprops)
658
- eprops.each {|ep| extended_property!(ep)}
659
- end
661
+ def extended_properties!(eprops)
662
+ eprops.each { |ep| extended_property!(ep) }
663
+ end
660
664
 
661
- def extended_property!(eprop)
662
- nbuild[NS_EWS_TYPES].ExtendedProperty {
663
- key = eprop.keys.grep(/extended/i).first
664
- dispatch_field_uri!({key => eprop[key]}, NS_EWS_TYPES)
665
- if eprop[:values]
666
- nbuild.Values {
667
- eprop[:values].each do |v|
668
- value! v
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
- def value!(val)
678
- nbuild[NS_EWS_TYPES].Value(val)
679
- end
681
+ def value!(val)
682
+ nbuild[NS_EWS_TYPES].Value(val)
683
+ end
680
684
 
681
- def field_uRI_or_constant(expr)
682
- nbuild[NS_EWS_TYPES].FieldURIOrConstant {
683
- type = expr.keys.first
684
- self.send(type, expr[type])
685
- }
686
- end
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
- alias_method :field_uri_or_constant, :field_uRI_or_constant
692
+ alias field_uri_or_constant field_uRI_or_constant
689
693
 
690
- def constant(expr)
691
- nbuild[NS_EWS_TYPES].Constant('Value' => expr[:value])
692
- end
694
+ def constant(expr)
695
+ nbuild[NS_EWS_TYPES].Constant('Value' => expr[:value])
696
+ end
693
697
 
694
- # Build the CalendarView element
695
- def calendar_view!(cal_view)
696
- attribs = {}
697
- cal_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s}
698
- @nbuild[NS_EWS_MESSAGES].CalendarView(attribs)
699
- end
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
- # Build the ContactsView element
702
- def contacts_view!(con_view)
703
- attribs = {}
704
- con_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s}
705
- @nbuild[NS_EWS_MESSAGES].ContactsView(attribs)
706
- end
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
- # @see https://msdn.microsoft.com/en-us/library/aa565683(v=exchg.140).aspx
709
- def categories!(fa)
710
- @nbuild[NS_EWS_TYPES].Categories {
711
- @nbuild[NS_EWS_TYPES].String(fa)
712
- }
713
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa579678(v=EXCHG.140).aspx
716
- def event_types!(evtypes)
717
- @nbuild[NS_EWS_TYPES].EventTypes {
718
- evtypes.each do |et|
719
- @nbuild[NS_EWS_TYPES].EventType(camel_case(et))
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
- # @see http://msdn.microsoft.com/en-us/library/aa565886(v=EXCHG.140).aspx
725
- def watermark!(wmark, ns = NS_EWS_TYPES)
726
- @nbuild[ns].Watermark(wmark)
727
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa565201(v=EXCHG.140).aspx
730
- def timeout!(tout)
731
- @nbuild[NS_EWS_TYPES].Timeout(tout)
732
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa564048(v=EXCHG.140).aspx
735
- def status_frequency!(freq)
736
- @nbuild[NS_EWS_TYPES].StatusFrequency(freq)
737
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa566309(v=EXCHG.140).aspx
740
- def uRL!(url)
741
- @nbuild[NS_EWS_TYPES].URL(url)
742
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa563790(v=EXCHG.140).aspx
745
- def subscription_id!(subid)
746
- @nbuild.SubscriptionId(subid)
747
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa563455(v=EXCHG.140).aspx
750
- def pull_subscription_request(subopts)
751
- subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
752
- @nbuild.PullSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
753
- folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
754
- event_types!(subopts[:event_types]) if subopts[:event_types]
755
- watermark!(subopts[:watermark]) if subopts[:watermark]
756
- timeout!(subopts[:timeout]) if subopts[:timeout]
757
- }
758
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa563599(v=EXCHG.140).aspx
761
- def push_subscription_request(subopts)
762
- subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
763
- @nbuild.PushSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
764
- folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
765
- event_types!(subopts[:event_types]) if subopts[:event_types]
766
- watermark!(subopts[:watermark]) if subopts[:watermark]
767
- status_frequency!(subopts[:status_frequency]) if subopts[:status_frequency]
768
- uRL!(subopts[:uRL]) if subopts[:uRL]
769
- }
770
- end
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
- # @see http://msdn.microsoft.com/en-us/library/ff406182(v=EXCHG.140).aspx
773
- def streaming_subscription_request(subopts)
774
- subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
775
- @nbuild.StreamingSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
776
- folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
777
- event_types!(subopts[:event_types]) if subopts[:event_types]
778
- }
779
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa565970(v=EXCHG.140).aspx
782
- def sync_state!(syncstate)
783
- @nbuild.SyncState(syncstate)
784
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa563785(v=EXCHG.140).aspx
787
- def ignore!(item_ids)
788
- @nbuild.Ignore {
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
- # @see http://msdn.microsoft.com/en-us/library/aa566325(v=EXCHG.140).aspx
796
- def max_changes_returned!(cnum)
797
- @nbuild[NS_EWS_MESSAGES].MaxChangesReturned(cnum)
798
- end
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
- # @see http://msdn.microsoft.com/en-us/library/dd899531(v=EXCHG.140).aspx
801
- def sync_scope!(scope)
802
- @nbuild.SyncScope(scope)
803
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa580758(v=EXCHG.140).aspx
806
- def saved_item_folder_id!(fid)
807
- @nbuild.SavedItemFolderId {
808
- dispatch_folder_id!(fid)
809
- }
810
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa565652(v=exchg.140).aspx
813
- def item!(item)
814
- nbuild.Item {
815
- item.each_pair {|k,v|
816
- self.send("#{k}!", v)
817
- }
818
- }
819
- end
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
- def message!(item)
822
- nbuild[NS_EWS_TYPES].Message {
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
- def is_read!(read)
833
- nbuild[NS_EWS_TYPES].IsRead(read)
834
- end
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
- def calendar_item!(item)
837
- nbuild[NS_EWS_TYPES].CalendarItem {
838
- item.each_pair {|k,v|
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
- def calendar_item_type!(type)
845
- nbuild[NS_EWS_TYPES].CalendarItemType(type)
846
- end
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
- def recurrence!(item)
849
- nbuild[NS_EWS_TYPES].Recurrence {
850
- item.each_pair { |k, v|
851
- self.send("#{k}!", v)
852
- }
853
- }
854
- end
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
- def daily_recurrence!(item)
857
- nbuild[NS_EWS_TYPES].DailyRecurrence {
858
- item.each_pair { |k, v|
859
- self.send("#{k}!", v)
860
- }
861
- }
862
- end
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
- def weekly_recurrence!(item)
865
- nbuild[NS_EWS_TYPES].WeeklyRecurrence {
866
- item.each_pair { |k, v|
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
- def interval!(num)
873
- nbuild[NS_EWS_TYPES].Interval(num)
874
- end
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
- def no_end_recurrence!(item)
877
- nbuild[NS_EWS_TYPES].NoEndRecurrence {
878
- item.each_pair { |k, v|
879
- self.send("#{k}!", v)
880
- }
881
- }
882
- end
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
- def numbered_recurrence!(item)
885
- nbuild[NS_EWS_TYPES].NumberedRecurrence {
886
- item.each_pair { |k, v|
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
- def number_of_occurrences!(count)
893
- nbuild[NS_EWS_TYPES].NumberOfOccurrences(count)
894
- end
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
- def task!(item)
898
- nbuild[NS_EWS_TYPES].Task {
899
- item.each_pair {|k, v|
900
- self.send("#{k}!", v)
901
- }
902
- }
903
- end
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
- def forward_item!(item)
906
- nbuild[NS_EWS_TYPES].ForwardItem {
907
- item.each_pair {|k,v|
908
- self.send("#{k}!", v)
909
- }
910
- }
911
- end
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
- def reply_to_item!(item)
914
- nbuild[NS_EWS_TYPES].ReplyToItem {
915
- item.each_pair {|k,v|
916
- self.send("#{k}!", v)
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
- def reply_all_to_item!(item)
922
- nbuild[NS_EWS_TYPES].ReplyAllToItem {
923
- item.each_pair {|k,v|
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
- def reference_item_id!(id)
930
- nbuild[NS_EWS_TYPES].ReferenceItemId {|x|
931
- x.parent['Id'] = id[:id]
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
- def subject!(sub)
937
- nbuild[NS_EWS_TYPES].Subject(sub)
938
- end
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
- def importance!(sub)
941
- nbuild[NS_EWS_TYPES].Importance(sub)
942
- end
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
- def body!(b)
945
- nbuild[NS_EWS_TYPES].Body(b[:text]) {|x|
946
- x.parent['BodyType'] = b[:body_type] if b[:body_type]
947
- }
948
- end
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
- def new_body_content!(b)
951
- nbuild[NS_EWS_TYPES].NewBodyContent(b[:text]) {|x|
952
- x.parent['BodyType'] = b[:body_type] if b[:body_type]
953
- }
954
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa563719(v=exchg.140).aspx
957
- # @param [Array] r An array of Mailbox type hashes to send to #mailbox!
958
- def to_recipients!(r)
959
- nbuild[NS_EWS_TYPES].ToRecipients {
960
- r.each {|mbox| mailbox!(mbox[:mailbox]) }
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
- def cc_recipients!(r)
965
- nbuild[NS_EWS_TYPES].CcRecipients {
966
- r.each {|mbox| mailbox!(mbox[:mailbox]) }
967
- }
968
- end
978
+ def bcc_recipients!(recipients)
979
+ nbuild[NS_EWS_TYPES].BccRecipients {
980
+ recipients.each { |mbox| mailbox!(mbox[:mailbox]) }
981
+ }
982
+ end
969
983
 
970
- def bcc_recipients!(r)
971
- nbuild[NS_EWS_TYPES].BccRecipients {
972
- r.each {|mbox| mailbox!(mbox[:mailbox]) }
973
- }
974
- end
984
+ def from!(sender)
985
+ nbuild[NS_EWS_TYPES].From {
986
+ mailbox! sender
987
+ }
988
+ end
975
989
 
976
- def from!(f)
977
- nbuild[NS_EWS_TYPES].From {
978
- mailbox! f
979
- }
980
- end
990
+ def required_attendees!(attendees)
991
+ nbuild[NS_EWS_TYPES].RequiredAttendees {
992
+ attendees.each { |a| attendee!(a[:attendee]) }
993
+ }
994
+ end
981
995
 
982
- def required_attendees!(attendees)
983
- nbuild[NS_EWS_TYPES].RequiredAttendees {
984
- attendees.each {|a| attendee!(a[:attendee])}
985
- }
986
- end
996
+ def optional_attendees!(attendees)
997
+ nbuild[NS_EWS_TYPES].OptionalAttendees {
998
+ attendees.each { |a| attendee!(a[:attendee]) }
999
+ }
1000
+ end
987
1001
 
988
- def optional_attendees!(attendees)
989
- nbuild[NS_EWS_TYPES].OptionalAttendees {
990
- attendees.each {|a| attendee!(a[:attendee])}
991
- }
992
- end
1002
+ def resources!(attendees)
1003
+ nbuild[NS_EWS_TYPES].Resources {
1004
+ attendees.each { |a| attendee!(a[:attendee]) }
1005
+ }
1006
+ end
993
1007
 
994
- def resources!(attendees)
995
- nbuild[NS_EWS_TYPES].Resources {
996
- attendees.each {|a| attendee!(a[:attendee])}
997
- }
998
- end
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
- # @todo support ResponseType, LastResponseTime: http://msdn.microsoft.com/en-us/library/aa580339.aspx
1001
- def attendee!(a)
1002
- nbuild[NS_EWS_TYPES].Attendee {
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
- def start!(st)
1008
- nbuild[NS_EWS_TYPES].Start(st[:text])
1009
- end
1019
+ def end!(end_time)
1020
+ nbuild[NS_EWS_TYPES].End(end_time[:text])
1021
+ end
1010
1022
 
1011
- def end!(et)
1012
- nbuild[NS_EWS_TYPES].End(et[:text])
1013
- end
1023
+ def start_date!(start_date)
1024
+ nbuild[NS_EWS_TYPES].StartDate start_date[:text]
1025
+ end
1014
1026
 
1015
- def start_date!(sd)
1016
- nbuild[NS_EWS_TYPES].StartDate sd[:text]
1017
- end
1027
+ def due_date!(due_date)
1028
+ nbuild[NS_EWS_TYPES].DueDate format_time(due_date[:text])
1029
+ end
1018
1030
 
1019
- def due_date!(dd)
1020
- nbuild[NS_EWS_TYPES].DueDate format_time(dd[:text])
1021
- end
1031
+ def location!(loc)
1032
+ nbuild[NS_EWS_TYPES].Location(loc)
1033
+ end
1022
1034
 
1023
- def location!(loc)
1024
- nbuild[NS_EWS_TYPES].Location(loc)
1025
- end
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
- def is_all_day_event!(all_day)
1028
- nbuild[NS_EWS_TYPES].IsAllDayEvent(all_day)
1029
- end
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
- def is_response_requested!(response_requested)
1032
- nbuild[NS_EWS_TYPES].IsResponseRequested(response_requested)
1033
- end
1043
+ def reminder_is_set!(reminder)
1044
+ nbuild[NS_EWS_TYPES].ReminderIsSet reminder
1045
+ end
1034
1046
 
1035
- def reminder_is_set!(reminder)
1036
- nbuild[NS_EWS_TYPES].ReminderIsSet reminder
1037
- end
1047
+ def reminder_due_by!(date)
1048
+ nbuild[NS_EWS_TYPES].ReminderDueBy format_time(date)
1049
+ end
1038
1050
 
1039
- def reminder_due_by!(date)
1040
- nbuild[NS_EWS_TYPES].ReminderDueBy format_time(date)
1041
- end
1051
+ def reminder_minutes_before_start!(minutes)
1052
+ nbuild[NS_EWS_TYPES].ReminderMinutesBeforeStart minutes
1053
+ end
1042
1054
 
1043
- def reminder_minutes_before_start!(minutes)
1044
- nbuild[NS_EWS_TYPES].ReminderMinutesBeforeStart minutes
1045
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa566143(v=exchg.150).aspx
1048
- # possible values Exchange Server 2010 = [Free, Tentative, Busy, OOF, NoData]
1049
- # Exchange Server 2013 = [Free, Tentative, Busy, OOF, WorkingElsewhere, NoData]
1050
- def legacy_free_busy_status!(state)
1051
- nbuild[NS_EWS_TYPES].LegacyFreeBusyStatus(state)
1052
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa565428(v=exchg.140).aspx
1055
- def item_changes!(changes)
1056
- nbuild.ItemChanges {
1057
- changes.each do |chg|
1058
- item_change!(chg)
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
- # @see http://msdn.microsoft.com/en-us/library/aa581081(v=exchg.140).aspx
1064
- def item_change!(change)
1065
- @nbuild[NS_EWS_TYPES].ItemChange {
1066
- updates = change.delete(:updates) # Remove updates so dispatch_item_id works correctly
1067
- dispatch_item_id!(change)
1068
- updates!(updates)
1069
- }
1070
- end
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
- # @see http://msdn.microsoft.com/en-us/library/aa581074(v=exchg.140).aspx
1073
- def updates!(updates)
1074
- @nbuild[NS_EWS_TYPES].Updates {
1075
- updates.each do |update|
1076
- dispatch_update_type!(update)
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
- # @see http://msdn.microsoft.com/en-us/library/aa581317(v=exchg.140).aspx
1082
- def append_to_item_field!(upd)
1083
- uri = upd.select {|k,v| k =~ /_uri/i}
1084
- raise EwsBadArgumentError, "Bad argument given for AppendToItemField." if uri.keys.length != 1
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
- # @see http://msdn.microsoft.com/en-us/library/aa581487(v=exchg.140).aspx
1093
- def set_item_field!(upd)
1094
- uri = upd.select {|k,v| k =~ /_uri/i}
1095
- raise EwsBadArgumentError, "Bad argument given for SetItemField." if uri.keys.length != 1
1096
- upd.delete(uri.keys.first)
1097
- @nbuild[NS_EWS_TYPES].SetItemField {
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
- # @see http://msdn.microsoft.com/en-us/library/aa580330(v=exchg.140).aspx
1104
- def delete_item_field!(upd)
1105
- uri = upd.select {|k,v| k =~ /_uri/i}
1106
- raise EwsBadArgumentError, "Bad argument given for SetItemField." if uri.keys.length != 1
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
- # @see http://msdn.microsoft.com/en-us/library/ff709497(v=exchg.140).aspx
1113
- def return_new_item_ids!(retval)
1114
- @nbuild.ReturnNewItemIds(retval)
1115
- end
1118
+ @nbuild[NS_EWS_TYPES].DeleteItemField {
1119
+ dispatch_field_uri!(uri, NS_EWS_TYPES)
1120
+ }
1121
+ end
1116
1122
 
1117
- def inline_attachment!(fa)
1118
- @nbuild[NS_EWS_TYPES].FileAttachment {
1119
- @nbuild[NS_EWS_TYPES].Name(fa.name)
1120
- @nbuild[NS_EWS_TYPES].ContentId(fa.name)
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
- def file_attachment!(fa)
1127
- @nbuild[NS_EWS_TYPES].FileAttachment {
1128
- @nbuild[NS_EWS_TYPES].Name(fa.name)
1129
- @nbuild[NS_EWS_TYPES].Content(fa.content)
1130
- }
1131
- end
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
- def item_attachment!(ia)
1134
- @nbuild[NS_EWS_TYPES].ItemAttachment {
1135
- @nbuild[NS_EWS_TYPES].Name(ia.name)
1136
- @nbuild[NS_EWS_TYPES].Item {
1137
- item_id!(ia.item)
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
- # Build the AttachmentIds element
1143
- # @see http://msdn.microsoft.com/en-us/library/aa580686.aspx
1144
- def attachment_ids!(aids)
1145
- @nbuild.AttachmentIds {
1146
- @nbuild.parent.default_namespace = @default_ns
1147
- aids.each do |aid|
1148
- attachment_id!(aid)
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
- # Build the AttachmentId element
1154
- # @see http://msdn.microsoft.com/en-us/library/aa580764.aspx
1155
- def attachment_id!(aid)
1156
- attribs = {'Id' => aid}
1157
- @nbuild[NS_EWS_TYPES].AttachmentId(attribs)
1158
- end
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
- def user_configuration_name!(cfg_name)
1161
- attribs = {'Name' => cfg_name.delete(:name)}
1162
- @nbuild[NS_EWS_MESSAGES].UserConfigurationName(attribs) {
1163
- fid = cfg_name.keys.first
1164
- self.send "#{fid}!", cfg_name[fid][:id], cfg_name[fid][:change_key]
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
- def user_configuration_properties!(cfg_prop)
1169
- @nbuild[NS_EWS_MESSAGES].UserConfigurationProperties(cfg_prop)
1170
- end
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
- # ---------------------- Helpers -------------------- #
1173
-
1174
- # A helper method to dispatch to a FolderId or DistinguishedFolderId correctly
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
- # A helper method to dispatch to an ItemId, OccurrenceItemId, or a RecurringMasterItemId
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
- # A helper method to dispatch to a AppendToItemField, SetItemField, or
1205
- # DeleteItemField
1206
- # @param [Hash] update An update of some type
1207
- def dispatch_update_type!(update)
1208
- type = update.keys.first
1209
- upd = update[type]
1210
- case type
1211
- when :append_to_item_field
1212
- append_to_item_field!(upd)
1213
- when :set_item_field
1214
- set_item_field!(upd)
1215
- when :delete_item_field
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
- # A helper to dispatch to a FieldURI, IndexedFieldURI, or an ExtendedFieldURI
1223
- # @todo Implement ExtendedFieldURI
1224
- def dispatch_field_uri!(uri, ns=NS_EWS_MESSAGES)
1225
- type = uri.keys.first
1226
- vals = uri[type].is_a?(Array) ? uri[type] : [uri[type]]
1227
- case type
1228
- when :field_uRI, :field_uri
1229
- vals.each do |val|
1230
- value = val.is_a?(Hash) ? val[type] : val
1231
- nbuild[ns].FieldURI('FieldURI' => value)
1232
- end
1233
- when :indexed_field_uRI, :indexed_field_uri
1234
- vals.each do |val|
1235
- nbuild[ns].IndexedFieldURI(
1236
- 'FieldURI' => (val[:field_uRI] || val[:field_uri]),
1237
- 'FieldIndex' => val[:field_index]
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
- when :extended_field_uRI, :extended_field_uri
1241
- vals.each do |val|
1242
- nbuild[ns].ExtendedFieldURI {
1243
- nbuild.parent['DistinguishedPropertySetId'] = val[:distinguished_property_set_id] if val[:distinguished_property_set_id]
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
- # Insert item, enforce xmlns attribute if prefix is present
1257
- def dispatch_field_item!(item, ns_prefix = nil)
1258
- item.values.first[:xmlns_attribute] = ns_prefix if ns_prefix
1259
- build_xml!(item)
1260
- end
1282
+ def room_lists!
1283
+ @nbuild[NS_EWS_MESSAGES].GetRoomLists
1284
+ end
1261
1285
 
1262
- def room_list!(cfg_prop)
1263
- @nbuild[NS_EWS_MESSAGES].RoomList {
1264
- email_address!(cfg_prop)
1265
- }
1266
- end
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
- def room_lists!
1269
- @nbuild[NS_EWS_MESSAGES].GetRoomLists
1270
- end
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
- def accept_item!(opts)
1273
- @nbuild[NS_EWS_TYPES].AcceptItem {
1274
- sensitivity!(opts)
1275
- body!(opts) if opts[:text]
1276
- reference_item_id!(opts)
1277
- }
1278
- end
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
- def tentatively_accept_item!(opts)
1281
- @nbuild[NS_EWS_TYPES].TentativelyAcceptItem {
1282
- sensitivity!(opts)
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
- def decline_item!(opts)
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
- def sensitivity!(value)
1297
- nbuild[NS_EWS_TYPES].Sensitivity(value[:sensitivity])
1298
- end
1316
+ def parent_namespace(node)
1317
+ node.parent.namespace_definitions.find { |ns| ns.prefix == NS_SOAP }
1318
+ end
1299
1319
 
1300
- private
1320
+ def set_version_header!(version)
1321
+ return unless version && version != 'none'
1301
1322
 
1302
- def parent_namespace(node)
1303
- node.parent.namespace_definitions.find {|ns| ns.prefix == NS_SOAP}
1304
- end
1323
+ nbuild[NS_EWS_TYPES].RequestServerVersion { |x|
1324
+ x.parent['Version'] = version
1325
+ }
1326
+ end
1305
1327
 
1306
- def set_version_header!(version)
1307
- if version && !(version == 'none')
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
- def set_impersonation!(type, address)
1315
- if type && type != ""
1316
- nbuild[NS_EWS_TYPES].ExchangeImpersonation {
1317
- nbuild[NS_EWS_TYPES].ConnectingSID {
1318
- nbuild[NS_EWS_TYPES].method_missing type, address
1319
- }
1320
- }
1321
- end
1322
- end
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
- # Set TimeZoneContext Header
1325
- # @param time_zone_def [Hash] !{id: time_zone_identifier, name: time_zone_name}
1326
- def set_time_zone_context_header!(time_zone_def)
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
- def meeting_time_zone!(mtz)
1335
- nbuild[NS_EWS_TYPES].MeetingTimeZone do |x|
1336
- x.parent['TimeZoneName'] = mtz[:time_zone_name] if mtz[:time_zone_name]
1337
- nbuild[NS_EWS_TYPES].BaseOffset(mtz[:base_offset][:text]) if mtz[:base_offset]
1338
- end
1339
- end
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
- # some methods need special naming so they use the '_r' suffix like 'and'
1342
- def normalize_type(type)
1343
- case type
1344
- when :and, :or, :not
1345
- "#{type}_r".to_sym
1346
- else
1347
- type
1348
- end
1349
- end
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
- def format_time(time)
1352
- case time
1353
- when Time, Date, DateTime
1354
- time.to_datetime.new_offset(0).iso8601
1355
- when String
1356
- begin
1357
- DateTime.parse(time).new_offset(0).iso8601
1358
- rescue ArgumentError
1359
- raise EwsBadArgumentError, "Invalid Time argument (#{time})"
1360
- end
1361
- else
1362
- raise EwsBadArgumentError, "Invalid Time argument (#{time})"
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
- end # EwsBuilder
1367
- end # Viewpoint::EWS::SOAP
1381
+ end
1382
+ end