Class: Rews::Folder::BaseFolderId
- Inherits:
-
Object
- Object
- Rews::Folder::BaseFolderId
- Includes:
- Util
- Defined in:
- lib/rews/folder.rb
Overview
Identifies a Folder
Direct Known Subclasses
Constant Summary collapse
- FIND_FOLDER_OPTS =
{ :restriction=>nil, :indexed_page_folder_view=>View::INDEXED_PAGE_VIEW_OPTS, :folder_shape=>Shape::FOLDER_SHAPE_OPTS}
- FIND_ITEM_OPTS =
{ :restriction=>nil, :sort_order=>nil, :indexed_page_item_view=>View::INDEXED_PAGE_VIEW_OPTS, :item_shape=>Shape::ITEM_SHAPE_OPTS}
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#find_folder(opts = {}) ⇒ Object
find
Folder::Folder
s within aFolder::Folder
. -
#find_folder_id(opts = {}) ⇒ Object
find
Folder::FolderIds
s within aFolder::FolderIds
. -
#find_item(opts = {}) ⇒ Object
find
Item::Item
s in a folder. -
#find_item_id(opts = {}) ⇒ Object
find
Item::ItemIds
s in a folder. -
#initialize(client) ⇒ BaseFolderId
constructor
A new instance of BaseFolderId.
Methods included from Util
apply_namespace, camel_keys, camelize, camelize_qname, check_opts, rsxml_to_xml, single_error_check, strip_bang, tag_exception, with_error_check
Constructor Details
#initialize(client) ⇒ BaseFolderId
Returns a new instance of BaseFolderId.
93 94 95 |
# File 'lib/rews/folder.rb', line 93 def initialize(client) @client=client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
91 92 93 |
# File 'lib/rews/folder.rb', line 91 def client @client end |
Instance Method Details
#find_folder(opts = {}) ⇒ Object
find Folder::Folder
s within a Folder::Folder
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/rews/folder.rb', line 103 def find_folder(opts={}) opts = check_opts(FIND_FOLDER_OPTS, opts) r = with_error_check(client, :find_folder_response, :response_messages, :find_folder_response_message) do client.savon_client.request(:wsdl, "FindFolder", "Traversal"=>"Shallow") do http.headers["SOAPAction"] = "\"#{SCHEMA_MESSAGES}/FindFolder\"" # required by EWS 2007 soap.namespaces["xmlns:t"]=SCHEMA_TYPES xml = Builder::XmlMarkup.new xml << Shape::FolderShape.new(opts[:folder_shape]||{}).to_xml xml << View::IndexedPageFolderView.new(opts[:indexed_page_folder_view]).to_xml if opts[:indexed_page_folder_view] xml << Restriction.new(opts[:restriction]).to_xml if opts[:restriction] xml.wsdl :ParentFolderIds do xml << self.to_xml end soap.body = xml.target! end end FindResult.new(r.fetch_in(:root_folder)) do |view| results = view.fetch_in(:folders, :folder) results = [results] if !results.is_a?(Array) results.compact.map do |folder| Folder.new(client, folder) end end end |
#find_folder_id(opts = {}) ⇒ Object
find Folder::FolderIds
s within a Folder::FolderIds
133 134 135 136 137 138 139 140 141 142 |
# File 'lib/rews/folder.rb', line 133 def find_folder_id(opts={}) opts = check_opts(FIND_FOLDER_OPTS, opts) shape = opts[:folder_shape] ||={} shape[:base_shape]||=:IdOnly r = find_folder(opts) r.result.map!(&:folder_id) r end |
#find_item(opts = {}) ⇒ Object
find Item::Item
s in a folder
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/rews/folder.rb', line 151 def find_item(opts={}) opts = check_opts(FIND_ITEM_OPTS, opts) r = with_error_check(client, :find_item_response, :response_messages, :find_item_response_message) do client.savon_client.request(:wsdl, "FindItem", "Traversal"=>"Shallow") do http.headers["SOAPAction"] = "\"#{SCHEMA_MESSAGES}/FindItem\"" # required by EWS 2007 soap.namespaces["xmlns:t"]=SCHEMA_TYPES xml = Builder::XmlMarkup.new xml << Shape::ItemShape.new(opts[:item_shape]||{}).to_xml xml << View::IndexedPageItemView.new(opts[:indexed_page_item_view]).to_xml if opts[:indexed_page_item_view] xml << Restriction.new(opts[:restriction]).to_xml if opts[:restriction] xml << SortOrder.new(opts[:sort_order]).to_xml if opts[:sort_order] xml.wsdl :ParentFolderIds do xml << self.to_xml end soap.body = xml.target! end end FindResult.new(r.to_hash.fetch_in(:root_folder)) do |view| results = Item.read_items(client, view[:items]) end end |
#find_item_id(opts = {}) ⇒ Object
find Item::ItemIds
s in a folder
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/rews/folder.rb', line 181 def find_item_id(opts={}) opts = check_opts(FIND_ITEM_OPTS, opts) shape = opts[:item_shape] ||= {} shape[:base_shape]||=:IdOnly r = find_item(opts) r.result.map!(&:item_id) r end |