viewpoint 1.1.1 → 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 +13 -8
  3. data/lib/ews/calendar_accessors.rb +37 -33
  4. data/lib/ews/connection.rb +151 -124
  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 +1186 -1188
  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 -67
  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 +60 -44
  53. data/lib/ews/types/calendar_item.rb +134 -116
  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 +32 -22
  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 +82 -11
  90. data/Changelog.txt +0 -1004
@@ -1,1384 +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
- include_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 include_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 http://msdn.microsoft.com/en-us/library/aa579678(v=EXCHG.140).aspx
709
- def event_types!(evtypes)
710
- @nbuild[NS_EWS_TYPES].EventTypes {
711
- evtypes.each do |et|
712
- @nbuild[NS_EWS_TYPES].EventType(camel_case(et))
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
+ }
713
717
  end
714
- }
715
- end
716
718
 
717
- # @see http://msdn.microsoft.com/en-us/library/aa565886(v=EXCHG.140).aspx
718
- def watermark!(wmark, ns = NS_EWS_TYPES)
719
- @nbuild[ns].Watermark(wmark)
720
- end
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
+ }
726
+ end
721
727
 
722
- # @see http://msdn.microsoft.com/en-us/library/aa565201(v=EXCHG.140).aspx
723
- def timeout!(tout)
724
- @nbuild[NS_EWS_TYPES].Timeout(tout)
725
- 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
726
732
 
727
- # @see http://msdn.microsoft.com/en-us/library/aa564048(v=EXCHG.140).aspx
728
- def status_frequency!(freq)
729
- @nbuild[NS_EWS_TYPES].StatusFrequency(freq)
730
- 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
731
737
 
732
- # @see http://msdn.microsoft.com/en-us/library/aa566309(v=EXCHG.140).aspx
733
- def uRL!(url)
734
- @nbuild[NS_EWS_TYPES].URL(url)
735
- 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
736
742
 
737
- # @see http://msdn.microsoft.com/en-us/library/aa563790(v=EXCHG.140).aspx
738
- def subscription_id!(subid)
739
- @nbuild.SubscriptionId(subid)
740
- 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
741
747
 
742
- # @see http://msdn.microsoft.com/en-us/library/aa563455(v=EXCHG.140).aspx
743
- def pull_subscription_request(subopts)
744
- subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
745
- @nbuild.PullSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
746
- folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
747
- event_types!(subopts[:event_types]) if subopts[:event_types]
748
- watermark!(subopts[:watermark]) if subopts[:watermark]
749
- timeout!(subopts[:timeout]) if subopts[:timeout]
750
- }
751
- 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
752
752
 
753
- # @see http://msdn.microsoft.com/en-us/library/aa563599(v=EXCHG.140).aspx
754
- def push_subscription_request(subopts)
755
- subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
756
- @nbuild.PushSubscriptionRequest('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
- status_frequency!(subopts[:status_frequency]) if subopts[:status_frequency]
761
- uRL!(subopts[:uRL]) if subopts[:uRL]
762
- }
763
- 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
764
763
 
765
- # @see http://msdn.microsoft.com/en-us/library/ff406182(v=EXCHG.140).aspx
766
- def streaming_subscription_request(subopts)
767
- subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
768
- @nbuild.StreamingSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
769
- folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
770
- event_types!(subopts[:event_types]) if subopts[:event_types]
771
- }
772
- 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
773
775
 
774
- # @see http://msdn.microsoft.com/en-us/library/aa565970(v=EXCHG.140).aspx
775
- def sync_state!(syncstate)
776
- @nbuild.SyncState(syncstate)
777
- 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
778
784
 
779
- # @see http://msdn.microsoft.com/en-us/library/aa563785(v=EXCHG.140).aspx
780
- def ignore!(item_ids)
781
- @nbuild.Ignore {
782
- item_ids.each do |iid|
783
- item_id!(iid)
785
+ # @see http://msdn.microsoft.com/en-us/library/aa565970(v=EXCHG.140).aspx
786
+ def sync_state!(syncstate)
787
+ @nbuild.SyncState(syncstate)
784
788
  end
785
- }
786
- end
787
789
 
788
- # @see http://msdn.microsoft.com/en-us/library/aa566325(v=EXCHG.140).aspx
789
- def max_changes_returned!(cnum)
790
- @nbuild[NS_EWS_MESSAGES].MaxChangesReturned(cnum)
791
- end
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
792
798
 
793
- # @see http://msdn.microsoft.com/en-us/library/dd899531(v=EXCHG.140).aspx
794
- def sync_scope!(scope)
795
- @nbuild.SyncScope(scope)
796
- end
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)
802
+ end
797
803
 
798
- # @see http://msdn.microsoft.com/en-us/library/aa580758(v=EXCHG.140).aspx
799
- def saved_item_folder_id!(fid)
800
- @nbuild.SavedItemFolderId {
801
- dispatch_folder_id!(fid)
802
- }
803
- 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
804
808
 
805
- # @see http://msdn.microsoft.com/en-us/library/aa565652(v=exchg.140).aspx
806
- def item!(item)
807
- nbuild.Item {
808
- item.each_pair {|k,v|
809
- self.send("#{k}!", v)
810
- }
811
- }
812
- 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
813
815
 
814
- def message!(item)
815
- nbuild[NS_EWS_TYPES].Message {
816
- if item[:extended_properties]
817
- extended_properties! item.delete(:extended_properties)
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
+ }
818
823
  end
819
- item.each_pair {|k,v|
820
- self.send("#{k}!", v)
821
- }
822
- }
823
- end
824
824
 
825
- def categories!(categories)
826
- nbuild[NS_EWS_TYPES].Categories {
827
- categories.each do |c|
828
- nbuild[NS_EWS_TYPES].String(c)
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
+ }
829
832
  end
830
- }
831
- end
832
833
 
833
- def is_from_me!(ans)
834
- return unless ans
834
+ def is_read!(read) # rubocop:disable Naming/PredicatePrefix -- public API name
835
+ nbuild[NS_EWS_TYPES].IsRead(read)
836
+ end
835
837
 
836
- nbuild[NS_EWS_TYPES].IsFromMe
837
- 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
838
845
 
839
- def mime_content!(mime_content)
840
- @nbuild[NS_EWS_TYPES].MimeContent(mime_content)
841
- end
846
+ def calendar_item_type!(type)
847
+ nbuild[NS_EWS_TYPES].CalendarItemType(type)
848
+ end
842
849
 
843
- def is_read!(read)
844
- nbuild[NS_EWS_TYPES].IsRead(read)
845
- 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
846
857
 
847
- def calendar_item!(item)
848
- nbuild[NS_EWS_TYPES].CalendarItem {
849
- item.each_pair {|k,v|
850
- self.send("#{k}!", v)
851
- }
852
- }
853
- 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
854
865
 
855
- def calendar_item_type!(type)
856
- nbuild[NS_EWS_TYPES].CalendarItemType(type)
857
- 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
858
873
 
859
- def recurrence!(item)
860
- nbuild[NS_EWS_TYPES].Recurrence {
861
- item.each_pair { |k, v|
862
- self.send("#{k}!", v)
863
- }
864
- }
865
- end
874
+ def interval!(num)
875
+ nbuild[NS_EWS_TYPES].Interval(num)
876
+ end
866
877
 
867
- def daily_recurrence!(item)
868
- nbuild[NS_EWS_TYPES].DailyRecurrence {
869
- item.each_pair { |k, v|
870
- self.send("#{k}!", v)
871
- }
872
- }
873
- 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
874
885
 
875
- def weekly_recurrence!(item)
876
- nbuild[NS_EWS_TYPES].WeeklyRecurrence {
877
- item.each_pair { |k, v|
878
- self.send("#{k}!", v)
879
- }
880
- }
881
- 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
882
893
 
883
- def interval!(num)
884
- nbuild[NS_EWS_TYPES].Interval(num)
885
- end
894
+ def number_of_occurrences!(count)
895
+ nbuild[NS_EWS_TYPES].NumberOfOccurrences(count)
896
+ end
886
897
 
887
- def no_end_recurrence!(item)
888
- nbuild[NS_EWS_TYPES].NoEndRecurrence {
889
- item.each_pair { |k, v|
890
- self.send("#{k}!", v)
891
- }
892
- }
893
- 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
894
905
 
895
- def numbered_recurrence!(item)
896
- nbuild[NS_EWS_TYPES].NumberedRecurrence {
897
- item.each_pair { |k, v|
898
- self.send("#{k}!", v)
899
- }
900
- }
901
- end
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
902
913
 
903
- def number_of_occurrences!(count)
904
- nbuild[NS_EWS_TYPES].NumberOfOccurrences(count)
905
- 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
906
921
 
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
907
929
 
908
- def task!(item)
909
- nbuild[NS_EWS_TYPES].Task {
910
- item.each_pair {|k, v|
911
- self.send("#{k}!", v)
912
- }
913
- }
914
- 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
915
936
 
916
- def forward_item!(item)
917
- nbuild[NS_EWS_TYPES].ForwardItem {
918
- item.each_pair {|k,v|
919
- self.send("#{k}!", v)
920
- }
921
- }
922
- end
937
+ def subject!(sub)
938
+ nbuild[NS_EWS_TYPES].Subject(sub)
939
+ end
923
940
 
924
- def reply_to_item!(item)
925
- nbuild[NS_EWS_TYPES].ReplyToItem {
926
- item.each_pair {|k,v|
927
- self.send("#{k}!", v)
928
- }
929
- }
930
- end
941
+ def importance!(sub)
942
+ nbuild[NS_EWS_TYPES].Importance(sub)
943
+ end
931
944
 
932
- def reply_all_to_item!(item)
933
- nbuild[NS_EWS_TYPES].ReplyAllToItem {
934
- item.each_pair {|k,v|
935
- self.send("#{k}!", v)
936
- }
937
- }
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 reference_item_id!(id)
941
- nbuild[NS_EWS_TYPES].ReferenceItemId {|x|
942
- x.parent['Id'] = id[:id]
943
- x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
944
- }
945
- 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
946
957
 
947
- def subject!(sub)
948
- nbuild[NS_EWS_TYPES].Subject(sub)
949
- 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
950
963
 
951
- def importance!(sub)
952
- nbuild[NS_EWS_TYPES].Importance(sub)
953
- 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
954
971
 
955
- def body!(b)
956
- nbuild[NS_EWS_TYPES].Body(b[:text]) {|x|
957
- x.parent['BodyType'] = b[:body_type] if b[:body_type]
958
- }
959
- end
972
+ def cc_recipients!(recipients)
973
+ nbuild[NS_EWS_TYPES].CcRecipients {
974
+ recipients.each { |mbox| mailbox!(mbox[:mailbox]) }
975
+ }
976
+ end
960
977
 
961
- def new_body_content!(b)
962
- nbuild[NS_EWS_TYPES].NewBodyContent(b[:text]) {|x|
963
- x.parent['BodyType'] = b[:body_type] if b[:body_type]
964
- }
965
- end
978
+ def bcc_recipients!(recipients)
979
+ nbuild[NS_EWS_TYPES].BccRecipients {
980
+ recipients.each { |mbox| mailbox!(mbox[:mailbox]) }
981
+ }
982
+ end
966
983
 
967
- # @see http://msdn.microsoft.com/en-us/library/aa563719(v=exchg.140).aspx
968
- # @param [Array] r An array of Mailbox type hashes to send to #mailbox!
969
- def to_recipients!(r)
970
- nbuild[NS_EWS_TYPES].ToRecipients {
971
- r.each {|mbox| mailbox!(mbox[:mailbox]) }
972
- }
973
- end
984
+ def from!(sender)
985
+ nbuild[NS_EWS_TYPES].From {
986
+ mailbox! sender
987
+ }
988
+ end
974
989
 
975
- def cc_recipients!(r)
976
- nbuild[NS_EWS_TYPES].CcRecipients {
977
- r.each {|mbox| mailbox!(mbox[:mailbox]) }
978
- }
979
- end
990
+ def required_attendees!(attendees)
991
+ nbuild[NS_EWS_TYPES].RequiredAttendees {
992
+ attendees.each { |a| attendee!(a[:attendee]) }
993
+ }
994
+ end
980
995
 
981
- def bcc_recipients!(r)
982
- nbuild[NS_EWS_TYPES].BccRecipients {
983
- r.each {|mbox| mailbox!(mbox[:mailbox]) }
984
- }
985
- end
996
+ def optional_attendees!(attendees)
997
+ nbuild[NS_EWS_TYPES].OptionalAttendees {
998
+ attendees.each { |a| attendee!(a[:attendee]) }
999
+ }
1000
+ end
986
1001
 
987
- def from!(f)
988
- nbuild[NS_EWS_TYPES].From {
989
- mailbox! f[:mailbox]
990
- }
991
- end
1002
+ def resources!(attendees)
1003
+ nbuild[NS_EWS_TYPES].Resources {
1004
+ attendees.each { |a| attendee!(a[:attendee]) }
1005
+ }
1006
+ end
992
1007
 
993
- def sender!(f)
994
- nbuild[NS_EWS_TYPES].Sender {
995
- mailbox! f[:mailbox]
996
- }
997
- 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
998
1014
 
999
- def required_attendees!(attendees)
1000
- nbuild[NS_EWS_TYPES].RequiredAttendees {
1001
- attendees.each {|a| attendee!(a[:attendee])}
1002
- }
1003
- end
1015
+ def start!(start_time)
1016
+ nbuild[NS_EWS_TYPES].Start(start_time[:text])
1017
+ end
1004
1018
 
1005
- def optional_attendees!(attendees)
1006
- nbuild[NS_EWS_TYPES].OptionalAttendees {
1007
- attendees.each {|a| attendee!(a[:attendee])}
1008
- }
1009
- end
1019
+ def end!(end_time)
1020
+ nbuild[NS_EWS_TYPES].End(end_time[:text])
1021
+ end
1010
1022
 
1011
- def resources!(attendees)
1012
- nbuild[NS_EWS_TYPES].Resources {
1013
- attendees.each {|a| attendee!(a[:attendee])}
1014
- }
1015
- end
1023
+ def start_date!(start_date)
1024
+ nbuild[NS_EWS_TYPES].StartDate start_date[:text]
1025
+ end
1016
1026
 
1017
- # @todo support ResponseType, LastResponseTime: http://msdn.microsoft.com/en-us/library/aa580339.aspx
1018
- def attendee!(a)
1019
- nbuild[NS_EWS_TYPES].Attendee {
1020
- mailbox!(a[:mailbox])
1021
- }
1022
- end
1027
+ def due_date!(due_date)
1028
+ nbuild[NS_EWS_TYPES].DueDate format_time(due_date[:text])
1029
+ end
1023
1030
 
1024
- def start!(st)
1025
- nbuild[NS_EWS_TYPES].Start(st[:text])
1026
- end
1031
+ def location!(loc)
1032
+ nbuild[NS_EWS_TYPES].Location(loc)
1033
+ end
1027
1034
 
1028
- def end!(et)
1029
- nbuild[NS_EWS_TYPES].End(et[:text])
1030
- 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
1031
1038
 
1032
- def start_date!(sd)
1033
- nbuild[NS_EWS_TYPES].StartDate sd[:text]
1034
- 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
1035
1042
 
1036
- def due_date!(dd)
1037
- nbuild[NS_EWS_TYPES].DueDate format_time(dd[:text])
1038
- end
1043
+ def reminder_is_set!(reminder)
1044
+ nbuild[NS_EWS_TYPES].ReminderIsSet reminder
1045
+ end
1039
1046
 
1040
- def location!(loc)
1041
- nbuild[NS_EWS_TYPES].Location(loc)
1042
- end
1047
+ def reminder_due_by!(date)
1048
+ nbuild[NS_EWS_TYPES].ReminderDueBy format_time(date)
1049
+ end
1043
1050
 
1044
- def is_all_day_event!(all_day)
1045
- nbuild[NS_EWS_TYPES].IsAllDayEvent(all_day)
1046
- end
1051
+ def reminder_minutes_before_start!(minutes)
1052
+ nbuild[NS_EWS_TYPES].ReminderMinutesBeforeStart minutes
1053
+ end
1047
1054
 
1048
- def is_response_requested!(response_requested)
1049
- nbuild[NS_EWS_TYPES].IsResponseRequested(response_requested)
1050
- 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
1051
1061
 
1052
- def reminder_is_set!(reminder)
1053
- nbuild[NS_EWS_TYPES].ReminderIsSet reminder
1054
- 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
1055
1070
 
1056
- def reminder_due_by!(date)
1057
- nbuild[NS_EWS_TYPES].ReminderDueBy format_time(date)
1058
- end
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
+ }
1078
+ end
1059
1079
 
1060
- def reminder_minutes_before_start!(minutes)
1061
- nbuild[NS_EWS_TYPES].ReminderMinutesBeforeStart minutes
1062
- 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
1063
1088
 
1064
- # @see http://msdn.microsoft.com/en-us/library/aa566143(v=exchg.150).aspx
1065
- # possible values Exchange Server 2010 = [Free, Tentative, Busy, OOF, NoData]
1066
- # Exchange Server 2013 = [Free, Tentative, Busy, OOF, WorkingElsewhere, NoData]
1067
- def legacy_free_busy_status!(state)
1068
- nbuild[NS_EWS_TYPES].LegacyFreeBusyStatus(state)
1069
- end
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
1070
1093
 
1071
- # @see http://msdn.microsoft.com/en-us/library/aa565428(v=exchg.140).aspx
1072
- def item_changes!(changes)
1073
- nbuild.ItemChanges {
1074
- changes.each do |chg|
1075
- item_change!(chg)
1094
+ upd.delete(uri.keys.first)
1095
+ @nbuild.AppendToItemField {
1096
+ dispatch_field_uri!(uri)
1097
+ dispatch_field_item!(upd)
1098
+ }
1076
1099
  end
1077
- }
1078
- end
1079
1100
 
1080
- # @see http://msdn.microsoft.com/en-us/library/aa581081(v=exchg.140).aspx
1081
- def item_change!(change)
1082
- @nbuild[NS_EWS_TYPES].ItemChange {
1083
- updates = change.delete(:updates) # Remove updates so dispatch_item_id works correctly
1084
- dispatch_item_id!(change)
1085
- updates!(updates)
1086
- }
1087
- 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
1088
1105
 
1089
- # @see http://msdn.microsoft.com/en-us/library/aa581074(v=exchg.140).aspx
1090
- def updates!(updates)
1091
- @nbuild[NS_EWS_TYPES].Updates {
1092
- updates.each do |update|
1093
- dispatch_update_type!(update)
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
+ }
1094
1111
  end
1095
- }
1096
- end
1097
1112
 
1098
- # @see http://msdn.microsoft.com/en-us/library/aa581317(v=exchg.140).aspx
1099
- def append_to_item_field!(upd)
1100
- uri = upd.select {|k,v| k =~ /_uri/i}
1101
- raise EwsBadArgumentError, "Bad argument given for AppendToItemField." if uri.keys.length != 1
1102
- upd.delete(uri.keys.first)
1103
- @nbuild.AppendToItemField {
1104
- dispatch_field_uri!(uri)
1105
- dispatch_field_item!(upd)
1106
- }
1107
- 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
1108
1117
 
1109
- # @see http://msdn.microsoft.com/en-us/library/aa581487(v=exchg.140).aspx
1110
- def set_item_field!(upd)
1111
- uri = upd.select {|k,v| k =~ /_uri/i}
1112
- raise EwsBadArgumentError, "Bad argument given for SetItemField." if uri.keys.length != 1
1113
- upd.delete(uri.keys.first)
1114
- @nbuild[NS_EWS_TYPES].SetItemField {
1115
- dispatch_field_uri!(uri, NS_EWS_TYPES)
1116
- dispatch_field_item!(upd, NS_EWS_TYPES)
1117
- }
1118
- end
1118
+ @nbuild[NS_EWS_TYPES].DeleteItemField {
1119
+ dispatch_field_uri!(uri, NS_EWS_TYPES)
1120
+ }
1121
+ end
1119
1122
 
1120
- # @see http://msdn.microsoft.com/en-us/library/aa580330(v=exchg.140).aspx
1121
- def delete_item_field!(upd)
1122
- uri = upd.select {|k,v| k =~ /_uri/i}
1123
- raise EwsBadArgumentError, "Bad argument given for SetItemField." if uri.keys.length != 1
1124
- @nbuild[NS_EWS_TYPES].DeleteItemField {
1125
- dispatch_field_uri!(uri, NS_EWS_TYPES)
1126
- }
1127
- 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
1128
1127
 
1129
- # @see http://msdn.microsoft.com/en-us/library/ff709497(v=exchg.140).aspx
1130
- def return_new_item_ids!(retval)
1131
- @nbuild.ReturnNewItemIds(retval)
1132
- 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
1133
1136
 
1134
- def inline_attachment!(fa)
1135
- @nbuild[NS_EWS_TYPES].FileAttachment {
1136
- @nbuild[NS_EWS_TYPES].Name(fa.name)
1137
- @nbuild[NS_EWS_TYPES].ContentId(fa.name)
1138
- @nbuild[NS_EWS_TYPES].IsInline(true)
1139
- @nbuild[NS_EWS_TYPES].Content(fa.content)
1140
- }
1141
- 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
1142
1143
 
1143
- def file_attachment!(fa)
1144
- @nbuild[NS_EWS_TYPES].FileAttachment {
1145
- @nbuild[NS_EWS_TYPES].Name(fa.name)
1146
- @nbuild[NS_EWS_TYPES].Content(fa.content)
1147
- }
1148
- end
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
+ }
1151
+ end
1149
1152
 
1150
- def item_attachment!(ia)
1151
- @nbuild[NS_EWS_TYPES].ItemAttachment {
1152
- @nbuild[NS_EWS_TYPES].Name(ia.name)
1153
- @nbuild[NS_EWS_TYPES].Item {
1154
- item_id!(ia.item)
1155
- }
1156
- }
1157
- 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
1158
1163
 
1159
- # Build the AttachmentIds element
1160
- # @see http://msdn.microsoft.com/en-us/library/aa580686.aspx
1161
- def attachment_ids!(aids)
1162
- @nbuild.AttachmentIds {
1163
- @nbuild.parent.default_namespace = @default_ns
1164
- aids.each do |aid|
1165
- attachment_id!(aid)
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)
1166
1169
  end
1167
- }
1168
- end
1169
1170
 
1170
- # Build the AttachmentId element
1171
- # @see http://msdn.microsoft.com/en-us/library/aa580764.aspx
1172
- def attachment_id!(aid)
1173
- attribs = {'Id' => aid}
1174
- @nbuild[NS_EWS_TYPES].AttachmentId(attribs)
1175
- 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
1176
1178
 
1177
- def user_configuration_name!(cfg_name)
1178
- attribs = {'Name' => cfg_name.delete(:name)}
1179
- @nbuild[NS_EWS_MESSAGES].UserConfigurationName(attribs) {
1180
- fid = cfg_name.keys.first
1181
- self.send "#{fid}!", cfg_name[fid][:id], cfg_name[fid][:change_key]
1182
- }
1183
- end
1179
+ def user_configuration_properties!(cfg_prop)
1180
+ @nbuild[NS_EWS_MESSAGES].UserConfigurationProperties(cfg_prop)
1181
+ end
1184
1182
 
1185
- def user_configuration_properties!(cfg_prop)
1186
- @nbuild[NS_EWS_MESSAGES].UserConfigurationProperties(cfg_prop)
1187
- end
1183
+ # ---------------------- Helpers -------------------- #
1188
1184
 
1189
- # ---------------------- Helpers -------------------- #
1190
-
1191
- # A helper method to dispatch to a FolderId or DistinguishedFolderId correctly
1192
- # @param [Hash] fid A folder_id
1193
- # Ex: {:id => myid, :change_key => ck}
1194
- def dispatch_folder_id!(fid)
1195
- if(fid[:id].is_a?(String))
1196
- folder_id!(fid[:id], fid[:change_key])
1197
- elsif(fid[:id].is_a?(Symbol))
1198
- distinguished_folder_id!(fid[:id], fid[:change_key], fid[:act_as])
1199
- else
1200
- raise EwsBadArgumentError, "Bad argument given for a FolderId. #{fid[:id].class}"
1201
- end
1202
- 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
1203
1197
 
1204
- # A helper method to dispatch to an ItemId, OccurrenceItemId, or a RecurringMasterItemId
1205
- # @param [Hash] iid The item id of some type
1206
- def dispatch_item_id!(iid)
1207
- type = iid.keys.first
1208
- item = iid[type]
1209
- case type
1210
- when :item_id
1211
- item_id!(item)
1212
- when :occurrence_item_id
1213
- occurrence_item_id!(item)
1214
- when :recurring_master_item_id
1215
- recurring_master_item_id!(item)
1216
- else
1217
- raise EwsBadArgumentError, "Bad ItemId type. #{type}"
1218
- end
1219
- end
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
1220
1214
 
1221
- # A helper method to dispatch to a AppendToItemField, SetItemField, or
1222
- # DeleteItemField
1223
- # @param [Hash] update An update of some type
1224
- def dispatch_update_type!(update)
1225
- type = update.keys.first
1226
- upd = update[type]
1227
- case type
1228
- when :append_to_item_field
1229
- append_to_item_field!(upd)
1230
- when :set_item_field
1231
- set_item_field!(upd)
1232
- when :delete_item_field
1233
- delete_item_field!(upd)
1234
- else
1235
- raise EwsBadArgumentError, "Bad Update type. #{type}"
1236
- end
1237
- end
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
1238
1232
 
1239
- # A helper to dispatch to a FieldURI, IndexedFieldURI, or an ExtendedFieldURI
1240
- # @todo Implement ExtendedFieldURI
1241
- def dispatch_field_uri!(uri, ns=NS_EWS_MESSAGES)
1242
- type = uri.keys.first
1243
- vals = uri[type].is_a?(Array) ? uri[type] : [uri[type]]
1244
- case type
1245
- when :field_uRI, :field_uri
1246
- vals.each do |val|
1247
- value = val.is_a?(Hash) ? val[type] : val
1248
- nbuild[ns].FieldURI('FieldURI' => value)
1249
- end
1250
- when :indexed_field_uRI, :indexed_field_uri
1251
- vals.each do |val|
1252
- nbuild[ns].IndexedFieldURI(
1253
- 'FieldURI' => (val[:field_uRI] || val[:field_uri]),
1254
- 'FieldIndex' => val[:field_index]
1255
- )
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)
1256
1274
  end
1257
- when :extended_field_uRI, :extended_field_uri
1258
- vals.each do |val|
1259
- nbuild[ns].ExtendedFieldURI {
1260
- nbuild.parent['DistinguishedPropertySetId'] = val[:distinguished_property_set_id] if val[:distinguished_property_set_id]
1261
- nbuild.parent['PropertySetId'] = val[:property_set_id] if val[:property_set_id]
1262
- nbuild.parent['PropertyTag'] = val[:property_tag] if val[:property_tag]
1263
- nbuild.parent['PropertyName'] = val[:property_name] if val[:property_name]
1264
- nbuild.parent['PropertyId'] = val[:property_id] if val[:property_id]
1265
- 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)
1266
1279
  }
1267
1280
  end
1268
- else
1269
- raise EwsBadArgumentError, "Bad URI type. #{type}"
1270
- end
1271
- end
1272
1281
 
1273
- # Insert item, enforce xmlns attribute if prefix is present
1274
- def dispatch_field_item!(item, ns_prefix = nil)
1275
- item.values.first[:xmlns_attribute] = ns_prefix if ns_prefix
1276
- build_xml!(item)
1277
- end
1282
+ def room_lists!
1283
+ @nbuild[NS_EWS_MESSAGES].GetRoomLists
1284
+ end
1278
1285
 
1279
- def room_list!(cfg_prop)
1280
- @nbuild[NS_EWS_MESSAGES].RoomList {
1281
- email_address!(cfg_prop)
1282
- }
1283
- 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
1284
1293
 
1285
- def room_lists!
1286
- @nbuild[NS_EWS_MESSAGES].GetRoomLists
1287
- 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
1288
1301
 
1289
- def accept_item!(opts)
1290
- @nbuild[NS_EWS_TYPES].AcceptItem {
1291
- sensitivity!(opts)
1292
- body!(opts) if opts[:text]
1293
- reference_item_id!(opts)
1294
- }
1295
- 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
1296
1309
 
1297
- def tentatively_accept_item!(opts)
1298
- @nbuild[NS_EWS_TYPES].TentativelyAcceptItem {
1299
- sensitivity!(opts)
1300
- body!(opts) if opts[:text]
1301
- reference_item_id!(opts)
1302
- }
1303
- end
1310
+ def sensitivity!(value)
1311
+ nbuild[NS_EWS_TYPES].Sensitivity(value[:sensitivity])
1312
+ end
1304
1313
 
1305
- def decline_item!(opts)
1306
- @nbuild[NS_EWS_TYPES].DeclineItem {
1307
- sensitivity!(opts)
1308
- body!(opts) if opts[:text]
1309
- reference_item_id!(opts)
1310
- }
1311
- end
1314
+ private
1312
1315
 
1313
- def sensitivity!(value)
1314
- nbuild[NS_EWS_TYPES].Sensitivity(value[:sensitivity])
1315
- end
1316
+ def parent_namespace(node)
1317
+ node.parent.namespace_definitions.find { |ns| ns.prefix == NS_SOAP }
1318
+ end
1316
1319
 
1317
- private
1320
+ def set_version_header!(version)
1321
+ return unless version && version != 'none'
1318
1322
 
1319
- def parent_namespace(node)
1320
- node.parent.namespace_definitions.find {|ns| ns.prefix == NS_SOAP}
1321
- end
1323
+ nbuild[NS_EWS_TYPES].RequestServerVersion { |x|
1324
+ x.parent['Version'] = version
1325
+ }
1326
+ end
1322
1327
 
1323
- def set_version_header!(version)
1324
- if version && !(version == 'none')
1325
- nbuild[NS_EWS_TYPES].RequestServerVersion {|x|
1326
- x.parent['Version'] = version
1327
- }
1328
- end
1329
- end
1328
+ def set_impersonation!(type, address)
1329
+ return unless type && type != ''
1330
1330
 
1331
- def set_impersonation!(type, address)
1332
- if type && type != ""
1333
- nbuild[NS_EWS_TYPES].ExchangeImpersonation {
1334
- nbuild[NS_EWS_TYPES].ConnectingSID {
1335
- nbuild[NS_EWS_TYPES].method_missing type, address
1336
- }
1337
- }
1338
- end
1339
- 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
1340
1337
 
1341
- # Set TimeZoneContext Header
1342
- # @param time_zone_def [Hash] !{id: time_zone_identifier, name: time_zone_name}
1343
- def set_time_zone_context_header!(time_zone_def)
1344
- if time_zone_def
1345
- nbuild[NS_EWS_TYPES].TimeZoneContext do
1346
- time_zone_definition! time_zone_def
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
1342
+
1343
+ nbuild[NS_EWS_TYPES].TimeZoneContext do
1344
+ time_zone_definition! time_zone_def
1345
+ end
1347
1346
  end
1348
- end
1349
- end
1350
1347
 
1351
- def meeting_time_zone!(mtz)
1352
- nbuild[NS_EWS_TYPES].MeetingTimeZone do |x|
1353
- x.parent['TimeZoneName'] = mtz[:time_zone_name] if mtz[:time_zone_name]
1354
- nbuild[NS_EWS_TYPES].BaseOffset(mtz[:base_offset][:text]) if mtz[:base_offset]
1355
- end
1356
- 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
1357
1354
 
1358
- # some methods need special naming so they use the '_r' suffix like 'and'
1359
- def normalize_type(type)
1360
- case type
1361
- when :and, :or, :not
1362
- "#{type}_r".to_sym
1363
- else
1364
- type
1365
- end
1366
- 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
1367
1364
 
1368
- def format_time(time)
1369
- case time
1370
- when Time, Date, DateTime
1371
- time.to_datetime.new_offset(0).iso8601
1372
- when String
1373
- begin
1374
- DateTime.parse(time).new_offset(0).iso8601
1375
- rescue ArgumentError
1376
- raise EwsBadArgumentError, "Invalid Time argument (#{time})"
1377
- end
1378
- else
1379
- 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
1380
1379
  end
1381
1380
  end
1382
-
1383
- end # EwsBuilder
1384
- end # Viewpoint::EWS::SOAP
1381
+ end
1382
+ end