Module: Viewpoint::EWS::SOAP::ExchangeDataServices
- Includes:
- Viewpoint::EWS::SOAP
- Included in:
- ExchangeWebService
- Defined in:
- lib/ews/soap/exchange_data_services.rb
Overview
Exchange Data Service operations as listed in the EWS Documentation.
Constant Summary
Constants included from Viewpoint::EWS::SOAP
ActiveDirectory, ActiveDirectoryContacts, Contacts, ContactsActiveDirectory, HARD_DELETE, MOVE_TO_DELETED_ITEMS, NAMESPACES, NS_EWS_MESSAGES, NS_EWS_TYPES, NS_SOAP, SOFT_DELETE, VERSION_2007, VERSION_2007_SP1, VERSION_2010, VERSION_2010_SP1, VERSION_2010_SP2, VERSION_2013, VERSION_2013_SP1, VERSION_NONE
Instance Method Summary collapse
-
#convert_id(opts) ⇒ Object
Converts item and folder identifiers between formats.
-
#copy_folder(to_folder_id, *sources) ⇒ Object
Defines a request to copy folders in the Exchange store.
-
#copy_item(opts) ⇒ Object
Copies items and puts the items in a different folder.
-
#create_attachment(opts) ⇒ Object
Creates either an item or file attachment and attaches it to the specified item.
-
#create_folder(opts) ⇒ Object
Creates folders, calendar folders, contacts folders, tasks folders, and search folders.
-
#create_item(opts) ⇒ Object
Defines a request to create an item in the Exchange store.
-
#delete_folder(opts) ⇒ Object
Deletes folders from a mailbox.
-
#delete_item(opts) ⇒ Object
Delete an item from a mailbox in the Exchange store.
-
#empty_folder(opts) ⇒ Object
Empties folders in a mailbox.
-
#expand_dl(opts) ⇒ Object
Exposes the full membership of distribution lists.
-
#export_items(ids) ⇒ Object
Export items as a base64 string (Requires Exchange version equal or newer than VERSION 2010 SP 1).
-
#find_folder(opts) ⇒ Object
Find subfolders of an identified folder.
-
#find_item(opts) ⇒ Object
Identifies items that are located in a specified folder.
-
#get_attachment(opts) ⇒ Object
Used to retrieve existing attachments on items in the Exchange store.
-
#get_folder(opts) ⇒ Object
Gets folders from the Exchange store.
-
#get_item(opts) ⇒ Object
Gets items from the Exchange store.
-
#move_folder(to_folder_id, *sources) ⇒ Object
Defines a request to move folders in the Exchange store.
-
#move_item(opts) ⇒ Object
Used to move one or more items to a single destination folder.
-
#resolve_names(opts) ⇒ Object
Resolve ambiguous e-mail addresses and display names.
-
#send_item(opts) ⇒ Object
Used to send e-mail messages that are located in the Exchange store.
-
#update_folder(folder_changes) ⇒ Object
Update properties for a specified folder There is a lot more building in this method because most of the builders are only used for this operation so there was no need to externalize them for re-use.
-
#update_item(opts) ⇒ Object
Used to modify the properties of an existing item in the Exchange store.
Methods included from Viewpoint::EWS::SOAP
Instance Method Details
#convert_id(opts) ⇒ Object
Needs to be finished
Converts item and folder identifiers between formats.
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
# File 'lib/ews/soap/exchange_data_services.rb', line 753 def convert_id(opts) opts = opts.clone [:id, :format, :destination_format, :mailbox ].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.ConvertId {|x| builder.nbuild.parent.default_namespace = @default_ns x.parent['DestinationFormat'] = opts[:destination_format].to_s.camel_case x.SourceIds { |x| x[NS_EWS_TYPES].AlternateId { |x| x.parent['Format'] = opts[:format].to_s.camel_case x.parent['Id'] = opts[:id] x.parent['Mailbox'] = opts[:mailbox] } } } end end do_soap_request(req, response_class: EwsResponse) end |
#copy_folder(to_folder_id, *sources) ⇒ Object
Defines a request to copy folders in the Exchange store
428 429 430 431 432 433 434 435 436 437 438 439 440 |
# File 'lib/ews/soap/exchange_data_services.rb', line 428 def copy_folder(to_folder_id, *sources) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.CopyFolder { builder.nbuild.parent.default_namespace = @default_ns builder.to_folder_id!(to_folder_id) builder.folder_ids!(sources.flatten) } end end do_soap_request(req) end |
#copy_item(opts) ⇒ Object
Copies items and puts the items in a different folder
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/ews/soap/exchange_data_services.rb', line 308 def copy_item(opts) opts = opts.clone [:to_folder_id, :item_ids].each do |k| validate_param(opts, k, true) end return_new_ids = validate_param(opts, :return_new_item_ids, false, true) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.CopyItem { builder.nbuild.parent.default_namespace = @default_ns builder.to_folder_id!(opts[:to_folder_id]) builder.item_ids!(opts[:item_ids]) builder.return_new_item_ids!(return_new_ids) } end end do_soap_request(req, response_class: EwsResponse) end |
#create_attachment(opts) ⇒ Object
Need to implement attachment of Item types
Creates either an item or file attachment and attaches it to the specified item.
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 |
# File 'lib/ews/soap/exchange_data_services.rb', line 657 def (opts) opts = opts.clone [:parent_id].each do |k| validate_param(opts, k, true) end validate_param(opts, :files, false, []) validate_param(opts, :items, false, []) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.CreateAttachment {|x| builder.nbuild.parent.default_namespace = @default_ns builder.parent_item_id!(opts[:parent_id]) x.Attachments { opts[:files].each do |fa| builder.(fa) end opts[:items].each do |ia| builder.(ia) end opts[:inline_files].each do |fi| builder.(fi) end } } end end do_soap_request(req, response_class: EwsResponse) end |
#create_folder(opts) ⇒ Object
Creates folders, calendar folders, contacts folders, tasks folders, and search folders.
406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/ews/soap/exchange_data_services.rb', line 406 def create_folder(opts) opts = opts.clone req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.CreateFolder {|x| x.parent.default_namespace = @default_ns builder.parent_folder_id!(opts[:parent_folder_id]) builder.folders!(opts[:folders]) } end end do_soap_request(req) end |
#create_item(opts) ⇒ Object
Defines a request to create an item in the Exchange store.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/ews/soap/exchange_data_services.rb', line 125 def create_item(opts) opts = opts.clone [:items].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| attribs = {} attribs['MessageDisposition'] = opts[:message_disposition] if opts[:message_disposition] attribs['SendMeetingInvitations'] = opts[:send_meeting_invitations] if opts[:send_meeting_invitations] if(type == :header) else builder.nbuild.CreateItem(attribs) { builder.nbuild.parent.default_namespace = @default_ns builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id] builder.nbuild.Items { opts[:items].each {|i| # The key can be any number of item types like :message, # :calendar, etc ikey = i.keys.first builder.send("#{ikey}!",i[ikey]) } } } end end do_soap_request(req, response_class: EwsResponse) end |
#delete_folder(opts) ⇒ Object
Deletes folders from a mailbox.
454 455 456 457 458 459 460 461 462 463 464 465 |
# File 'lib/ews/soap/exchange_data_services.rb', line 454 def delete_folder(opts) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.DeleteFolder('DeleteType' => opts[:delete_type]) { builder.nbuild.parent.default_namespace = @default_ns builder.folder_ids!(opts[:folder_ids], opts[:act_as]) } end end do_soap_request(req) end |
#delete_item(opts) ⇒ Object
Delete an item from a mailbox in the Exchange store
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/ews/soap/exchange_data_services.rb', line 227 def delete_item(opts) opts = opts.clone [:delete_type, :item_ids].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| attribs = {'DeleteType' => opts[:delete_type]} attribs['SendMeetingCancellations'] = opts[:send_meeting_cancellations] if opts[:send_meeting_cancellations] attribs['AffectedTaskOccurrences'] = opts[:affected_task_occurrences] if opts[:affected_task_occurrences] if(type == :header) else builder.nbuild.DeleteItem(attribs) { builder.nbuild.parent.default_namespace = @default_ns builder.item_ids!(opts[:item_ids]) } end end do_soap_request(req, response_class: EwsResponse) end |
#empty_folder(opts) ⇒ Object
Finish
Empties folders in a mailbox.
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
# File 'lib/ews/soap/exchange_data_services.rb', line 600 def empty_folder(opts) validate_version(VERSION_2010_SP1) ef_opts = {} [:delete_type, :delete_sub_folders].each do |k| ef_opts[camel_case(k)] = validate_param(opts, k, true) end fids = validate_param opts, :folder_ids, true req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.EmptyFolder(ef_opts) {|x| builder.nbuild.parent.default_namespace = @default_ns builder.folder_ids!(fids) } end end do_soap_request(req) end |
#expand_dl(opts) ⇒ Object
Fully support all of the ExpandDL operations. Today it just supports taking an e-mail address as an argument
Exposes the full membership of distribution lists.
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
# File 'lib/ews/soap/exchange_data_services.rb', line 701 def (opts) opts = opts.clone req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.ExpandDL {|x| x.parent.default_namespace = @default_ns x.Mailbox {|mb| key = :email_address mb[NS_EWS_TYPES].EmailAddress(opts[key]) if opts[key] builder.item_id! if opts[:item_id] } } end end do_soap_request(req) end |
#export_items(ids) ⇒ Object
Export items as a base64 string (Requires Exchange version equal or newer than VERSION 2010 SP 1)
374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/ews/soap/exchange_data_services.rb', line 374 def export_items(ids) validate_version(VERSION_2010_SP1) ids = ids.clone [:item_ids].each do |k| validate_param(ids, k, true) end req = build_soap! do |type, builder| if(type == :header) else builder.export_item_ids!(ids[:item_ids]) end end do_soap_request(req, response_class: EwsResponse) end |
#find_folder(opts) ⇒ Object
add FractionalPageFolderView
Find subfolders of an identified folder
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
# File 'lib/ews/soap/exchange_data_services.rb', line 486 def find_folder(opts) opts = opts.clone [:parent_folder_ids, :traversal, :folder_shape].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.FindFolder(:Traversal => camel_case(opts[:traversal])) { builder.nbuild.parent.default_namespace = @default_ns builder.folder_shape!(opts[:folder_shape]) builder.restriction!(opts[:restriction]) if opts[:restriction] builder.parent_folder_ids!(opts[:parent_folder_ids]) } end end do_soap_request(req) end |
#find_item(opts) ⇒ Object
Identifies items that are located in a specified folder
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ews/soap/exchange_data_services.rb', line 32 def find_item(opts) opts = opts.clone [:parent_folder_ids, :traversal, :item_shape].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.FindItem(:Traversal => camel_case(opts[:traversal])) { builder.nbuild.parent.default_namespace = @default_ns builder.item_shape!(opts[:item_shape]) builder.indexed_page_item_view!(opts[:indexed_page_item_view]) if opts[:indexed_page_item_view] # @todo add FractionalPageFolderView builder.calendar_view!(opts[:calendar_view]) if opts[:calendar_view] builder.contacts_view!(opts[:contacts_view]) if opts[:contacts_view] builder.restriction!(opts[:restriction]) if opts[:restriction] builder.parent_folder_ids!(opts[:parent_folder_ids]) } end end do_soap_request(req, response_class: EwsResponse) end |
#get_attachment(opts) ⇒ Object
Used to retrieve existing attachments on items in the Exchange store
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
# File 'lib/ews/soap/exchange_data_services.rb', line 631 def (opts) opts = opts.clone [:attachment_ids].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.GetAttachment {|x| builder.nbuild.parent.default_namespace = @default_ns builder.(opts[:attachment_ids]) } end end do_soap_request(req) end |
#get_folder(opts) ⇒ Object
Gets folders from the Exchange store
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/ews/soap/exchange_data_services.rb', line 522 def get_folder(opts) opts = opts.clone [:folder_ids, :folder_shape].each do |k| validate_param(opts, k, true) end validate_param(opts[:folder_shape], :base_shape, true) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.GetFolder { builder.nbuild.parent.default_namespace = @default_ns builder.folder_shape!(opts[:folder_shape]) builder.folder_ids!(opts[:folder_ids], opts[:act_as]) } end end do_soap_request(req) end |
#get_item(opts) ⇒ Object
Gets items from the Exchange store
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ews/soap/exchange_data_services.rb', line 72 def get_item(opts) opts = opts.clone [:item_shape, :item_ids].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.GetItem { builder.nbuild.parent.default_namespace = @default_ns builder.item_shape!(opts[:item_shape]) builder.item_ids!(opts[:item_ids]) } end end do_soap_request(req, response_class: EwsResponse) end |
#move_folder(to_folder_id, *sources) ⇒ Object
Defines a request to move folders in the Exchange store
548 549 550 551 552 553 554 555 556 557 558 559 560 |
# File 'lib/ews/soap/exchange_data_services.rb', line 548 def move_folder(to_folder_id, *sources) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.MoveFolder { builder.nbuild.parent.default_namespace = @default_ns builder.to_folder_id!(to_folder_id) builder.folder_ids!(sources.flatten) } end end do_soap_request(req) end |
#move_item(opts) ⇒ Object
Used to move one or more items to a single destination folder.
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/ews/soap/exchange_data_services.rb', line 267 def move_item(opts) opts = opts.clone [:to_folder_id, :item_ids].each do |k| validate_param(opts, k, true) end return_new_ids = validate_param(opts, :return_new_item_ids, false, true) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.MoveItem { builder.nbuild.parent.default_namespace = @default_ns builder.to_folder_id!(opts[:to_folder_id]) builder.item_ids!(opts[:item_ids]) builder.return_new_item_ids!(return_new_ids) } end end do_soap_request(req, response_class: EwsResponse) end |
#resolve_names(opts) ⇒ Object
Resolve ambiguous e-mail addresses and display names
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
# File 'lib/ews/soap/exchange_data_services.rb', line 732 def resolve_names(opts) opts = opts.clone fcd = opts.has_key?(:full_contact_data) ? opts[:full_contact_data] : true req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.ResolveNames {|x| x.parent['ReturnFullContactData'] = fcd.to_s x.parent['SearchScope'] = opts[:search_scope] if opts[:search_scope] x.parent.default_namespace = @default_ns # @todo builder.nbuild.ParentFolderIds x.UnresolvedEntry(opts[:name]) } end end do_soap_request(req) end |
#send_item(opts) ⇒ Object
Used to send e-mail messages that are located in the Exchange store.
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/ews/soap/exchange_data_services.rb', line 347 def send_item(opts) opts = opts.clone [:item_ids].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| attribs = {} attribs['SaveItemToFolder'] = validate_param(opts, :save_item_to_folder, false, true) if(type == :header) else builder.nbuild.SendItem(attribs) { builder.nbuild.parent.default_namespace = @default_ns builder.item_ids!(opts[:item_ids]) builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id] } end end do_soap_request(req, response_class: EwsResponse) end |
#update_folder(folder_changes) ⇒ Object
Update properties for a specified folder There is a lot more building in this method because most of the builders are only used for this operation so there was no need to externalize them for re-use.
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
# File 'lib/ews/soap/exchange_data_services.rb', line 568 def update_folder(folder_changes) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.UpdateFolder { builder.nbuild.parent.default_namespace = @default_ns builder.nbuild.FolderChanges { folder_changes.each do |fc| builder[NS_EWS_TYPES].FolderChange { builder.dispatch_folder_id!(fc) builder[NS_EWS_TYPES].Updates { # @todo finish implementation } } end } } end end do_soap_request(req) end |
#update_item(opts) ⇒ Object
Used to modify the properties of an existing item in the Exchange store
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/ews/soap/exchange_data_services.rb', line 184 def update_item(opts) opts = opts.clone [:item_changes].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| attribs = {} attribs['MessageDisposition'] = opts[:message_disposition] if opts[:message_disposition] attribs['ConflictResolution'] = opts[:conflict_resolution] if opts[:conflict_resolution] attribs['SendMeetingInvitationsOrCancellations'] = opts[:send_meeting_invitations_or_cancellations] if opts[:send_meeting_invitations_or_cancellations] if(type == :header) else builder.nbuild.UpdateItem(attribs) { builder.nbuild.parent.default_namespace = @default_ns builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id] builder.item_changes!(opts[:item_changes]) } end end do_soap_request(req, response_class: EwsResponse) end |