viewpoint 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/README +84 -45
  2. data/Rakefile +7 -5
  3. data/TODO +6 -0
  4. data/VERSION +1 -1
  5. data/lib/exceptions/exceptions.rb +34 -0
  6. data/lib/extensions/string.rb +37 -0
  7. data/lib/model/calendar_folder.rb +45 -0
  8. data/lib/model/calendar_item.rb +145 -0
  9. data/lib/model/contact.rb +58 -0
  10. data/lib/model/contacts_folder.rb +35 -0
  11. data/lib/model/distribution_list.rb +26 -0
  12. data/lib/model/event.rb +118 -0
  13. data/lib/model/folder.rb +36 -0
  14. data/lib/model/generic_folder.rb +302 -0
  15. data/lib/model/item.rb +126 -0
  16. data/lib/model/mailbox_user.rb +107 -0
  17. data/lib/model/meeting_cancellation.rb +28 -0
  18. data/lib/{viewpoint/errors.rb → model/meeting_message.rb} +10 -14
  19. data/lib/model/meeting_request.rb +26 -0
  20. data/lib/model/meeting_response.rb +26 -0
  21. data/lib/model/message.rb +73 -0
  22. data/lib/model/model.rb +161 -0
  23. data/lib/model/search_folder.rb +36 -0
  24. data/lib/model/task.rb +62 -0
  25. data/lib/model/task_list.rb +19 -0
  26. data/lib/model/tasks_folder.rb +33 -0
  27. data/lib/soap/handsoap/builder.rb +22 -0
  28. data/lib/soap/handsoap/builders/ews_build_helpers.rb +317 -0
  29. data/lib/soap/handsoap/builders/ews_builder.rb +86 -0
  30. data/lib/soap/handsoap/ews_service.rb +646 -0
  31. data/lib/soap/handsoap/parser.rb +106 -0
  32. data/lib/soap/handsoap/parsers/ews_parser.rb +165 -0
  33. data/lib/soap/soap_provider.rb +75 -0
  34. data/lib/viewpoint.rb +98 -3
  35. data/preamble +1 -1
  36. data/test/spec/basic_functions.spec +51 -0
  37. data/test/spec/folder_subscriptions.spec +35 -0
  38. data/test/spec/folder_synchronization.spec +28 -0
  39. data/utils/ewsWSDL2rb.rb +29 -0
  40. metadata +101 -43
  41. data/lib/exchwebserv.rb +0 -6
  42. data/lib/soap/viewpoint.conf +0 -3
  43. data/lib/viewpoint/calendar.rb +0 -128
  44. data/lib/viewpoint/calendar_item.rb +0 -118
  45. data/lib/viewpoint/event.rb +0 -0
  46. data/lib/viewpoint/exchange_headers.rb +0 -49
  47. data/lib/viewpoint/exchwebserv.rb +0 -236
  48. data/lib/viewpoint/folder.rb +0 -358
  49. data/lib/viewpoint/item.rb +0 -101
  50. data/lib/viewpoint/mail.rb +0 -117
  51. data/lib/viewpoint/message.rb +0 -132
  52. data/lib/viewpoint/task.rb +0 -0
  53. data/lib/viewpoint/tasks.rb +0 -0
  54. data/lib/wsdl/defaultMappingRegistry.rb +0 -10680
  55. data/lib/wsdl/exchangeServiceBinding.rb +0 -349
  56. data/lib/wsdl/exchangeServiceTypes.rb +0 -11013
  57. data/test/spec/basic_features_spec.rb +0 -37
  58. data/test/test_client.rb +0 -13
  59. data/test/testrestrict.rb +0 -75
@@ -0,0 +1,36 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
+ #
4
+ #
5
+ # This file is part of Viewpoint.
6
+ #
7
+ # Viewpoint is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # Viewpoint is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+
21
+ module Viewpoint
22
+ module EWS
23
+ # This class represents a SearchFolderType object in the Exchange Data store.
24
+ class SearchFolder < GenericFolder
25
+
26
+ def initialize(folder)
27
+ super(folder)
28
+ define_int_var :unread_count
29
+
30
+ # @todo Handle:
31
+ # <SearchParameters/>
32
+ end
33
+
34
+ end # SearchFolder
35
+ end # EWS
36
+ end # Viewpoint
@@ -0,0 +1,62 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
+ #
4
+ #
5
+ # This file is part of Viewpoint.
6
+ #
7
+ # Viewpoint is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # Viewpoint is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+
21
+ module Viewpoint
22
+ module EWS
23
+ class Task < Item
24
+
25
+ # Create a Task in the Exchange Data Store
26
+ #
27
+ # @param [String] subject The task subject
28
+ # @param [String] body The task body
29
+ # @param [DateTime] v_start The date/time when this task begins
30
+ # @param [DateTime] v_end The date/time when this task is due
31
+ def self.create_task(subject, body, v_start = nil, v_end = nil)
32
+ item = {}
33
+ item[:subject] = {:text => subject}
34
+ item[:body] = {:text => body, :body_type => 'Text'} unless body.nil?
35
+ item[:start_date] = {:text => v_start.to_s} unless v_start.nil?
36
+ item[:due_date] = {:text => v_end.to_s} unless v_end.nil?
37
+
38
+ conn = Viewpoint::EWS::EWS.instance
39
+ resp = conn.ews.create_task_item(nil, item, 'SaveOnly')
40
+ if(resp.status == 'Success')
41
+ resp = resp.items.shift
42
+ self.new(resp[resp.keys.first])
43
+ else
44
+ raise EwsError, "Could not create task. #{resp.code}: #{resp.message}"
45
+ end
46
+ end
47
+
48
+
49
+ # Initialize an Exchange Web Services item of type Task
50
+ def initialize(ews_item)
51
+ super(ews_item)
52
+ end
53
+
54
+ private
55
+
56
+ def init_methods
57
+ super()
58
+ end
59
+
60
+ end # Task
61
+ end # EWS
62
+ end # Viewpoint
@@ -0,0 +1,19 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
+ #
4
+ #
5
+ # This file is part of Viewpoint.
6
+ #
7
+ # Viewpoint is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # Viewpoint is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
@@ -0,0 +1,33 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
+ #
4
+ #
5
+ # This file is part of Viewpoint.
6
+ #
7
+ # Viewpoint is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # Viewpoint is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+
21
+ module Viewpoint
22
+ module EWS
23
+ # This class represents a TaskFolderType object in the Exchange Data store.
24
+ class TasksFolder < GenericFolder
25
+
26
+ def initialize(folder)
27
+ super(folder)
28
+ define_int_var :unread_count
29
+ end
30
+
31
+ end # TasksFolder
32
+ end # EWS
33
+ end # Viewpoint
@@ -0,0 +1,22 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
+ #
4
+ #
5
+ # This file is part of Viewpoint.
6
+ #
7
+ # Viewpoint is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # Viewpoint is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+ # Exchange Web Service Builders
21
+ require 'builders/ews_builder.rb'
22
+
@@ -0,0 +1,317 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
+ #
4
+ #
5
+ # This file is part of Viewpoint.
6
+ #
7
+ # Viewpoint is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # Viewpoint is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+ # This is a module that is included in the main Builder that has sub builders
21
+ # that are used from multiple root nodes. It is basically just a way to do
22
+ # code reuse in a more natural way. The one difference between these functions
23
+ # and the builder functions in the EwsBuilder class is that the first parameter
24
+ # is of node type. We use that parameter to build subnodes in this module.
25
+
26
+ module Viewpoint
27
+ module EWS
28
+ module SOAP
29
+ module EwsBuildHelpers
30
+
31
+ def folder_ids!(node, folder_ids, act_as=nil, element_name="#{NS_EWS_MESSAGES}:FolderIds")
32
+ node.add(element_name) do |p|
33
+ folder_ids.each do |id|
34
+ folder_id!(p,id,act_as)
35
+ end
36
+ end
37
+ end
38
+
39
+ def folder_id!(node, folder_id, act_as = nil)
40
+ if( folder_id.is_a?(Symbol) )
41
+ # @todo add change_key support to DistinguishedFolderId
42
+ node.add("#{NS_EWS_TYPES}:DistinguishedFolderId") do |df|
43
+ df.set_attr('Id', folder_id.to_s)
44
+ # add optional delegate user
45
+ mailbox!(df, {:email_address => {:text => act_as}}, NS_EWS_TYPES) unless act_as.nil?
46
+ end
47
+ else
48
+ # @todo add change_key support to FolderId
49
+ node.add("#{NS_EWS_TYPES}:FolderId") do |fi|
50
+ fi.set_attr('Id', folder_id)
51
+ end
52
+ end
53
+ end
54
+
55
+
56
+ # For now this is the same as folder_ids! so just use that method
57
+ def parent_folder_ids!(node, folder_ids)
58
+ folder_ids!(node, folder_ids, nil, "#{NS_EWS_MESSAGES}:ParentFolderIds")
59
+ end
60
+
61
+
62
+ def item_ids!(node, item_ids)
63
+ node.add("#{NS_EWS_MESSAGES}:ItemIds") do |ids|
64
+ item_ids.each do |id|
65
+ ids.add("#{NS_EWS_TYPES}:ItemId") do |iid|
66
+ iid.set_attr('Id',id)
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ def user_id!(node, uid)
73
+ add_hierarchy!(node, uid)
74
+ end
75
+
76
+ # @param [Element] node The node we are adding Mailbox elements to.
77
+ # @param [Hash] mailbox A Mailbox formated hash inside the :mailbox key
78
+ # For example: {:email_address => 'test@test.com', :name => 'Test User'}
79
+ def mailbox!(node, mailbox, ns = NS_EWS_MESSAGES)
80
+ node.add("#{ns}:Mailbox") do |mbx|
81
+ add_hierarchy!(mbx, mailbox)
82
+ end
83
+ end
84
+
85
+ def delegate_users!(node, d_users)
86
+ node.add("#{NS_EWS_MESSAGES}:DelegateUsers") do |dus|
87
+ d_users.each do |du|
88
+ dus.add("#{NS_EWS_TYPES}:DelegateUser") do |dut|
89
+ add_hierarchy!(dut, du)
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+ def saved_item_folder_id!(node, folder_id)
96
+ node.add("#{NS_EWS_MESSAGES}:SavedItemFolderId") do |sfid|
97
+ if( folder_id.is_a?(Symbol) )
98
+ # @todo add change_key support to DistinguishedFolderId
99
+ sfid.add("#{NS_EWS_TYPES}:DistinguishedFolderId") do |df|
100
+ df.set_attr('Id', folder_id.to_s)
101
+ end
102
+ else
103
+ # @todo add change_key support to FolderId
104
+ sfid.add("#{NS_EWS_TYPES}:FolderId",folder_id)
105
+ end
106
+ end
107
+ end
108
+
109
+
110
+ # @todo This only supports the FieldURI extended property right now
111
+ def folder_shape!(node, folder_shape)
112
+ node.add("#{NS_EWS_MESSAGES}:FolderShape") do |fshape|
113
+ fshape.add("#{NS_EWS_TYPES}:BaseShape", folder_shape[:base_shape])
114
+
115
+ unless( folder_shape[:additional_props].nil? )
116
+ unless( folder_shape[:additional_props][:FieldURI].nil? )
117
+ fshape.add("#{NS_EWS_TYPES}:AdditionalProperties") do |addprops|
118
+ folder_shape[:additional_props][:FieldURI].each do |uri|
119
+ addprops.add("#{NS_EWS_TYPES}:FieldURI") { |furi| furi.set_attr('FieldURI', uri) }
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
126
+
127
+ # @todo Finish AdditionalProperties implementation
128
+ def item_shape!(node, item_shape)
129
+ node.add("#{NS_EWS_MESSAGES}:ItemShape") do |is|
130
+ is.add("#{NS_EWS_TYPES}:BaseShape", item_shape[:base_shape])
131
+ end
132
+
133
+ unless( item_shape[:additional_props].nil? )
134
+ end
135
+ end
136
+
137
+ def items!(node, items, type)
138
+ node.add("#{NS_EWS_MESSAGES}:Items") do |i|
139
+ if items.is_a? Hash
140
+ method("#{type}_item!").call(i, items)
141
+ else
142
+ items.each do |item|
143
+ method("#{type}_item!").call(i, item)
144
+ end
145
+ end
146
+ end
147
+ end
148
+
149
+ # Creates a CalendarItem Element structure. It matters to Exchange which order Items are added in
150
+ # so it loops through an order Array to make sure things are added appropriately.
151
+ # @param [Element] node The <Items> element that is the parent to all of the elements that will
152
+ # be created from the items param
153
+ # @param [Hash] item The item or items that will be added to the element in the parameter node
154
+ # @todo Make sure and watch this method for new Item elements when EWS versions change.
155
+ def message_item!(node, item)
156
+ order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received,
157
+ :size,:categories,:importance,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified,
158
+ :internet_message_headers,:date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,
159
+ :reminder_minutes_before_start,:display_cc,:display_to,:has_attachments,:extended_property,:culture,:sender,
160
+ :to_recipients,:cc_recipients,:bcc_recipients,:is_read_receipt_requested,:is_delivery_receipt_requested,
161
+ :conversation_index,:conversation_topic,:from,:internet_message_id,:is_read,:is_response_requested,:references,
162
+ :reply_to,:effective_rights,:received_by,:received_representing,:last_modified_name,:last_modified_time,
163
+ :is_associated,:web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body]
164
+
165
+ node.add("#{NS_EWS_TYPES}:Message") do |msg|
166
+ item!(msg, item, order)
167
+ end
168
+ end
169
+
170
+ # Creates a CalendarItem Element structure. It matters to Exchange which order Items are added in
171
+ # so it loops through an order Array to make sure things are added appropriately.
172
+ # @param [Element] node The <Items> element that is the parent to all of the elements that will
173
+ # be created from the items param
174
+ # @param [Hash] item The item or items that will be added to the element in the parameter node
175
+ # @todo Make sure and watch this method for new Item elements when EWS versions change.
176
+ def calendar_item!(node, item)
177
+ # For some reason MS thought it was a good idea to make order matter for Item creation. This list is the current order
178
+ # for Exchange 2003 and 2010
179
+ order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received,:size,
180
+ :categories,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified,:internet_message_headers,
181
+ :date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,:reminder_minutes_before_start,
182
+ :display_cc,:display_to,:has_attachments,:extended_property,:culture,:start,:end,:original_start,:is_all_day_event,
183
+ :legacy_free_busy_status,:location,:when,:is_meeting,:is_cancelled,:is_recurring,:meeting_request_was_sent,
184
+ :is_response_requested,:calendar_item_type,:my_response_type,:organizer,:required_attendees,:optional_attendees,
185
+ :resources,:conflicting_meeting_count,:adjacent_meeting_count,:conflicting_meetings,:adjacent_meetings,:duration,:time_zone,
186
+ :appointment_reply_time,:appointment_sequence_number,:appointment_state,:recurrence,:first_occurrence,:last_occurrence,
187
+ :modified_occurrences,:deleted_occurrences,:meeting_time_zone,:start_time_zone,:end_time_zone,:conference_type,
188
+ :allow_new_time_proposal,:is_online_meeting,:meeting_workspace_url,:net_show_url,:effective_rights,:last_modified_name,
189
+ :last_modified_time,:is_associated,:web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body]
190
+
191
+ node.add("#{NS_EWS_TYPES}:CalendarItem") do |msg|
192
+ item!(msg, item, order)
193
+ end
194
+ end
195
+
196
+ # Creates a Contact Element structure. It matters to Exchange which order Items are added in
197
+ # so it loops through an order Array to make sure things are added appropriately.
198
+ # @param [Element] node The <Items> element that is the parent to all of the elements that will
199
+ # be created from the items param
200
+ # @param [Hash] item The item or items that will be added to the element in the parameter node
201
+ # @todo Make sure and watch this method for new Item elements when EWS versions change.
202
+ def contact_item!(node,item)
203
+ order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received,:size,
204
+ :categories,:importance,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified, :internet_message_headers,
205
+ :date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,:reminder_minutes_before_start,
206
+ :display_cc,:display_to,:has_attachments,:extended_property,:culture,:effective_rights,:last_modified_name,:last_modified_time,
207
+ :is_associated,:web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body,:file_as,
208
+ :file_as_mapping,:display_name,:given_name,:initials,:middle_name,:nickname,:complete_name,:company_name,:email_addresses,
209
+ :physical_addresses,:phone_numbers,:assistant_name,:birthday,:business_home_page,:children,:companies,:contact_source,
210
+ :department,:generation,:im_addresses,:job_title,:manager,:mileage,:office_location,:postal_address_index,:profession,
211
+ :spouse_name,:surname,:wedding_anniversary,:has_picture]
212
+
213
+ node.add("#{NS_EWS_TYPES}:Contact") do |msg|
214
+ item!(msg, item, order)
215
+ end
216
+ end
217
+
218
+ # Creates a Task Element structure. It matters to Exchange which order Items are added in
219
+ # so it loops through an order Array to make sure things are added appropriately.
220
+ # @param [Element] node The <Items> element that is the parent to all of the elements that will
221
+ # be created from the items param
222
+ # @param [Hash] item The item or items that will be added to the element in the parameter node
223
+ # @todo Make sure and watch this method for new Item elements when EWS versions change.
224
+ def task_item!(node,item)
225
+ order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received,
226
+ :size,:categories,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified,:internet_message_headers,
227
+ :date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,:reminder_minutes_before_start,
228
+ :display_cc,:display_to,:has_attachments,:extended_property,:culture,:actual_work,:assigned_time,:billing_information,
229
+ :change_count,:companies,:complete_date,:contacts,:delegation_state,:delegator,:due_date,:is_assignment_editable,
230
+ :is_complete,:is_recurring,:is_team_task,:mileage,:owner,:percent_complete,:recurrence,:start_date,:status,
231
+ :status_description,:total_work,:effective_rights,:last_modified_name,:last_modified_time,:is_associated,
232
+ :web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body]
233
+
234
+ node.add("#{NS_EWS_TYPES}:Task") do |msg|
235
+ item!(msg, item, order)
236
+ end
237
+ end
238
+
239
+
240
+ # This is a convernience method used by the specific item types like
241
+ # CalendarItem and Message to create item structures. It is the shared
242
+ # code between them.
243
+ # @param [Element] node The <*Item> element that is the parent to all of the elements that will
244
+ # be created from the elems param
245
+ # @param [Hash, Array] item The subelements that will be created under node
246
+ # @param [Array<Symbol] order The order that Exchange expects these elements to appear in
247
+ # the SOAP request.
248
+ def item!(node, item, order)
249
+ order.each do |id|
250
+ if(item[id])
251
+ if(item[id].is_a?(Hash))
252
+ node.add("#{NS_EWS_TYPES}:#{id.to_s.camel_case}", item[id][:text]) do |it|
253
+ add_hierarchy!(it, item[id]) if item[id]
254
+ end
255
+ elsif(item[id].is_a?(Array))
256
+ node.add("#{NS_EWS_TYPES}:#{id.to_s.camel_case}") do |it|
257
+ item[id].each do |ai|
258
+ add_hierarchy!(it, ai)
259
+ end
260
+ end
261
+ end
262
+ end
263
+ end
264
+ end
265
+
266
+
267
+ def event_types!(node, event_types)
268
+ node.add("#{NS_EWS_TYPES}:EventTypes") do |ets|
269
+ event_types.each do |event_type|
270
+ ets.add("#{NS_EWS_TYPES}:EventType", event_type)
271
+ end
272
+ end
273
+ end
274
+
275
+ def subscription_id!(node, subscription_id)
276
+ node.add("#{NS_EWS_MESSAGES}:SubscriptionId", subscription_id)
277
+ end
278
+
279
+ def watermark!(node, watermark)
280
+ node.add("#{NS_EWS_MESSAGES}:Watermark", watermark)
281
+ end
282
+
283
+ def sync_state!(node, sync_state)
284
+ node.add("#{NS_EWS_MESSAGES}:SyncState", sync_state)
285
+ end
286
+
287
+ # Add a hierarchy of elements from hash data
288
+ # @example Hash to XML
289
+ # {:this => {:text =>'that'},'top' => {:id => '32fss', :text => 'TestText', {'middle' => 'bottom'}}}
290
+ # becomes...
291
+ # <this>that</this>
292
+ # <top Id='32fss'>
293
+ # TestText
294
+ # <middle>bottom</middle>
295
+ # </top>
296
+ def add_hierarchy!(node, e_hash, prefix = NS_EWS_TYPES)
297
+ e_hash.each_pair do |k,v|
298
+ if v.is_a? Hash
299
+ node.add("#{prefix}:#{k.to_s.camel_case}", v[:text]) do |n|
300
+ add_hierarchy!(n, v)
301
+ end
302
+ elsif v.is_a? Array
303
+ node.add("#{prefix}:#{k.to_s.camel_case}") do |n|
304
+ v.each do |i|
305
+ add_hierarchy!(n, i)
306
+ end
307
+ end
308
+ else
309
+ node.set_attr(k.to_s.camel_case, v) unless k == :text
310
+ end
311
+ end
312
+ end
313
+
314
+ end # EwsBuildHelpers
315
+ end # SOAP
316
+ end # EWS
317
+ end # Viewpoint