Module: Viewpoint::EWS::ItemAccessors

Includes:
Viewpoint::EWS
Included in:
Types::GenericFolder, Viewpoint::EWSClient
Defined in:
lib/ews/item_accessors.rb

Overview

This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.

Copyright 

Constant Summary

Constants included from Viewpoint::EWS

ConnectingSID

Instance Attribute Summary

Attributes included from Viewpoint::EWS

#logger

Instance Method Summary collapse

Methods included from Viewpoint::EWS

#remove_impersonation, root_logger, #set_impersonation

Instance Method Details

#copy_items(items, folder) ⇒ Array<Hash>

Copy an array of items to the specified folder

Parameters:

  • items (Array)

    an array of EWS Items that you want to copy

  • folder (String, Symbol, GenericFolder)

    The folder to copy to. This must be a subclass of GenericFolder, a DistinguishedFolderId (must me a Symbol) or a FolderId (String)

Returns:

  • (Array<Hash>)

    returns a Hash for each item passed on success:

    {:success => true, :item_id => <new_item_id>}
    

    on failure:

    {:success => false, :error_message => <the message>}
    


75
76
77
78
79
80
81
82
83
84
# File 'lib/ews/item_accessors.rb', line 75

def copy_items(items, folder)
  folder = folder.id if folder.kind_of?(Types::GenericFolder)
  item_ids = items.collect{|i| {item_id: {id: i.id, change_key: i.change_key}}}
  copy_opts = {
    :to_folder_id => {:id => folder},
    :item_ids => item_ids
  }
  resp = ews.copy_item(copy_opts)
  copy_move_items_parser(resp)
end

#export_items(item_ids) ⇒ Object

Exports an entire item into base64 string return [Array] array of bulk items

Parameters:

  • item_ids (Array)

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



102
103
104
105
106
107
# File 'lib/ews/item_accessors.rb', line 102

def export_items(item_ids)
  args = export_items_args(item_ids)

  resp = ews.export_items(args)
  export_items_parser(resp)
end

#find_items(opts = {}) {|obj| ... } ⇒ Object

Parameters:

  • opts (Hash) (defaults to: {})

    Misc options to control request

Options Hash (opts):

  • :folder_id (Symbol)

Yields:

  • (obj)

See Also:

  • GenericFolder#items


40
41
42
43
44
45
46
47
# File 'lib/ews/item_accessors.rb', line 40

def find_items(opts = {})
  args = find_items_args(opts.clone)
  obj = OpenStruct.new(opts: args, restriction: {})
  yield obj if block_given?
  merge_restrictions! obj
  resp = ews.find_item(args)
  find_items_parser resp
end

#get_item(item_id, opts = {}) {|obj| ... } ⇒ Item

TODO:

Add support to fetch an item with a ChangeKey

This is a class method that fetches an existing Item from the

Exchange Store.

Parameters:

  • item_id (String)

    The id of the item. You can also pass a Hash in the form: <fold_id>, change_key: <change_key>

  • opts (Hash) (defaults to: {})

    Misc options to control request

Options Hash (opts):

  • :shape (Symbol)

    :id_only/:default/:all_properties

Yields:

  • (obj)

Returns:

  • (Item)

    Returns an Item or subclass of Item



29
30
31
32
33
34
35
# File 'lib/ews/item_accessors.rb', line 29

def get_item(item_id, opts = {})
  args = get_item_args(item_id, opts.clone)
  obj = OpenStruct.new(opts: args)
  yield obj if block_given?
  resp = ews.get_item(args)
  get_item_parser(resp)
end

#get_items(item_ids, opts = {}) {|obj| ... } ⇒ Item

TODO:

Add support to fetch an item with a ChangeKey

This is a class method that fetches an existing Item from the

Exchange Store.

Parameters:

  • item_id (String)

    The id of the item. You can also pass a Hash in the form: <fold_id>, change_key: <change_key>

  • opts (Hash) (defaults to: {})

    Misc options to control request

Options Hash (opts):

  • :shape (Symbol)

    :id_only/:default/:all_properties

Yields:

  • (obj)

Returns:

  • (Item)

    Returns an Item or subclass of Item



57
58
59
60
61
62
63
# File 'lib/ews/item_accessors.rb', line 57

def get_items(item_ids, opts = {})
  args = get_item_args(item_ids, opts.clone)
  obj = OpenStruct.new(opts: args)
  yield obj if block_given?
  resp = ews.get_item(args)
  get_items_parser(resp)
end

#move_items(items, folder) ⇒ Object

Move an array of items to the specified folder

See Also:



88
89
90
91
92
93
94
95
96
97
# File 'lib/ews/item_accessors.rb', line 88

def move_items(items, folder)
  folder = folder.id if folder.kind_of?(Types::GenericFolder)
  item_ids = items.collect{|i| {item_id: {id: i.id, change_key: i.change_key}}}
  move_opts = {
    :to_folder_id => {:id => folder},
    :item_ids => item_ids
  }
  resp = ews.move_item(move_opts)
  copy_move_items_parser(resp, :move_item_response_message)
end