Module: Viewpoint::EWS::SOAP::EwsBuildHelpers
- Included in:
- EwsBuilder
- Defined in:
- lib/soap/handsoap/builders/ews_build_helpers.rb
Instance Method Summary collapse
-
#add_hierarchy!(node, e_hash, prefix = NS_EWS_TYPES) ⇒ Object
Add a hierarchy of elements from hash data.
- #attachment_ids!(node, attachment_ids) ⇒ Object
- #attachment_shape!(node) ⇒ Object
- #attachments!(node, files, items) ⇒ Object
-
#calendar_item!(node, item) ⇒ Object
Creates a CalendarItem Element structure.
-
#contact_item!(node, item) ⇒ Object
Creates a Contact Element structure.
- #delegate_users!(node, d_users) ⇒ Object
- #event_types!(node, event_types) ⇒ Object
- #folder_id!(node, folder_id, act_as = nil) ⇒ Object
- #folder_ids!(node, folder_ids, act_as = nil, element_name = "#{NS_EWS_MESSAGES}:FolderIds") ⇒ Object
- #folder_shape!(node, folder_shape) ⇒ Object
-
#item!(node, item, order) ⇒ Object
This is a convernience method used by the specific item types like CalendarItem and Message to create item structures.
-
#item_changes!(node, item_ids, changes) ⇒ Object
Create the ItemChanges Element.
-
#item_id!(node, item_id, element_name = "#{NS_EWS_TYPES}:ItemId") ⇒ Object
Builds an ItemId element out of a String or Hash object.
-
#item_ids!(node, item_ids) ⇒ Object
Create the ItemIds Element.
- #item_shape!(node, item_shape) ⇒ Object
- #items!(node, items, type) ⇒ Object
- #mailbox!(node, mailbox, ns = NS_EWS_MESSAGES) ⇒ Object
-
#message_item!(node, item) ⇒ Object
Creates a CalendarItem Element structure.
-
#parent_folder_ids!(node, folder_ids) ⇒ Object
For now this is the same as folder_ids! so just use that method.
- #saved_item_folder_id!(node, folder_id) ⇒ Object
- #subscription_id!(node, subscription_id) ⇒ Object
- #sync_state!(node, sync_state) ⇒ Object
-
#task_item!(node, item) ⇒ Object
Creates a Task Element structure.
- #to_folder_id!(node, folder_id) ⇒ Object
- #user_id!(node, uid) ⇒ Object
- #watermark!(node, watermark) ⇒ Object
Instance Method Details
#add_hierarchy!(node, e_hash, prefix = NS_EWS_TYPES) ⇒ Object
Add a hierarchy of elements from hash data
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 352 def add_hierarchy!(node, e_hash, prefix = NS_EWS_TYPES) e_hash.each_pair do |k,v| if v.is_a? Hash if(k == :sub_elements) add_hierarchy!(node, v) else node.add("#{prefix}:#{k.to_s.camel_case}", v[:text]) do |n| add_hierarchy!(n, v) end end elsif v.is_a? Array if(k == :sub_elements) v.each do |i| add_hierarchy!(node, i) end else node.add("#{prefix}:#{k.to_s.camel_case}") do |n| v.each do |i| add_hierarchy!(n, i) end end end else node.set_attr(k.to_s.camel_case, v) unless k == :text end end end |
#attachment_ids!(node, attachment_ids) ⇒ Object
332 333 334 335 336 337 338 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 332 def (node, ) node.add("#{NS_EWS_MESSAGES}:AttachmentIds") do |att| .each do |id| add_hierarchy!(att, {:attachment_id => {:id => id}}) end end end |
#attachment_shape!(node) ⇒ Object
340 341 342 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 340 def (node) node.add("#{NS_EWS_MESSAGES}:AttachmentShape") end |
#attachments!(node, files, items) ⇒ Object
320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 320 def (node, files, items) # Order matters and ruby 1.8.x does not have ordered hashes. order=[:name, :content] node.add("#{NS_EWS_MESSAGES}:Attachments") do |att| files.each do |f| att.add("#{NS_EWS_TYPES}:FileAttachment") do |fatt| item!(fatt, f, order) end end end end |
#calendar_item!(node, item) ⇒ Object
Make sure and watch this method for new Item elements when EWS versions change.
Creates a CalendarItem Element structure. It matters to Exchange which order Items are added in so it loops through an order Array to make sure things are added appropriately.
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 209 def calendar_item!(node, item) # For some reason MS thought it was a good idea to make order matter for Item creation. This list is the current order # for Exchange 2003 and 2010 order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received,:size, :categories,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified,:internet_message_headers, :date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,:reminder_minutes_before_start, :display_cc,:display_to,:has_attachments,:extended_property,:culture,:start,:end,:original_start,:is_all_day_event, :legacy_free_busy_status,:location,:when,:is_meeting,:is_cancelled,:is_recurring,:meeting_request_was_sent, :is_response_requested,:calendar_item_type,:my_response_type,:organizer,:required_attendees,:optional_attendees, :resources,:conflicting_meeting_count,:adjacent_meeting_count,:conflicting_meetings,:adjacent_meetings,:duration,:time_zone, :appointment_reply_time,:appointment_sequence_number,:appointment_state,:recurrence,:first_occurrence,:last_occurrence, :modified_occurrences,:deleted_occurrences,:meeting_time_zone,:start_time_zone,:end_time_zone,:conference_type, :allow_new_time_proposal,:is_online_meeting,:meeting_workspace_url,:net_show_url,:effective_rights,:last_modified_name, :last_modified_time,:is_associated,:web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body] node.add("#{NS_EWS_TYPES}:CalendarItem") do |msg| item!(msg, item, order) end end |
#contact_item!(node, item) ⇒ Object
Make sure and watch this method for new Item elements when EWS versions change.
Creates a Contact Element structure. It matters to Exchange which order Items are added in so it loops through an order Array to make sure things are added appropriately.
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 235 def contact_item!(node,item) order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received,:size, :categories,:importance,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified, :internet_message_headers, :date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,:reminder_minutes_before_start, :display_cc,:display_to,:has_attachments,:extended_property,:culture,:effective_rights,:last_modified_name,:last_modified_time, :is_associated,:web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body,:file_as, :file_as_mapping,:display_name,:given_name,:initials,:middle_name,:nickname,:complete_name,:company_name,:email_addresses, :physical_addresses,:phone_numbers,:assistant_name,:birthday,:business_home_page,:children,:companies,:contact_source, :department,:generation,:im_addresses,:job_title,:manager,:mileage,:office_location,:postal_address_index,:profession, :spouse_name,:surname,:wedding_anniversary,:has_picture] node.add("#{NS_EWS_TYPES}:Contact") do |msg| item!(msg, item, order) end end |
#delegate_users!(node, d_users) ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 117 def delegate_users!(node, d_users) node.add("#{NS_EWS_MESSAGES}:DelegateUsers") do |dus| d_users.each do |du| dus.add("#{NS_EWS_TYPES}:DelegateUser") do |dut| add_hierarchy!(dut, du) end end end end |
#event_types!(node, event_types) ⇒ Object
300 301 302 303 304 305 306 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 300 def event_types!(node, event_types) node.add("#{NS_EWS_TYPES}:EventTypes") do |ets| event_types.each do |event_type| ets.add("#{NS_EWS_TYPES}:EventType", event_type) end end end |
#folder_id!(node, folder_id, act_as = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 38 def folder_id!(node, folder_id, act_as = nil) if( folder_id.is_a?(Symbol) ) # @todo add change_key support to DistinguishedFolderId node.add("#{NS_EWS_TYPES}:DistinguishedFolderId") do |df| df.set_attr('Id', folder_id.to_s) # add optional delegate user mailbox!(df, {:email_address => {:text => act_as}}, NS_EWS_TYPES) unless act_as.nil? end else # @todo add change_key support to FolderId node.add("#{NS_EWS_TYPES}:FolderId") do |fi| fi.set_attr('Id', folder_id) end end end |
#folder_ids!(node, folder_ids, act_as = nil, element_name = "#{NS_EWS_MESSAGES}:FolderIds") ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 30 def folder_ids!(node, folder_ids, act_as=nil, element_name="#{NS_EWS_MESSAGES}:FolderIds") node.add(element_name) do |p| folder_ids.each do |id| folder_id!(p,id,act_as) end end end |
#folder_shape!(node, folder_shape) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 134 def folder_shape!(node, folder_shape) node.add("#{NS_EWS_MESSAGES}:FolderShape") do |fshape| fshape.add("#{NS_EWS_TYPES}:BaseShape", folder_shape[:base_shape]) unless( folder_shape[:additional_properties].nil? ) unless( folder_shape[:additional_properties][:FieldURI].nil? ) fshape.add("#{NS_EWS_TYPES}:AdditionalProperties") do |addprops| folder_shape[:additional_properties][:FieldURI].each do |uri| addprops.add("#{NS_EWS_TYPES}:FieldURI") { |furi| furi.set_attr('FieldURI', uri) } end end end end end end |
#item!(node, item, order) ⇒ Object
This is a convernience method used by the specific item types like CalendarItem and Message to create item structures. It is the shared code between them.
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 281 def item!(node, item, order) order.each do |id| if(item[id]) if(item[id].is_a?(Hash)) node.add("#{NS_EWS_TYPES}:#{id.to_s.camel_case}", item[id][:text]) do |it| add_hierarchy!(it, item[id]) if item[id] end elsif(item[id].is_a?(Array)) node.add("#{NS_EWS_TYPES}:#{id.to_s.camel_case}") do |it| item[id].each do |ai| add_hierarchy!(it, ai) end end end end end end |
#item_changes!(node, item_ids, changes) ⇒ Object
Create the ItemChanges Element
67 68 69 70 71 72 73 74 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 67 def item_changes!(node, item_ids, changes) node.add("#{NS_EWS_MESSAGES}:ItemChanges") do |chgs| chgs.add("#{NS_EWS_TYPES}:ItemChange") do |chg| item_id!(chg, item_ids.first) add_hierarchy!(chg, changes) end end end |
#item_id!(node, item_id, element_name = "#{NS_EWS_TYPES}:ItemId") ⇒ Object
Builds an ItemId element out of a String or Hash object
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 93 def item_id!(node, item_id, element_name="#{NS_EWS_TYPES}:ItemId") node.add(element_name) do |iid| if(item_id.is_a?(String)) iid.set_attr('Id',item_id) else iid.set_attr('Id',item_id[:id]) iid.set_attr('ChangeKey',item_id[:change_key]) end end end |
#item_ids!(node, item_ids) ⇒ Object
Create the ItemIds Element
79 80 81 82 83 84 85 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 79 def item_ids!(node, item_ids) node.add("#{NS_EWS_MESSAGES}:ItemIds") do |ids| item_ids.each do |id| item_id!(ids,id) end end end |
#item_shape!(node, item_shape) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 151 def item_shape!(node, item_shape) node.add("#{NS_EWS_MESSAGES}:ItemShape") do |is| is.add("#{NS_EWS_TYPES}:BaseShape", item_shape[:base_shape]) is.add("#{NS_EWS_TYPES}:IncludeMimeContent", item_shape[:include_mime_content]) if item_shape.has_key?(:include_mime_content) is.add("#{NS_EWS_TYPES}:BodyType", item_shape[:body_type]) if item_shape.has_key?(:body_type) is.add("#{NS_EWS_TYPES}:FilterHtmlContent", item_shape[:filter_html_content]) if item_shape.has_key?(:filter_html_content) 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) unless( item_shape[:additional_properties].nil? ) unless( item_shape[:additional_properties][:field_uRI].nil? ) is.add("#{NS_EWS_TYPES}:AdditionalProperties") do |addprops| item_shape[:additional_properties][:field_uRI].each do |uri| addprops.add("#{NS_EWS_TYPES}:FieldURI") { |furi| furi.set_attr('FieldURI', uri) } end end end end end end |
#items!(node, items, type) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 170 def items!(node, items, type) node.add("#{NS_EWS_MESSAGES}:Items") do |i| if items.is_a? Hash method("#{type}_item!").call(i, items) else items.each do |item| method("#{type}_item!").call(i, item) end end end end |
#mailbox!(node, mailbox, ns = NS_EWS_MESSAGES) ⇒ Object
111 112 113 114 115 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 111 def mailbox!(node, mailbox, ns = NS_EWS_MESSAGES) node.add("#{ns}:Mailbox") do |mbx| add_hierarchy!(mbx, mailbox) end end |
#message_item!(node, item) ⇒ Object
Make sure and watch this method for new Item elements when EWS versions change.
Creates a CalendarItem Element structure. It matters to Exchange which order Items are added in so it loops through an order Array to make sure things are added appropriately.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 188 def (node, item) order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received, :size,:categories,:importance,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified, :internet_message_headers,:date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set, :reminder_minutes_before_start,:display_cc,:display_to,:has_attachments,:extended_property,:culture,:sender, :to_recipients,:cc_recipients,:bcc_recipients,:is_read_receipt_requested,:is_delivery_receipt_requested, :conversation_index,:conversation_topic,:from,:internet_message_id,:is_read,:is_response_requested,:references, :reply_to,:effective_rights,:received_by,:received_representing,:last_modified_name,:last_modified_time, :is_associated,:web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body] node.add("#{NS_EWS_TYPES}:Message") do |msg| item!(msg, item, order) end end |
#parent_folder_ids!(node, folder_ids) ⇒ Object
For now this is the same as folder_ids! so just use that method
55 56 57 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 55 def parent_folder_ids!(node, folder_ids) folder_ids!(node, folder_ids, nil, "#{NS_EWS_MESSAGES}:ParentFolderIds") end |
#saved_item_folder_id!(node, folder_id) ⇒ Object
127 128 129 130 131 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 127 def saved_item_folder_id!(node, folder_id) node.add("#{NS_EWS_MESSAGES}:SavedItemFolderId") do |sfid| folder_id!(sfid, folder_id) end end |
#subscription_id!(node, subscription_id) ⇒ Object
308 309 310 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 308 def subscription_id!(node, subscription_id) node.add("#{NS_EWS_MESSAGES}:SubscriptionId", subscription_id) end |
#sync_state!(node, sync_state) ⇒ Object
316 317 318 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 316 def sync_state!(node, sync_state) node.add("#{NS_EWS_MESSAGES}:SyncState", sync_state) end |
#task_item!(node, item) ⇒ Object
Make sure and watch this method for new Item elements when EWS versions change.
Creates a Task Element structure. It matters to Exchange which order Items are added in so it loops through an order Array to make sure things are added appropriately.
257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 257 def task_item!(node,item) order=[:mime_content,:item_id,:parent_folder_id,:item_class,:subject,:sensitivity,:body,:attachments,:date_time_received, :size,:categories,:in_reply_to,:is_submitted,:is_draft,:is_from_me,:is_resend,:is_unmodified,:internet_message_headers, :date_time_sent,:date_time_created,:response_objects,:reminder_due_by,:reminder_is_set,:reminder_minutes_before_start, :display_cc,:display_to,:has_attachments,:extended_property,:culture,:actual_work,:assigned_time,:billing_information, :change_count,:companies,:complete_date,:contacts,:delegation_state,:delegator,:due_date,:is_assignment_editable, :is_complete,:is_recurring,:is_team_task,:mileage,:owner,:percent_complete,:recurrence,:start_date,:status, :status_description,:total_work,:effective_rights,:last_modified_name,:last_modified_time,:is_associated, :web_client_read_form_query_string,:web_client_edit_form_query_string,:conversation_id,:unique_body] node.add("#{NS_EWS_TYPES}:Task") do |msg| item!(msg, item, order) end end |
#to_folder_id!(node, folder_id) ⇒ Object
60 61 62 63 64 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 60 def to_folder_id!(node, folder_id) node.add("#{NS_EWS_MESSAGES}:ToFolderId") do |tfi| folder_id!(tfi, folder_id) end end |
#user_id!(node, uid) ⇒ Object
104 105 106 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 104 def user_id!(node, uid) add_hierarchy!(node, uid) end |
#watermark!(node, watermark) ⇒ Object
312 313 314 |
# File 'lib/soap/handsoap/builders/ews_build_helpers.rb', line 312 def watermark!(node, watermark) node.add("#{NS_EWS_MESSAGES}:Watermark", watermark) end |