Class: Zm::Client::DistributionListAliasesCollection

Inherits:
Object
  • Object
show all
Includes:
MissingMethodStaticCollection
Defined in:
lib/zm/client/distributionlist/distributionlist_aliases_collection.rb

Overview

Collection Account Aliases

Instance Attribute Summary

Attributes included from MissingMethodStaticCollection

#all

Instance Method Summary collapse

Methods included from MissingMethodStaticCollection

#method_missing

Constructor Details

#initialize(parent) ⇒ DistributionListAliasesCollection

Returns a new instance of DistributionListAliasesCollection.



9
10
11
12
13
# File 'lib/zm/client/distributionlist/distributionlist_aliases_collection.rb', line 9

def initialize(parent)
  @parent = parent
  @all = []
  build_aliases
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MissingMethodStaticCollection

Instance Method Details

#add!(email) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/zm/client/distributionlist/distributionlist_aliases_collection.rb', line 15

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

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

  @all.push(email)
  true
end

#remove!(email) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/zm/client/distributionlist/distributionlist_aliases_collection.rb', line 26

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

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

  @all.delete(email)
  true
end