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

Methods included from Viewpoint::EWS::SOAP

#initialize

Instance Method Details

#convert_id(opts) ⇒ Object

TODO:

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

Parameters:

  • to_folder_id (Hash)

    The target FolderId => <myid>, :change_key => <optional ck>

  • *sources (Array<Hash>)

    The source Folders => <myid>, :change_key => <optional_ck>, => <myid2>, :change_key => <optional_ck>

See Also:



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

Examples:

opts = {
  :to_folder_id => {:id => :inbox},
  :item_ids => [
    {:item_id => {:id => 'id1'}},
    {:item_id => {:id => 'id2'}},
  ],
  :return_new_item_ids => true
  }
obj.copy_item(opts)

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :to_folder_id (Hash)

    A well formatted folder_id Hash. Ex: => :inbox

  • :item_ids (Array<Hash>)

    ItemIds Hash. The keys in these Hashes can be :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the Microsoft docs for more information.

  • :return_new_item_ids (Boolean)

    Indicates whether the item identifiers of new items are returned in the response

See Also:



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

TODO:

Need to implement attachment of Item types

Creates either an item or file attachment and attaches it to the specified item.

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :parent_id (Hash)

    <id>, change_key: <ck>

  • :files (Array<Hash>)

    An Array of Base64 encoded Strings with an associated name: => <name>, :content => <Base64 encoded string>

  • :items (Array)

    Exchange Items to attach to this Item

See Also:



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 create_attachment(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.file_attachment!(fa)
          end
          opts[:items].each do |ia|
            builder.item_attachment!(ia)
          end
          opts[:inline_files].each do |fi|
            builder.inline_attachment!(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.

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :parent_folder_id (Hash)

    A hash with either the name of a folder or it’s numerical ID. See: msdn.microsoft.com/en-us/library/aa565998.aspx => :root or => ‘myfolderid#’

  • :folders (Array<Hash>)

    An array of hashes of folder types that conform to input for build_xml! @example [

    {:folder =>
      {:display_name => "New Folder"}},
    {:calendar_folder =>
      {:folder_id => {:id => 'blah', :change_key => 'blah'}}}
    

See Also:



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.

Examples:

opts = {
  message_disposition: 'SendAndSaveCopy',
  items: [ {message:
    {subject: 'test2',
     body: {body_type: 'Text', text: 'this is a test'},
     to_recipients: [{mailbox: {email_address: '[email protected]'}}]
    }
  }]}

opts = {
  send_meeting_invitations: 'SendToAllAndSaveCopy',
  items: [ {calendar_item:
    {subject: 'test cal item',
     body: {body_type: 'Text', text: 'this is a test cal item'},
     start: {text: Chronic.parse('tomorrow at 4pm').to_datetime.to_s},
     end: {text: Chronic.parse('tomorrow at 5pm').to_datetime.to_s},
     required_attendees: [
      {attendee: {mailbox: {email_address: '[email protected]'}}},
     ]
    }
  }]

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :message_disposition (String)

    How the item will be handled after it is created. Only applicable for to e-mail. Must be one of ‘SaveOnly’, ‘SendOnly’, or ‘SendAndSaveCopy’

  • :send_meeting_invitations (String)

    How meeting requests are handled after they are created. Required for calendar items. Must be one of ‘SendToNone’, ‘SendOnlyToAll’, ‘SendToAllAndSaveCopy’

  • :saved_item_folder_id (Hash)

    A well formatted folder_id Hash. Ex: => :inbox Will on work if ‘SendOnly’ is specified for :message_disposition

  • :items (Array<Hash>)

    This is a complex Hash that conforms to various Item types. Please see the Microsoft documentation for this element.

See Also:



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.

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :folder_ids (Array<Hash>)

    An array of folder_ids in the form: [ => ‘myfolderID##asdfs’, :change_key => ‘asdfasdf’,

    {:id => :msgfolderroot} ]  # Don't do this for real
    
  • :delete_type (String, nil)

    Type of delete to do: HardDelete/SoftDelete/MoveToDeletedItems

  • :act_as (String, nil)

    User to act on behalf as. This user must have been given delegate access to this folder or else this operation will fail.

See Also:



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

Examples:

opts = {
  :delete_type => 'MoveToDeletedItems',
  :item_ids => [{:item_id => {:id => 'id1'}}]
  }
inst.delete_item(opts)

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :delete_type (String)

    Describes how an item is deleted. Must be one of ‘HardDelete’, ‘SoftDelete’, or ‘MoveToDeletedItems’

  • :send_meeting_cancellations (String)

    How meetings are handled after they are deleted. Required for calendar items. Must be one of ‘SendToNone’, ‘SendOnlyToAll’, ‘SendToAllAndSaveCopy’

  • :affected_task_occurrences (String)

    Describes whether a task instance or a task master is deleted by a DeleteItem Operation. This attribute is required when tasks are deleted. Must be one of ‘AllOccurrences’ or ‘SpecifiedOccurrenceOnly’

  • :item_ids (Array<Hash>)

    ItemIds Hash. The keys in these Hashes can be :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the Microsoft docs for more information.

See Also:



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

TODO:

Finish

Empties folders in a mailbox.

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :delete_type (String)

    Must be one of ExchangeDataServices::HARD_DELETE, SOFT_DELETE, or MOVE_TO_DELETED_ITEMS

  • :delete_sub_folders (Boolean)
  • :folder_ids (Array<Hash>)

    An array of folder_ids in the form: [ => ‘myfolderID##asdfs’, :change_key => ‘asdfasdf’,

    {:id => 'blah'} ]
    

See Also:



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

TODO:

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.

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :email_address (String)

    The e-mail address of the distribution to resolve

  • :item_id (Hash)

    The ItemId of the private distribution to resolve. => ‘my id’

See Also:



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 expand_dl(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)

Parameters:

  • ids (Array)

    array of item ids. Can also be a single id value

See Also:



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

TODO:

add FractionalPageFolderView

Find subfolders of an identified folder

Examples:

{ :parent_folder_ids => [{:id => root}],
  :traversal => 'Deep',
  :folder_shape  => {:base_shape => 'Default'} }

Parameters:

  • opts (Hash)
  • folder_shape (Hash)

    a customizable set of options

Options Hash (opts):

  • :parent_folder_ids (Array<Hash>)

    An Array of folder id Hashes, either a DistinguishedFolderId (must me a Symbol) or a FolderId (String)

    => <myid>, :change_key => <ck>, => :root
  • :traversal (String)

    Shallow/Deep/SoftDeleted

  • :folder_shape (Hash)

    defines the FolderShape node See: msdn.microsoft.com/en-us/library/aa494311.aspx

  • :restriction (Hash)

    A well formatted restriction Hash.

See Also:



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

Examples:

{ :parent_folder_ids => [{:id => root}],
  :traversal => 'Shallow',
  :item_shape  => {:base_shape => 'Default'} }

Parameters:

  • opts (Hash)
  • item_shape (Hash)

    a customizable set of options

Options Hash (opts):

  • :parent_folder_ids (Array<Hash>)

    An Array of folder id Hashes, either a DistinguishedFolderId (must me a Symbol) or a FolderId (String)

    => <myid>, :change_key => <ck>, => :root
  • :traversal (String)

    Shallow/Deep/SoftDeleted

  • :item_shape (Hash)

    defines the ItemShape node

  • :calendar_view (Hash)

    Limit FindItem by a start and end date => {:max_entries_returned => 2, :start_date => <DateTime Obj>, :end_date => <DateTime Obj>}

  • :contacts_view (Hash)

    Limit FindItem between contact names => {:max_entries_returned => 2, :initial_name => ‘Dan’, :final_name => ‘Wally’}

See Also:



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

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :attachment_ids (Array)

    Attachment Ids to fetch

  • :attachment_shape (Hash)

    Attachment shape include_mime_content: true or false (optional) body_type: “Best” | “HTML” | “Text” (optional) filter_html_content: true or false (optional) additional_properties: @todo finish implementation

See Also:



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 get_attachment(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.attachment_ids!(opts[:attachment_ids])
      }
    end
  end
  do_soap_request(req)
end

#get_folder(opts) ⇒ Object

Gets folders from the Exchange store

Examples:

{ :folder_ids   => [{:id => :msgfolderroot}],
  :folder_shape => {:base_shape => 'Default'} }

Parameters:

  • opts (Hash)
  • folder_shape (Hash)

    a customizable set of options

Options Hash (opts):

  • :folder_ids (Array<Hash>)

    An array of folder_ids in the form: [ => ‘myfolderID##asdfs’, :change_key => ‘asdfasdf’,

    {:id => :msgfolderroot} ]
    
  • :folder_shape (Hash)

    defines the FolderShape node

  • :act_as (String, nil)

    User to act on behalf as. This user must have been given delegate access to this folder or else this operation will fail.

See Also:



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

Examples:

opts = {
  :item_shape => {:base_shape => 'Default'},
  :item_ids   => [
    {:item_id => {:id => 'id1'}},
    {:occurrence_item_id => {:recurring_master_id => 'rid1', :change_key => 'ck', :instance_index => 1}},
    {:recurring_master_item_id => {:occurrence_id => 'oid1', :change_key => 'ck'}}
    ]}

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :item_shape (Hash)

    The item shape properties Ex: => ‘Default’

  • :item_ids (Array<Hash>)

    ItemIds Hash. The keys in these Hashes can be :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the Microsoft docs for more information.

See Also:



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

Parameters:

  • to_folder_id (Hash)

    The target FolderId => <myid>, :change_key => <optional ck>

  • *sources (Array<Hash>)

    The source Folders => <myid>, :change_key => <optional_ck>, => <myid2>, :change_key => <optional_ck>

See Also:



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.

Examples:

opts = {
  :to_folder_id => {:id => :inbox},
  :item_ids => [
    {:item_id => {:id => 'id1'}},
    {:item_id => {:id => 'id2'}},
  ],
  :return_new_item_ids => true
  }
obj.move_item(opts)

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :to_folder_id (Hash)

    A well formatted folder_id Hash. Ex: => :inbox

  • :item_ids (Array<Hash>)

    ItemIds Hash. The keys in these Hashes can be :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the Microsoft docs for more information.

  • :return_new_item_ids (Boolean)

    Indicates whether the item identifiers of new items are returned in the response

See Also:



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

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :name (String)

    the unresolved entry

  • :full_contact_data (Boolean) — default: true

    Whether or not to return the full contact details.

  • :search_scope (String)

    where to seach for this entry, one of SOAP::Contacts, SOAP::ActiveDirectory, SOAP::ActiveDirectoryContacts (default), SOAP::ContactsActiveDirectory

  • :parent_folder_id (String, FolderId)

    either the name of a folder or it’s numerical ID. @see msdn.microsoft.com/en-us/library/aa565998.aspx

See Also:



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.

Examples:

opts = {
  :save_item_to_folder => true,
  :saved_item_folder_id => {:id => :sentitems},
  :item_ids => [
    {:item_id => {:id => 'id1'}},
    {:item_id => {:id => 'id2'}},
  ]}
obj.send_item(opts)

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :save_item_to_folder (Boolean)

    To save or not to save… save! :-)

  • :saved_item_folder_id (Hash)

    A well formatted folder_id Hash. Ex: => :sentitems

  • :item_ids (Array<Hash>)

    ItemIds Hash. The keys in these Hashes can be :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the Microsoft docs for more information.

See Also:



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.

Parameters:

  • folder_changes (Array<Hash>)

    an Array of well formatted Hashes

See Also:



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

Examples:

opts = {
  :send_meeting_invitations_or_cancellations => 'SendOnlyToChangedAndSaveCopy',
  :item_changes => [
    { :item_id => {:id => 'id1'},
      :updates => [
        {:set_item_field => {
          :field_uRI => {:field_uRI => 'item:Subject'},
          # The following needs to conform to #build_xml! format for now
          :calendar_item => { :sub_elements => [{:subject => {:text => 'Test Subject'}}]}
        }}
      ]
    }
  ]
}

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :conflict_resolution (String)

    Identifies the type of conflict resolution to try during an update. The default value is AutoResolve. Available options are ‘NeverOverwrite’, ‘AutoResolve’, ‘AlwaysOverwrite’

  • :message_disposition (String)

    How the item will be handled after it is updated. Only applicable for to e-mail. Must be one of ‘SaveOnly’, ‘SendOnly’, or ‘SendAndSaveCopy’

  • :send_meeting_invitations_or_cancellations (String)

    How meeting requests are handled after they are updated. Required for calendar items. Must be one of ‘SendToNone’, ‘SendOnlyToAll’, ‘SendOnlyToChanged’, ‘SendToAllAndSaveCopy’, ‘SendToChangedAndSaveCopy’

  • :saved_item_folder_id (Hash)

    A well formatted folder_id Hash. Ex: => :sentitems Will on work if ‘SendOnly’ is specified for :message_disposition

  • :item_changes (Array<Hash>)

    an array of ItemChange elements that identify items and the updates to apply to the items. See the Microsoft docs for more information.

See Also:



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