Class: Zm::Client::AccountAliasesCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/zm/client/account/account_aliases_collection.rb

Overview

Collection Account Aliases

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ AccountAliasesCollection

Returns a new instance of AccountAliasesCollection.



7
8
9
10
# File 'lib/zm/client/account/account_aliases_collection.rb', line 7

def initialize(parent)
  @parent = parent
  build_aliases
end

Instance Method Details

#add!(email) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/zm/client/account/account_aliases_collection.rb', line 16

def add!(email)
  return false if all.include?(Utils.format_email(email))

  soap_request = SoapElement.admin(SoapAdminConstants::ADD_ACCOUNT_ALIAS_REQUEST)
  soap_request.add_attributes({ id: @parent.id, alias: email })
  @parent.sac.invoke(soap_request)

  all.push(email)
  true
end

#allObject



12
13
14
# File 'lib/zm/client/account/account_aliases_collection.rb', line 12

def all
  @parent.zimbraMailAlias
end

#remove!(email) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/zm/client/account/account_aliases_collection.rb', line 27

def remove!(email)
  return false unless all.include?(Utils.format_email(email))

  soap_request = SoapElement.admin(SoapAdminConstants::REMOVE_ACCOUNT_ALIAS_REQUEST)
  soap_request.add_attributes({ id: @parent.id, alias: email })
  @parent.sac.invoke(soap_request)

  all.delete(email)
  true
end