Module: Teamlab::MailMessages

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

Overview

Methods for working with mail messages

Instance Method Summary collapse

Instance Method Details

#attach_teamlab_document(message_id, file_id, options = {}) ⇒ Object



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

def attach_teamlab_document(message_id, file_id, options = {})
  @request.post(['messages', message_id.to_s, 'document'], { fileId: file_id }.merge(options))
end

#delete_attachment_from_message(message_id, attachment_id) ⇒ Object



70
71
72
# File 'lib/teamlab/modules/mail/mail_messages.rb', line 70

def delete_attachment_from_message(message_id, attachment_id)
  @request.delete(['messages', message_id.to_s, 'attachments', attachment_id.to_s])
end

#export_all_message_attachments_to_my_docs(message_id) ⇒ Object



66
67
68
# File 'lib/teamlab/modules/mail/mail_messages.rb', line 66

def export_all_message_attachments_to_my_docs(message_id)
  @request.put(%w[attachments mydocuments export], messageId: message_id)
end

#export_attachments_to_my_docs(attachment_id) ⇒ Object



62
63
64
# File 'lib/teamlab/modules/mail/mail_messages.rb', line 62

def export_attachments_to_my_docs(attachment_id)
  @request.put(%w[attachment mydocuments export], attachmentId: attachment_id)
end

#export_mail_to_crm_relations_history(message_id, *crm_contact_ids) ⇒ Object



58
59
60
# File 'lib/teamlab/modules/mail/mail_messages.rb', line 58

def export_mail_to_crm_relations_history(message_id, *crm_contact_ids)
  @request.put(%w[messages crm export], messageId: message_id, crmContactIds: crm_contact_ids.flatten)
end

#get_filtered_messages(page, options = {}) ⇒ Object



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

def get_filtered_messages(page, options = {})
  @request.get(%w[messages], { page: page }.merge(options))
end

#get_message(id, options = {}) ⇒ Object



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

def get_message(id, options = {})
  @request.get(['messages', id.to_s], options)
end

#get_message_modify_dateObject



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

def get_message_modify_date
  @request.get(%w[messages modify_date])
end

#get_message_templateObject



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

def get_message_template
  @request.get(%w[messages template])
end

#get_previous_or_next_message_id(id, direction, options = {}) ⇒ Object



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

def get_previous_or_next_message_id(id, direction, options = {})
  @request.get(['messages', id.to_s, direction.to_s], options)
end

#move_messages_to_folder(folder_id, *message_ids) ⇒ Object



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

def move_messages_to_folder(folder_id, *message_ids)
  @request.put(%w[,essages move], folderId: folder_id, ids: message_ids.flatten)
end

#remove_messages(*ids) ⇒ Object



50
51
52
# File 'lib/teamlab/modules/mail/mail_messages.rb', line 50

def remove_messages(*ids)
  @request.put(%w[messages remove], ids: ids.flatten)
end

#restore_message_to_foldersObject



54
55
56
# File 'lib/teamlab/modules/mail/mail_messages.rb', line 54

def restore_message_to_folders
  @request.put(%w[messages restore])
end

#save_message(id, options = {}) ⇒ Object



46
47
48
# File 'lib/teamlab/modules/mail/mail_messages.rb', line 46

def save_message(id, options = {})
  @request.put(%w[messages save], { id: id }.merge(options))
end

#send_message(id, options = {}) ⇒ Object



42
43
44
# File 'lib/teamlab/modules/mail/mail_messages.rb', line 42

def send_message(id, options = {})
  @request.put(%w[messages send], { id: id }.merge(options))
end

#set_message_crm_status(emails, *user_ids) ⇒ Object



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

def set_message_crm_status(emails, *user_ids)
  @request.post(%w[messages update_crm], emails: emails, userIds: user_ids.flatten)
end

#set_message_status(status, *ids) ⇒ Object



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

def set_message_status(status, *ids)
  @request.put(%w[messages mark], status: status, ids: ids.flatten)
end