Module: Teamlab::MailAccounts

Included in:
Mail
Defined in:
lib/teamlab/modules/mail/mail_accounts.rb

Overview

Methods for working with mail accounts

Instance Method Summary collapse

Instance Method Details

#create_account_by_email(email, password) ⇒ Object



26
27
28
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 26

def (email, password)
  @request.post(%w[accounts simple], email: email, password: password)
end

#create_account_with_custom_mail_service(name, email, account, password, options = {}) ⇒ Object



18
19
20
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 18

def (name, email, , password, options = {})
  @request.post(%w[accounts], { name: name, email: email, account: , password: password }.merge(options))
end

#create_oauth_account(email, token, options = {}) ⇒ Object



22
23
24
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 22

def (email, token, options = {})
  @request.post(%w[accounts oauth], { email: email, token: token }.merge(options))
end

#delete_account(email) ⇒ Object



49
50
51
52
53
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 49

def (email)
  @request.delete(['accounts', email.to_s])
rescue StandardError
  @request.delete(['accounts'], email: email.to_s) # for version 8.7
end

#get_account_by_email(email) ⇒ Object



10
11
12
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 10

def (email)
  @request.get(['accounts', email.to_s])
end

#get_account_listObject



6
7
8
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 6

def 
  @request.get(%w[accounts])
end

#get_default_account_settings(email, options = {}) ⇒ Object



14
15
16
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 14

def (email, options = {})
  @request.get(['accounts', email.to_s, 'default'], options)
end

#set_account_state(email, state) ⇒ Object



34
35
36
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 34

def (email, state)
  @request.put(['accounts', email.to_s, 'state'], state: state)
end

#set_account_state_by_mailbox(mailbox_id, email_in_folder) ⇒ Object



38
39
40
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 38

def (mailbox_id, email_in_folder)
  @request.put(['accounts', mailbox_id.to_s, 'emailinfolder'], emailInFolder: email_in_folder)
end

#set_default_account(email, is_default) ⇒ Object

Sets the default account specified in the request

Parameters:

  • email (String)

    email of account

  • is_default (Boolean)

    Set or reset account as default



45
46
47
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 45

def (email, is_default)
  @request.put(%w[accounts default], email: email, isDefault: is_default)
end

#update_account(name, email, password, options = {}) ⇒ Object



30
31
32
# File 'lib/teamlab/modules/mail/mail_accounts.rb', line 30

def (name, email, password, options = {})
  @request.put(%w[accounts], { name: name, email: email, password: password }.merge(options))
end