Class: Rews::Folder::DistinguishedFolderId

Inherits:
BaseFolderId show all
Defined in:
lib/rews/folder.rb

Overview

identifies a DistinguishedFolder in a mailbox on an Exchange server. the Client.distinguished_folder_id method returns DistinguishedFolderIds

Constant Summary

Constants inherited from BaseFolderId

BaseFolderId::FIND_FOLDER_OPTS, BaseFolderId::FIND_ITEM_OPTS

Instance Attribute Summary collapse

Attributes inherited from BaseFolderId

#client

Instance Method Summary collapse

Methods inherited from BaseFolderId

#find_folder, #find_folder_id, #find_item, #find_item_id

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, id, mailbox_email = nil) ⇒ DistinguishedFolderId

Returns a new instance of DistinguishedFolderId.



246
247
248
249
250
251
# File 'lib/rews/folder.rb', line 246

def initialize(client, id, mailbox_email=nil)
  super(client)
  @id = id
  @mailbox_email = mailbox_email
  raise "no id" if !@id
end

Instance Attribute Details

#idObject (readonly)

the Id of the DistinguishedFolder e.g. "inbox"



241
242
243
# File 'lib/rews/folder.rb', line 241

def id
  @id
end

#mailbox_emailObject (readonly)

the email address of the mailbox containing the DistinguishedFolder



244
245
246
# File 'lib/rews/folder.rb', line 244

def mailbox_email
  @mailbox_email
end

Instance Method Details

#==(other) ⇒ Object



253
254
255
256
257
258
# File 'lib/rews/folder.rb', line 253

def ==(other)
  other.is_a?(DistinguishedFolderId) &&
    @client == other.client &&
    @id == other.id &&
    @mailbox_email == other.mailbox_email
end

#inspectObject



279
280
281
# File 'lib/rews/folder.rb', line 279

def inspect
  "#<#{self.class} @id=#{id}, @mailbox_email=#{mailbox_email}>"
end

#key(ignore_change_key = false) ⇒ Object

a JSON compatible key for persistently identifying this folder



261
262
263
264
265
# File 'lib/rews/folder.rb', line 261

def key(ignore_change_key=false)
  key = ["distinguished_folder", id]
  key << mailbox_email if mailbox_email
  key
end

#to_xmlObject



267
268
269
270
271
272
273
274
275
276
277
# File 'lib/rews/folder.rb', line 267

def to_xml
  xml = Builder::XmlMarkup.new
  xml.t :DistinguishedFolderId, :Id=>id do
    if mailbox_email
      xml.t :Mailbox do
        xml.t :EmailAddress, mailbox_email
      end
    end
  end
  xml.target!
end