viewpoint 0.1.27 → 1.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/README.md +196 -0
  2. data/lib/ews/calendar_accessors.rb +34 -0
  3. data/lib/ews/connection.rb +117 -0
  4. data/lib/ews/connection_helper.rb +35 -0
  5. data/lib/ews/ews_client.rb +71 -0
  6. data/lib/ews/exceptions/exceptions.rb +59 -0
  7. data/lib/ews/folder_accessors.rb +199 -0
  8. data/lib/ews/item_accessors.rb +157 -0
  9. data/lib/ews/mailbox_accessors.rb +87 -0
  10. data/lib/ews/message_accessors.rb +86 -0
  11. data/lib/ews/push_subscription_accessors.rb +33 -0
  12. data/lib/ews/soap.rb +63 -0
  13. data/lib/ews/soap/builders/ews_builder.rb +1011 -0
  14. data/lib/ews/soap/ews_response.rb +83 -0
  15. data/lib/ews/soap/ews_soap_availability_response.rb +58 -0
  16. data/lib/ews/soap/ews_soap_free_busy_response.rb +109 -0
  17. data/lib/ews/soap/ews_soap_response.rb +103 -0
  18. data/lib/ews/soap/exchange_availability.rb +61 -0
  19. data/lib/ews/soap/exchange_data_services.rb +742 -0
  20. data/lib/ews/soap/exchange_notification.rb +146 -0
  21. data/lib/ews/soap/exchange_user_configuration.rb +33 -0
  22. data/lib/ews/soap/exchange_web_service.rb +294 -0
  23. data/lib/{model/attendee.rb → ews/soap/parsers/ews_parser.rb} +20 -14
  24. data/lib/ews/soap/parsers/ews_sax_document.rb +66 -0
  25. data/lib/ews/soap/response_message.rb +78 -0
  26. data/lib/ews/soap/responses/create_attachment_response_message.rb +46 -0
  27. data/lib/{model/meeting_message.rb → ews/soap/responses/create_item_response_message.rb} +7 -10
  28. data/lib/ews/soap/responses/find_item_response_message.rb +80 -0
  29. data/lib/ews/soap/responses/get_events_response_message.rb +53 -0
  30. data/lib/ews/soap/responses/send_notification_response_message.rb +58 -0
  31. data/lib/{model/attachment.rb → ews/soap/responses/subscribe_response_message.rb} +17 -13
  32. data/lib/ews/templates/forward_item.rb +24 -0
  33. data/lib/ews/templates/message.rb +66 -0
  34. data/lib/ews/templates/reply_to_item.rb +25 -0
  35. data/lib/ews/types.rb +146 -0
  36. data/lib/ews/types/attachment.rb +77 -0
  37. data/lib/{model/meeting_cancellation.rb → ews/types/attendee.rb} +9 -8
  38. data/lib/ews/types/calendar_folder.rb +8 -0
  39. data/lib/ews/types/calendar_item.rb +37 -0
  40. data/lib/ews/types/contact.rb +7 -0
  41. data/lib/ews/types/contacts_folder.rb +8 -0
  42. data/lib/ews/types/copied_event.rb +51 -0
  43. data/lib/{soap/handsoap/builder.rb → ews/types/created_event.rb} +5 -2
  44. data/lib/{model/meeting_response.rb → ews/types/deleted_event.rb} +6 -6
  45. data/lib/ews/types/distribution_list.rb +7 -0
  46. data/lib/ews/types/event.rb +62 -0
  47. data/lib/ews/types/file_attachment.rb +65 -0
  48. data/lib/ews/types/folder.rb +60 -0
  49. data/lib/{model/distribution_list.rb → ews/types/free_busy_changed_event.rb} +6 -6
  50. data/lib/ews/types/generic_folder.rb +352 -0
  51. data/lib/ews/types/item.rb +381 -0
  52. data/lib/ews/types/item_attachment.rb +46 -0
  53. data/lib/{model → ews/types}/item_field_uri_map.rb +2 -2
  54. data/lib/ews/types/mailbox_user.rb +156 -0
  55. data/lib/ews/types/meeting_cancellation.rb +7 -0
  56. data/lib/ews/types/meeting_message.rb +7 -0
  57. data/lib/ews/types/meeting_request.rb +7 -0
  58. data/lib/ews/types/meeting_response.rb +7 -0
  59. data/lib/ews/types/message.rb +7 -0
  60. data/lib/ews/types/modified_event.rb +48 -0
  61. data/lib/{model/item_attachment.rb → ews/types/moved_event.rb} +33 -15
  62. data/lib/ews/types/new_mail_event.rb +24 -0
  63. data/lib/ews/types/out_of_office.rb +147 -0
  64. data/lib/ews/types/search_folder.rb +8 -0
  65. data/lib/ews/types/status_event.rb +39 -0
  66. data/lib/ews/types/task.rb +7 -0
  67. data/lib/ews/types/tasks_folder.rb +8 -0
  68. data/lib/viewpoint.rb +82 -106
  69. metadata +99 -67
  70. data/README +0 -114
  71. data/lib/exceptions/exceptions.rb +0 -46
  72. data/lib/model/calendar_folder.rb +0 -67
  73. data/lib/model/calendar_item.rb +0 -267
  74. data/lib/model/contact.rb +0 -238
  75. data/lib/model/contacts_folder.rb +0 -46
  76. data/lib/model/event.rb +0 -116
  77. data/lib/model/file_attachment.rb +0 -53
  78. data/lib/model/folder.rb +0 -47
  79. data/lib/model/generic_folder.rb +0 -471
  80. data/lib/model/item.rb +0 -313
  81. data/lib/model/mailbox_user.rb +0 -146
  82. data/lib/model/meeting_request.rb +0 -39
  83. data/lib/model/message.rb +0 -142
  84. data/lib/model/model.rb +0 -269
  85. data/lib/model/search_folder.rb +0 -48
  86. data/lib/model/task.rb +0 -121
  87. data/lib/model/tasks_folder.rb +0 -44
  88. data/lib/soap/handsoap/builders/ews_build_helpers.rb +0 -383
  89. data/lib/soap/handsoap/builders/ews_builder.rb +0 -146
  90. data/lib/soap/handsoap/ews_service.rb +0 -813
  91. data/lib/soap/handsoap/parser.rb +0 -104
  92. data/lib/soap/handsoap/parsers/ews_parser.rb +0 -246
  93. data/lib/soap/soap_provider.rb +0 -64
@@ -1,48 +0,0 @@
1
- =begin
2
- This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
-
4
- Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License");
7
- you may not use this file except in compliance with the License.
8
- You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- =end
18
-
19
- module Viewpoint
20
- module EWS
21
- # This class represents a SearchFolderType object in the Exchange Data store.
22
- class SearchFolder < GenericFolder
23
-
24
- # Find folders of type SearchFolder
25
- # @see GenericFolder.find_folders
26
- # @param [String,Symbol] root An folder id, either a DistinguishedFolderId (must me a Symbol)
27
- # or a FolderId (String). SearchFolders must be created under the :searchfolders distinguished
28
- # id so we might as well only search from there.
29
- # @param [String] traversal Shallow/Deep/SoftDeleted
30
- # @param [String] shape the shape to return IdOnly/Default/AllProperties
31
- # @param [optional, String] folder_type an optional folder type to limit the search to like 'IPF.Task'
32
- # @return [Array] Returns an Array of Folder or subclasses of Folder
33
- def self.find_folders(root = :searchfolders, traversal = 'Deep', shape = 'Default', folder_type = nil)
34
- super(root, traversal, shape, folder_type)
35
- end
36
-
37
-
38
- def initialize(folder)
39
- super(folder)
40
- define_int_var :unread_count
41
-
42
- # @todo Handle:
43
- # <SearchParameters/>
44
- end
45
-
46
- end # SearchFolder
47
- end # EWS
48
- end # Viewpoint
@@ -1,121 +0,0 @@
1
- =begin
2
- This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
-
4
- Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License");
7
- you may not use this file except in compliance with the License.
8
- You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- =end
18
-
19
- module Viewpoint
20
- module EWS
21
- class Task < Item
22
-
23
-
24
- # Create a Task in the Exchange Data Store from a hash
25
- # @param [Hash] item A Hash of values based on values found here:
26
- # http://msdn.microsoft.com/en-us/library/aa563930.aspx
27
- # @param [String, Symbol] folder_id The folder to create this item in. Either a
28
- # DistinguishedFolderId (must me a Symbol) or a FolderId (String)
29
- # @param [String] disposition SaveOnly/SendOnly/SendAndSaveCopy
30
- # See: http://msdn.microsoft.com/en-us/library/aa565209.aspx
31
- # @example Typical Usage
32
- # item = {
33
- # :subject => {:text => 'Planning'},
34
- # :body => {:body_type => 'Text', :text => 'This is a test'},
35
- # :start_date => {:text => '2010-07-29T14:00:00'},
36
- # :due_date => {:text => '2010-07-29T15:00:00'},
37
- # }
38
- # @example Minimal Usage
39
- # item = {:subject => {:text => 'This is a test'}}
40
- def self.create_item_from_hash(item, folder_id = :tasks, disposition = 'SaveOnly')
41
- conn = Viewpoint::EWS::EWS.instance
42
- resp = conn.ews.create_task_item(folder_id, item, disposition)
43
- if(resp.status == 'Success')
44
- resp = resp.items.shift
45
- self.new(resp[resp.keys.first])
46
- else
47
- raise EwsError, "Could not create Task. #{resp.code}: #{resp.message}"
48
- end
49
- end
50
-
51
- # Create a Task in the Exchange Data Store
52
- #
53
- # @param [nil, String] folder the folder to add the task to. If it is nil
54
- # the Task will be placed in the default Task folder.
55
- # @param [String] subject The task subject
56
- # @param [String] body The task body
57
- # @param [DateTime] v_start The date/time when this task begins
58
- # @param [DateTime] v_end The date/time when this task is due
59
- # @param [Symbol] status The current status of this task
60
- # :completed, :in_progress, :waiting_on_others,
61
- def self.create_task(folder, subject, body, v_start = nil, v_end = nil, status = nil)
62
- item = {}
63
- item[:subject] = {:text => subject}
64
- item[:body] = {:text => body, :body_type => 'Text'} unless body.nil?
65
- item[:start_date] = {:text => v_start.to_s} unless v_start.nil?
66
- item[:due_date] = {:text => v_end.to_s} unless v_end.nil?
67
- item[:status] = {:text => status} unless status.nil?
68
-
69
- self.create_item_from_hash(item, folder)
70
- end
71
-
72
-
73
- # Initialize an Exchange Web Services item of type Task
74
- def initialize(ews_item, opts={})
75
- super(ews_item, opts)
76
- end
77
-
78
- # Delete this item
79
- # @param [Boolean] soft Whether or not to do a soft delete. By default EWS will do a
80
- # hard delete of this item. See the MSDN docs for more info:
81
- # http://msdn.microsoft.com/en-us/library/aa562961.aspx
82
- # @param [String, nil] affected_task_occurrences "AllOccurrences/SpecifiedOccurrenceOnly"
83
- # Default is AllOccurrences
84
- # If you use 'SpecifiedOccurrenceOnly' on a non-reocurring task you will receive and error.
85
- # @return [Boolean] Whether or not the item was deleted
86
- # @todo Add exception handling for failed deletes
87
- #
88
- def delete!(soft=false, affected_task_occurrences='AllOccurrences')
89
- deltype = soft ? 'SoftDelete' : 'HardDelete'
90
- resp = (Viewpoint::EWS::EWS.instance).ews.delete_item([@item_id], deltype, nil, affected_task_occurrences)
91
- self.clear_object!
92
- resp.status == 'Success'
93
- end
94
-
95
- # Delete this item by moving it to the Deleted Items folder
96
- # @see http://msdn.microsoft.com/en-us/library/aa562961.aspx
97
- # @param [String, nil] affected_task_occurrences "AllOccurrences/SpecifiedOccurrenceOnly"
98
- # Default is AllOccurrences
99
- # If you use 'SpecifiedOccurrenceOnly' on a non-reocurring task you will receive and error.
100
- # @return [Boolean] Whether or not the item was deleted
101
- # @todo Add exception handling for failed deletes
102
- def recycle!(affected_task_occurrences='AllOccurrences')
103
- resp = (Viewpoint::EWS::EWS.instance).ews.delete_item([@item_id], 'MoveToDeletedItems', nil, affected_task_occurrences)
104
- self.clear_object!
105
- resp.status == 'Success'
106
- end
107
-
108
-
109
- private
110
-
111
- def init_methods
112
- super
113
- define_str_var :status, :owner
114
- define_bool_var :is_complete, :is_recurring, :is_team_task
115
- define_int_var :percent_complete, :actual_work, :change_count
116
- define_datetime_var :start_date, :due_date, :complete_date
117
- end
118
-
119
- end # Task
120
- end # EWS
121
- end # Viewpoint
@@ -1,44 +0,0 @@
1
- =begin
2
- This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
-
4
- Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License");
7
- you may not use this file except in compliance with the License.
8
- You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- =end
18
-
19
- module Viewpoint
20
- module EWS
21
- # This class represents a TaskFolderType object in the Exchange Data store.
22
- class TasksFolder < GenericFolder
23
-
24
- # Find folders of type Task
25
- # @see GenericFolder.find_folders
26
- # @param [String,Symbol] root An folder id, either a DistinguishedFolderId (must me a Symbol)
27
- # or a FolderId (String)
28
- # @param [String] traversal Shallow/Deep/SoftDeleted
29
- # @param [String] shape the shape to return IdOnly/Default/AllProperties
30
- # @param [optional, String] folder_type an optional folder type to limit the search to like 'IPF.Task'
31
- # @return [Array] Returns an Array of Folder or subclasses of Folder
32
- def self.find_folders(root = :msgfolderroot, traversal = 'Deep', shape = 'Default', folder_type = 'IPF.Task')
33
- super(root, traversal, shape, folder_type)
34
- end
35
-
36
-
37
- def initialize(folder)
38
- super(folder)
39
- define_int_var :unread_count
40
- end
41
-
42
- end # TasksFolder
43
- end # EWS
44
- end # Viewpoint
@@ -1,383 +0,0 @@
1
- =begin
2
- This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
-
4
- Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License");
7
- you may not use this file except in compliance with the License.
8
- You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- =end
18
-
19
- # This is a module that is included in the main Builder that has sub builders
20
- # that are used from multiple root nodes. It is basically just a way to do
21
- # code reuse in a more natural way. The one difference between these functions
22
- # and the builder functions in the EwsBuilder class is that the first parameter
23
- # is of node type. We use that parameter to build subnodes in this module.
24
-
25
- module Viewpoint
26
- module EWS
27
- module SOAP
28
- module EwsBuildHelpers
29
-
30
- def folder_ids!(node, folder_ids, act_as=nil, element_name="#{NS_EWS_MESSAGES}:FolderIds")
31
- node.add(element_name) do |p|
32
- folder_ids.each do |id|
33
- folder_id!(p,id,act_as)
34
- end
35
- end
36
- end
37
-
38
- def folder_id!(node, folder_id, act_as = nil)
39
- if( folder_id.is_a?(Symbol) )
40
- # @todo add change_key support to DistinguishedFolderId
41
- node.add("#{NS_EWS_TYPES}:DistinguishedFolderId") do |df|
42
- df.set_attr('Id', folder_id.to_s)
43
- # add optional delegate user
44
- mailbox!(df, {:email_address => {:text => act_as}}, NS_EWS_TYPES) unless act_as.nil?
45
- end
46
- else
47
- # @todo add change_key support to FolderId
48
- node.add("#{NS_EWS_TYPES}:FolderId") do |fi|
49
- fi.set_attr('Id', folder_id)
50
- end
51
- end
52
- end
53
-
54
- # For now this is the same as folder_ids! so just use that method
55
- def parent_folder_ids!(node, folder_ids)
56
- folder_ids!(node, folder_ids, nil, "#{NS_EWS_MESSAGES}:ParentFolderIds")
57
- end
58
-
59
- # @see http://msdn.microsoft.com/en-us/library/aa565020.aspx
60
- def to_folder_id!(node, folder_id)
61
- node.add("#{NS_EWS_MESSAGES}:ToFolderId") do |tfi|
62
- folder_id!(tfi, folder_id)
63
- end
64
- end
65
-
66
- # Create the ItemChanges Element
67
- def item_changes!(node, item_ids, changes)
68
- node.add("#{NS_EWS_MESSAGES}:ItemChanges") do |chgs|
69
- chgs.add("#{NS_EWS_TYPES}:ItemChange") do |chg|
70
- item_id!(chg, item_ids.first)
71
- add_hierarchy!(chg, changes)
72
- end
73
- end
74
- end
75
-
76
- # Create the ItemIds Element
77
- # @param [Element] node The node we are adding Mailbox elements to.
78
- # @param [Array] item_ids The item ids to add in.
79
- def item_ids!(node, item_ids)
80
- node.add("#{NS_EWS_MESSAGES}:ItemIds") do |ids|
81
- item_ids.each do |id|
82
- item_id!(ids,id)
83
- end
84
- end
85
- end
86
-
87
- # Builds an ItemId element out of a String or Hash object
88
- # @param [Element] node The node we are adding Mailbox elements to.
89
- # @param [String,Hash] item_id The id of the Item. If this is a Hash
90
- # it should contain the Id and the ChangeKey.
91
- # @option item_ids [String] :id The item Id
92
- # @option item_ids [String] :change_key The ChangeKey
93
- def item_id!(node, item_id, element_name="#{NS_EWS_TYPES}:ItemId")
94
- node.add(element_name) do |iid|
95
- if(item_id.is_a?(String))
96
- iid.set_attr('Id',item_id)
97
- else
98
- iid.set_attr('Id',item_id[:id])
99
- iid.set_attr('ChangeKey',item_id[:change_key])
100
- end
101
- end
102
- end
103
-
104
- def user_id!(node, uid)
105
- add_hierarchy!(node, uid)
106
- end
107
-
108
- # @param [Element] node The node we are adding Mailbox elements to.
109
- # @param [Hash] mailbox A Mailbox formated hash inside the :mailbox key
110
- # For example: {:email_address => 'test@test.com', :name => 'Test User'}
111
- def mailbox!(node, mailbox, ns = NS_EWS_MESSAGES)
112
- node.add("#{ns}:Mailbox") do |mbx|
113
- add_hierarchy!(mbx, mailbox)
114
- end
115
- end
116
-
117
- def delegate_users!(node, d_users)
118
- node.add("#{NS_EWS_MESSAGES}:DelegateUsers") do |dus|
119
- d_users.each do |du|
120
- dus.add("#{NS_EWS_TYPES}:DelegateUser") do |dut|
121
- add_hierarchy!(dut, du)
122
- end
123
- end
124
- end
125
- end
126
-
127
- def saved_item_folder_id!(node, folder_id)
128
- node.add("#{NS_EWS_MESSAGES}:SavedItemFolderId") do |sfid|
129
- folder_id!(sfid, folder_id)
130
- end
131
- end
132
-
133
- # @todo This only supports the FieldURI extended property right now
134
- def folder_shape!(node, folder_shape)
135
- node.add("#{NS_EWS_MESSAGES}:FolderShape") do |fshape|
136
- fshape.add("#{NS_EWS_TYPES}:BaseShape", folder_shape[:base_shape])
137
-
138
- unless( folder_shape[:additional_properties].nil? )
139
- unless( folder_shape[:additional_properties][:FieldURI].nil? )
140
- fshape.add("#{NS_EWS_TYPES}:AdditionalProperties") do |addprops|
141
- folder_shape[:additional_properties][:FieldURI].each do |uri|
142
- addprops.add("#{NS_EWS_TYPES}:FieldURI") { |furi| furi.set_attr('FieldURI', uri) }
143
- end
144
- end
145
- end
146
- end
147
- end
148
- end
149
-
150
- # @todo Finish AdditionalProperties implementation
151
- def item_shape!(node, item_shape)
152
- node.add("#{NS_EWS_MESSAGES}:ItemShape") do |is|
153
- is.add("#{NS_EWS_TYPES}:BaseShape", item_shape[:base_shape])
154
- is.add("#{NS_EWS_TYPES}:IncludeMimeContent", item_shape[:include_mime_content]) if item_shape.has_key?(:include_mime_content)
155
- is.add("#{NS_EWS_TYPES}:BodyType", item_shape[:body_type]) if item_shape.has_key?(:body_type)
156
- is.add("#{NS_EWS_TYPES}:FilterHtmlContent", item_shape[:filter_html_content]) if item_shape.has_key?(:filter_html_content)
157
- is.add("#{NS_EWS_TYPES}:ConvertHtmlCodePageToUTF8", item_shape[:convert_html_code_page_to_utf8]) if item_shape.has_key?(:convert_html_code_page_to_utf8)
158
- unless( item_shape[:additional_properties].nil? )
159
- unless( item_shape[:additional_properties][:field_uRI].nil? )
160
- is.add("#{NS_EWS_TYPES}:AdditionalProperties") do |addprops|
161
- item_shape[:additional_properties][:field_uRI].each do |uri|
162
- addprops.add("#{NS_EWS_TYPES}:FieldURI") { |furi| furi.set_attr('FieldURI', uri) }
163
- end
164
- end
165
- end
166
- end
167
- end
168
- end
169
-
170
- def items!(node, items, type)
171
- node.add("#{NS_EWS_MESSAGES}:Items") do |i|
172
- if items.is_a? Hash
173
- method("#{type}_item!").call(i, items)
174
- else
175
- items.each do |item|
176
- method("#{type}_item!").call(i, item)
177
- end
178
- end
179
- end
180
- end
181
-
182
- # Creates a CalendarItem Element structure. It matters to Exchange which order Items are added in
183
- # so it loops through an order Array to make sure things are added appropriately.
184
- # @param [Element] node The <Items> element that is the parent to all of the elements that will
185
- # be created from the items param
186
- # @param [Hash] item The item or items that will be added to the element in the parameter node
187
- # @todo Make sure and watch this method for new Item elements when EWS versions change.
188
- def message_item!(node, item)
189
- order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received,
190
- :size,:categories,:importance,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified,
191
- :internet_message_headers,:date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,
192
- :reminder_minutes_before_start,:display_cc,:display_to,:has_attachments,:extended_property,:culture,:sender,
193
- :to_recipients,:cc_recipients,:bcc_recipients,:is_read_receipt_requested,:is_delivery_receipt_requested,
194
- :conversation_index,:conversation_topic,:from,:internet_message_id,:is_read,:is_response_requested,:references,
195
- :reply_to,:effective_rights,:received_by,:received_representing,:last_modified_name,:last_modified_time,
196
- :is_associated,:web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body]
197
-
198
- node.add("#{NS_EWS_TYPES}:Message") do |msg|
199
- item!(msg, item, order)
200
- end
201
- end
202
-
203
- # Creates a CalendarItem Element structure. It matters to Exchange which order Items are added in
204
- # so it loops through an order Array to make sure things are added appropriately.
205
- # @param [Element] node The <Items> element that is the parent to all of the elements that will
206
- # be created from the items param
207
- # @param [Hash] item The item or items that will be added to the element in the parameter node
208
- # @todo Make sure and watch this method for new Item elements when EWS versions change.
209
- def calendar_item!(node, item)
210
- # For some reason MS thought it was a good idea to make order matter for Item creation. This list is the current order
211
- # for Exchange 2003 and 2010
212
- order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received,:size,
213
- :categories,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified,:internet_message_headers,
214
- :date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,:reminder_minutes_before_start,
215
- :display_cc,:display_to,:has_attachments,:extended_property,:culture,:start,:end,:original_start,:is_all_day_event,
216
- :legacy_free_busy_status,:location,:when,:is_meeting,:is_cancelled,:is_recurring,:meeting_request_was_sent,
217
- :is_response_requested,:calendar_item_type,:my_response_type,:organizer,:required_attendees,:optional_attendees,
218
- :resources,:conflicting_meeting_count,:adjacent_meeting_count,:conflicting_meetings,:adjacent_meetings,:duration,:time_zone,
219
- :appointment_reply_time,:appointment_sequence_number,:appointment_state,:recurrence,:first_occurrence,:last_occurrence,
220
- :modified_occurrences,:deleted_occurrences,:meeting_time_zone,:start_time_zone,:end_time_zone,:conference_type,
221
- :allow_new_time_proposal,:is_online_meeting,:meeting_workspace_url,:net_show_url,:effective_rights,:last_modified_name,
222
- :last_modified_time,:is_associated,:web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body]
223
-
224
- node.add("#{NS_EWS_TYPES}:CalendarItem") do |msg|
225
- item!(msg, item, order)
226
- end
227
- end
228
-
229
- # Creates a Contact Element structure. It matters to Exchange which order Items are added in
230
- # so it loops through an order Array to make sure things are added appropriately.
231
- # @param [Element] node The <Items> element that is the parent to all of the elements that will
232
- # be created from the items param
233
- # @param [Hash] item The item or items that will be added to the element in the parameter node
234
- # @todo Make sure and watch this method for new Item elements when EWS versions change.
235
- def contact_item!(node,item)
236
- order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received,:size,
237
- :categories,:importance,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified, :internet_message_headers,
238
- :date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,:reminder_minutes_before_start,
239
- :display_cc,:display_to,:has_attachments,:extended_property,:culture,:effective_rights,:last_modified_name,:last_modified_time,
240
- :is_associated,:web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body,:file_as,
241
- :file_as_mapping,:display_name,:given_name,:initials,:middle_name,:nickname,:complete_name,:company_name,:email_addresses,
242
- :physical_addresses,:phone_numbers,:assistant_name,:birthday,:business_home_page,:children,:companies,:contact_source,
243
- :department,:generation,:im_addresses,:job_title,:manager,:mileage,:office_location,:postal_address_index,:profession,
244
- :spouse_name,:surname,:wedding_anniversary,:has_picture]
245
-
246
- node.add("#{NS_EWS_TYPES}:Contact") do |msg|
247
- item!(msg, item, order)
248
- end
249
- end
250
-
251
- # Creates a Task Element structure. It matters to Exchange which order Items are added in
252
- # so it loops through an order Array to make sure things are added appropriately.
253
- # @param [Element] node The <Items> element that is the parent to all of the elements that will
254
- # be created from the items param
255
- # @param [Hash] item The item or items that will be added to the element in the parameter node
256
- # @todo Make sure and watch this method for new Item elements when EWS versions change.
257
- def task_item!(node,item)
258
- order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received,
259
- :size,:categories,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified,:internet_message_headers,
260
- :date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,:reminder_minutes_before_start,
261
- :display_cc,:display_to,:has_attachments,:extended_property,:culture,:actual_work,:assigned_time,:billing_information,
262
- :change_count,:companies,:complete_date,:contacts,:delegation_state,:delegator,:due_date,:is_assignment_editable,
263
- :is_complete,:is_recurring,:is_team_task,:mileage,:owner,:percent_complete,:recurrence,:start_date,:status,
264
- :status_description,:total_work,:effective_rights,:last_modified_name,:last_modified_time,:is_associated,
265
- :web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body]
266
-
267
- node.add("#{NS_EWS_TYPES}:Task") do |msg|
268
- item!(msg, item, order)
269
- end
270
- end
271
-
272
-
273
- # This is a convernience method used by the specific item types like
274
- # CalendarItem and Message to create item structures. It is the shared
275
- # code between them.
276
- # @param [Element] node The <*Item> element that is the parent to all of the elements that will
277
- # be created from the elems param
278
- # @param [Hash, Array] item The subelements that will be created under node
279
- # @param [Array<Symbol] order The order that Exchange expects these elements to appear in
280
- # the SOAP request.
281
- def item!(node, item, order)
282
- order.each do |id|
283
- if(item[id])
284
- if(item[id].is_a?(Hash))
285
- node.add("#{NS_EWS_TYPES}:#{id.to_s.camel_case}", item[id][:text]) do |it|
286
- add_hierarchy!(it, item[id]) if item[id]
287
- end
288
- elsif(item[id].is_a?(Array))
289
- node.add("#{NS_EWS_TYPES}:#{id.to_s.camel_case}") do |it|
290
- item[id].each do |ai|
291
- add_hierarchy!(it, ai)
292
- end
293
- end
294
- end
295
- end
296
- end
297
- end
298
-
299
-
300
- def event_types!(node, event_types)
301
- node.add("#{NS_EWS_TYPES}:EventTypes") do |ets|
302
- event_types.each do |event_type|
303
- ets.add("#{NS_EWS_TYPES}:EventType", event_type)
304
- end
305
- end
306
- end
307
-
308
- def subscription_id!(node, subscription_id)
309
- node.add("#{NS_EWS_MESSAGES}:SubscriptionId", subscription_id)
310
- end
311
-
312
- def watermark!(node, watermark)
313
- node.add("#{NS_EWS_MESSAGES}:Watermark", watermark)
314
- end
315
-
316
- def sync_state!(node, sync_state)
317
- node.add("#{NS_EWS_MESSAGES}:SyncState", sync_state)
318
- end
319
-
320
- def attachments!(node, files, items)
321
- # Order matters and ruby 1.8.x does not have ordered hashes.
322
- order=[:name, :content]
323
- node.add("#{NS_EWS_MESSAGES}:Attachments") do |att|
324
- files.each do |f|
325
- att.add("#{NS_EWS_TYPES}:FileAttachment") do |fatt|
326
- item!(fatt, f, order)
327
- end
328
- end
329
- end
330
- end
331
-
332
- def attachment_ids!(node, attachment_ids)
333
- node.add("#{NS_EWS_MESSAGES}:AttachmentIds") do |att|
334
- attachment_ids.each do |id|
335
- add_hierarchy!(att, {:attachment_id => {:id => id}})
336
- end
337
- end
338
- end
339
-
340
- def attachment_shape!(node)
341
- node.add("#{NS_EWS_MESSAGES}:AttachmentShape")
342
- end
343
-
344
- # Add a hierarchy of elements from hash data
345
- # @example Hash to XML
346
- # {:this => {:text =>'that'},'top' => {:id => '32fss', :text => 'TestText', :sub_elements => {'middle' => {:text => 'bottom'}}}}
347
- # becomes...
348
- # <this>that</this>
349
- # <top Id='32fss'>
350
- # <middle>bottom</middle>
351
- # </top>
352
- def add_hierarchy!(node, e_hash, prefix = NS_EWS_TYPES)
353
- e_hash.each_pair do |k,v|
354
- if v.is_a? Hash
355
- if(k == :sub_elements)
356
- add_hierarchy!(node, v)
357
- else
358
- node.add("#{prefix}:#{k.to_s.camel_case}", v[:text]) do |n|
359
- add_hierarchy!(n, v)
360
- end
361
- end
362
- elsif v.is_a? Array
363
- if(k == :sub_elements)
364
- v.each do |i|
365
- add_hierarchy!(node, i)
366
- end
367
- else
368
- node.add("#{prefix}:#{k.to_s.camel_case}") do |n|
369
- v.each do |i|
370
- add_hierarchy!(n, i)
371
- end
372
- end
373
- end
374
- else
375
- node.set_attr(k.to_s.camel_case, v) unless k == :text
376
- end
377
- end
378
- end
379
-
380
- end # EwsBuildHelpers
381
- end # SOAP
382
- end # EWS
383
- end # Viewpoint