Class: Zm::Client::Base::MailboxObject

Inherits:
Object
  • Object
show all
Includes:
HasSoapAdminConnector
Defined in:
lib/zm/client/base/mailbox_object.rb

Overview

Abstract Class for Account and Resource

Direct Known Subclasses

Account, Resource

Instance Attribute Summary collapse

Attributes inherited from Object

#id, #name, #parent, #token

Instance Method Summary collapse

Methods included from HasSoapAdminConnector

#soap_admin_connector

Methods inherited from Object

#clone, #initialize, #inspect, #instance_variables_map, #logger, #recorded?, #save!, #to_h, #to_s, #update_attribute

Constructor Details

This class inherits a constructor from Zm::Client::Base::Object

Instance Attribute Details

#carLicenseObject

Returns the value of attribute carLicense.



28
29
30
# File 'lib/zm/client/base/mailbox_object.rb', line 28

def carLicense
  @carLicense
end

#domain_keyObject



85
86
87
88
89
90
# File 'lib/zm/client/base/mailbox_object.rb', line 85

def domain_key
  return @domain_key if @domain_key
  return @parent.domain_key(domain_name) if @parent.logged?

  nil
end

#home_urlObject

Returns the value of attribute home_url.



28
29
30
# File 'lib/zm/client/base/mailbox_object.rb', line 28

def home_url
  @home_url
end

#passwordObject

Returns the value of attribute password.



28
29
30
# File 'lib/zm/client/base/mailbox_object.rb', line 28

def password
  @password
end

#public_urlObject

Returns the value of attribute public_url.



28
29
30
# File 'lib/zm/client/base/mailbox_object.rb', line 28

def public_url
  @public_url
end

#usedObject



54
55
56
# File 'lib/zm/client/base/mailbox_object.rb', line 54

def used
  @used || used!
end

Instance Method Details

#account_content_byObject



128
129
130
# File 'lib/zm/client/base/mailbox_object.rb', line 128

def 
  @id ? [@id, :id] : [@name, :name]
end

#account_loginObject



100
101
102
103
104
105
106
107
108
# File 'lib/zm/client/base/mailbox_object.rb', line 100

def 
  sacc.token = nil

  if password
    
  else
    
  end
end

#account_login_passwordObject

Raises:



119
120
121
122
123
124
125
126
# File 'lib/zm/client/base/mailbox_object.rb', line 119

def 
  raise ZmError, 'password is required to login !' if password.nil?

  content, by = 

  @token = sacc.auth_password(content, by, @password)
  sacc.context.token(@token)
end

#account_login_preauth(expires = 0) ⇒ Object

Raises:



110
111
112
113
114
115
116
117
# File 'lib/zm/client/base/mailbox_object.rb', line 110

def (expires = 0)
  raise ZmError, 'domain key is required to login !' if domain_key.nil?

  content, by = 

  @token = sacc.auth_preauth(content, by, expires, domain_key)
  sacc.context.token(@token)
end

#acesObject Also known as: rights



197
198
199
# File 'lib/zm/client/base/mailbox_object.rb', line 197

def aces
  @aces ||= AcesCollection.new(self)
end

#admin_loginObject



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/zm/client/base/mailbox_object.rb', line 132

def 
  # @token = sac.delegate_auth(@name)

  soap_request = SoapElement.admin(SoapAdminConstants::DELEGATE_AUTH_REQUEST)
   = SoapElement.create(SoapConstants::ACCOUNT)

  if recorded?
    .add_attribute(SoapConstants::BY, SoapConstants::ID).add_content(@id)
  else
    .add_attribute(SoapConstants::BY, SoapConstants::NAME).add_content(@name)
  end

  soap_request.add_node()
  @token = sac.invoke(soap_request)[:DelegateAuthResponse][:authToken].first[:_content]
  sacc.context.token(@token)
end

#appointmentsObject



185
186
187
# File 'lib/zm/client/base/mailbox_object.rb', line 185

def appointments
  @appointments ||= AppointmentsCollection.new(self)
end

#contactsObject



181
182
183
# File 'lib/zm/client/base/mailbox_object.rb', line 181

def contacts
  @contacts ||= ContactsCollection.new(self)
end

#data_sourcesObject



226
227
228
# File 'lib/zm/client/base/mailbox_object.rb', line 226

def data_sources
  @data_sources ||= DataSourcesCollection.new(self)
end

#dls_ownerObject



214
215
216
# File 'lib/zm/client/base/mailbox_object.rb', line 214

def dls_owner
  @dls_owner ||= AccountDlsOwnerCollection.new(self)
end

#documentsObject



206
207
208
# File 'lib/zm/client/base/mailbox_object.rb', line 206

def documents
  @documents ||= DocumentsCollection.new(self)
end

#domain_nameObject



42
43
44
# File 'lib/zm/client/base/mailbox_object.rb', line 42

def domain_name
  @domain_name ||= @name.split('@').last
end

#filter_rulesObject



218
219
220
# File 'lib/zm/client/base/mailbox_object.rb', line 218

def filter_rules
  @filter_rules ||= FilterRulesCollection.new(self)
end

#foldersObject



161
162
163
# File 'lib/zm/client/base/mailbox_object.rb', line 161

def folders
  @folders ||= FoldersCollection.new(self)
end

#identitiesObject



173
174
175
# File 'lib/zm/client/base/mailbox_object.rb', line 173

def identities
  @identities ||= IdentitiesCollection.new(self)
end

#infosObject



46
47
48
# File 'lib/zm/client/base/mailbox_object.rb', line 46

def infos
  @infos ||= MailboxInfosCollection.new(self)
end

#is_external_transport?Boolean

Returns:

  • (Boolean)


281
282
283
284
285
# File 'lib/zm/client/base/mailbox_object.rb', line 281

def is_external_transport?
  return nil unless zimbraMailTransport

  zimbraMailTransport.start_with?(SoapConstants::SMTP)
end

#is_local_transport?Boolean

Returns:

  • (Boolean)


275
276
277
278
279
# File 'lib/zm/client/base/mailbox_object.rb', line 275

def is_local_transport?
  return nil unless zimbraMailTransport

  zimbraMailTransport.start_with?(SoapConstants::LMTP)
end

#last_logonObject



287
288
289
# File 'lib/zm/client/base/mailbox_object.rb', line 287

def last_logon
  @last_logon ||= Time.parse(zimbraLastLogonTimestamp) unless zimbraLastLogonTimestamp.nil?
end

#local_transportObject



265
266
267
268
269
# File 'lib/zm/client/base/mailbox_object.rb', line 265

def local_transport
  raise Zm::Client::ZmError, 'zimbraMailHost is null' if zimbraMailHost.nil?

  "lmtp:#{zimbraMailHost}:7025"
end

#local_transport!Object



271
272
273
# File 'lib/zm/client/base/mailbox_object.rb', line 271

def local_transport!
  update!(zimbraMailTransport: local_transport)
end

#logged?Boolean

################################################################# Authentication #################################################################

Returns:

  • (Boolean)


81
82
83
# File 'lib/zm/client/base/mailbox_object.rb', line 81

def logged?
  !@token.nil?
end

#loginObject



92
93
94
95
96
97
98
# File 'lib/zm/client/base/mailbox_object.rb', line 92

def 
  if parent_logged?
    
  else
    
  end
end

#mailbox_infosObject



70
71
72
73
74
75
# File 'lib/zm/client/base/mailbox_object.rb', line 70

def mailbox_infos
  soap_request = SoapElement.admin(SoapAdminConstants::GET_MAILBOX_REQUEST)
  node_mbox = SoapElement.create(SoapConstants::MBOX).add_attribute(SoapConstants::ID, @id)
  soap_request.add_node(node_mbox)
  sac.invoke(soap_request)[:GetMailboxResponse][:mbox].first
end

#mbxidObject



62
63
64
# File 'lib/zm/client/base/mailbox_object.rb', line 62

def mbxid
  @mbxid || mbxid!
end

#mbxid!Object



66
67
68
# File 'lib/zm/client/base/mailbox_object.rb', line 66

def mbxid!
  @mbxid = mailbox_infos[:mbxid]
end

#membershipsObject



210
211
212
# File 'lib/zm/client/base/mailbox_object.rb', line 210

def memberships
  @memberships ||= AccountDlsMembershipCollection.new(self)
end

#messagesObject



157
158
159
# File 'lib/zm/client/base/mailbox_object.rb', line 157

def messages
  @messages ||= MessagesCollection.new(self)
end

#mountpointsObject



165
166
167
# File 'lib/zm/client/base/mailbox_object.rb', line 165

def mountpoints
  @mountpoints ||= MountPointsCollection.new(self)
end

#outgoing_filter_rulesObject



222
223
224
# File 'lib/zm/client/base/mailbox_object.rb', line 222

def outgoing_filter_rules
  @outgoing_filter_rules ||= OutgoingFilterRulesCollection.new(self)
end

#password!(new_password = nil) ⇒ Object

################################################################# SOAP Actions #################################################################



234
235
236
237
238
239
240
241
242
243
# File 'lib/zm/client/base/mailbox_object.rb', line 234

def password!(new_password = nil)
  new_password ||= @password
  return false if new_password.nil?

  soap_request = SoapElement.admin(SoapAdminConstants::SET_PASSWORD_REQUEST)
  soap_request.add_attributes({ id: @id, newPassword: new_password })
  sac.invoke(soap_request)

  @password = new_password
end

#prefsObject



50
51
52
# File 'lib/zm/client/base/mailbox_object.rb', line 50

def prefs
  @prefs ||= MailboxPrefsCollection.new(self)
end

#rename!(email) ⇒ Object



245
246
247
248
249
250
251
# File 'lib/zm/client/base/mailbox_object.rb', line 245

def rename!(email)
  soap_request = SoapElement.admin(SoapAdminConstants::RENAME_ACCOUNT_REQUEST)
  soap_request.add_attributes({ id: @id, newName: email })
  sac.invoke(soap_request)

  @name = email
end

#rest_account_connectorObject Also known as: rac



36
37
38
# File 'lib/zm/client/base/mailbox_object.rb', line 36

def 
  @rest_account_connector ||= RestAccountConnector.new
end

#search_foldersObject



169
170
171
# File 'lib/zm/client/base/mailbox_object.rb', line 169

def search_folders
  @search_folders ||= SearchFoldersCollection.new(self)
end

#sharesObject



177
178
179
# File 'lib/zm/client/base/mailbox_object.rb', line 177

def shares
  @shares ||= SharesCollection.new(self)
end

#signaturesObject



202
203
204
# File 'lib/zm/client/base/mailbox_object.rb', line 202

def signatures
  @signatures ||= SignaturesCollection.new(self)
end

#soap_account_connectorObject Also known as: sacc



31
32
33
# File 'lib/zm/client/base/mailbox_object.rb', line 31

def 
  @soap_account_connector ||= SoapAccountConnector.create(soap_config)
end

#tagsObject



189
190
191
# File 'lib/zm/client/base/mailbox_object.rb', line 189

def tags
  @tags ||= TagsCollection.new(self)
end

#tasksObject



193
194
195
# File 'lib/zm/client/base/mailbox_object.rb', line 193

def tasks
  @tasks ||= TasksCollection.new(self)
end

#token_metadataObject

################################################################# Associations #################################################################



153
154
155
# File 'lib/zm/client/base/mailbox_object.rb', line 153

def 
  @token_metadata ||= TokenMetaData.new(@token)
end

#update!(hash) ⇒ Object



253
254
255
256
257
258
259
260
261
262
263
# File 'lib/zm/client/base/mailbox_object.rb', line 253

def update!(hash)
  return false if hash.delete_if { |k, v| v.nil? || !respond_to?(k) }.empty?

  do_update!(hash)

  hash.each do |key, value|
    update_attribute(key, value)
  end

  true
end

#uploaderObject

#################################################################



293
294
295
# File 'lib/zm/client/base/mailbox_object.rb', line 293

def uploader
  @uploader ||= Upload.new(self)
end

#used!Object



58
59
60
# File 'lib/zm/client/base/mailbox_object.rb', line 58

def used!
  @used = mailbox_infos[:s]
end