Class: Teamlab::Mail

Inherits:
Object
  • Object
show all
Defined in:
lib/teamlab/modules/mail.rb

Instance Method Summary collapse

Constructor Details

#initializeMail

Returns a new instance of Mail.



3
4
5
# File 'lib/teamlab/modules/mail.rb', line 3

def initialize
  @request = Teamlab::Request.new('mail')
end

Instance Method Details

#add_tag_to_conversations(tag_id, *conversation_ids) ⇒ Object



207
208
209
# File 'lib/teamlab/modules/mail.rb', line 207

def add_tag_to_conversations(tag_id, *conversation_ids)
  @request.put(['conversations', 'tag', tag_id.to_s, 'set'], messages: conversation_ids.flatten)
end

#add_trusted_address(address) ⇒ Object



247
248
249
# File 'lib/teamlab/modules/mail.rb', line 247

def add_trusted_address(address)
  @request.post(%w(display_messages addresses), addres: address)
end

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



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

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

#create_account_by_email(email, password) ⇒ Object



117
118
119
# File 'lib/teamlab/modules/mail.rb', line 117

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



109
110
111
# File 'lib/teamlab/modules/mail.rb', line 109

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



113
114
115
# File 'lib/teamlab/modules/mail.rb', line 113

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

#create_tag(name, options = {}) ⇒ Object



263
264
265
# File 'lib/teamlab/modules/mail.rb', line 263

def create_tag(name, options = {})
  @request.post(%w(tags), { name: name }.merge(options))
end

#delete_account(email) ⇒ Object



133
134
135
136
137
# File 'lib/teamlab/modules/mail.rb', line 133

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

#delete_alert_by_id(id) ⇒ Object



147
148
149
# File 'lib/teamlab/modules/mail.rb', line 147

def delete_alert_by_id(id)
  @request.delete(['alert', id.to_s])
end

#delete_attachment_from_message(message_id, attachment_id) ⇒ Object



73
74
75
# File 'lib/teamlab/modules/mail.rb', line 73

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

#delete_tag(id) ⇒ Object



279
280
281
# File 'lib/teamlab/modules/mail.rb', line 279

def delete_tag(id)
  @request.delete(['tags', id.to_s])
end

#export_all_message_attachments_to_my_docs(message_id) ⇒ Object



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

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



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

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



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

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

#generate_custom_guidObject

region GUID



235
236
237
# File 'lib/teamlab/modules/mail.rb', line 235

def generate_custom_guid
  @request.get(%w(random_guid))
end

#get_account_by_email(email) ⇒ Object



101
102
103
# File 'lib/teamlab/modules/mail.rb', line 101

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

#get_account_listObject

region Accounts



97
98
99
# File 'lib/teamlab/modules/mail.rb', line 97

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

#get_alerts_listObject

region Alerts



143
144
145
# File 'lib/teamlab/modules/mail.rb', line 143

def get_alerts_list
  @request.get('alert')
end

#get_contact_list_for_auto_complete(term) ⇒ Object

region Contacts



155
156
157
# File 'lib/teamlab/modules/mail.rb', line 155

def get_contact_list_for_auto_complete(term)
  @request.get(%w(contacts), term: term)
end

#get_crm_linked_entities(message_id) ⇒ Object



159
160
161
# File 'lib/teamlab/modules/mail.rb', line 159

def get_crm_linked_entities(message_id)
  @request.get(%w(crm linked entities), messageId: message_id)
end

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



105
106
107
# File 'lib/teamlab/modules/mail.rb', line 105

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

#get_filtered_conversations(options = {}) ⇒ Object

region Conversations



167
168
169
# File 'lib/teamlab/modules/mail.rb', line 167

def get_filtered_conversations(options = {})
  @request.get(%w(conversations), options)
end

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

region Messages



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

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

#get_folder_change_date(folder_id) ⇒ Object



223
224
225
# File 'lib/teamlab/modules/mail.rb', line 223

def get_folder_change_date(folder_id)
  @request.get(['folders', folder_id.to_s, 'modify_date'])
end

#get_folders(options = {}) ⇒ Object

region Folders



219
220
221
# File 'lib/teamlab/modules/mail.rb', line 219

def get_folders(options = {})
  @request.get(%w(folders), options)
end

#get_html_of_help_centerObject

region HelpCenter



81
82
83
# File 'lib/teamlab/modules/mail.rb', line 81

def get_html_of_help_center
  @request.get(%w(helpcenter))
end

#get_meail_signature(mailbox_id) ⇒ Object

endregion



87
88
89
# File 'lib/teamlab/modules/mail.rb', line 87

def get_meail_signature(mailbox_id)
  @request.get(['signature', mailbox_id.to_s])
end

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



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

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

#get_message_modify_dateObject



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

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

#get_message_templateObject



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

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

#get_messages_linked_into_one_chain(message_id, load_all_content) ⇒ Object



171
172
173
# File 'lib/teamlab/modules/mail.rb', line 171

def get_messages_linked_into_one_chain(message_id, load_all_content)
  @request.get(['conversation', message_id.to_s], loadAllContent: load_all_content)
end

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



175
176
177
# File 'lib/teamlab/modules/mail.rb', line 175

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

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



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

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

#get_tag_listObject

region Tags



259
260
261
# File 'lib/teamlab/modules/mail.rb', line 259

def get_tag_list
  @request.get(%w(tags))
end

#get_trusted_addressesObject

region IMAGES



243
244
245
# File 'lib/teamlab/modules/mail.rb', line 243

def get_trusted_addresses
  @request.get(%w(display_messages addresses))
end

#is_chain_crm_linked_by_message(message_id) ⇒ Object



179
180
181
# File 'lib/teamlab/modules/mail.rb', line 179

def is_chain_crm_linked_by_message(message_id)
  @request.get(%w(conversations link crm status), messageId: message_id)
end

#mark_conversation_as_crm_linked(message_id, *crm_contact_ids) ⇒ Object



199
200
201
# File 'lib/teamlab/modules/mail.rb', line 199

def mark_conversation_as_crm_linked(message_id, *crm_contact_ids)
  @request.put(%w(conversations crm mark), messageId: message_id, crmContactIds: crm_contact_ids.flatten)
end

#move_conversations_to_folder(folder_id, *message_ids) ⇒ Object



183
184
185
# File 'lib/teamlab/modules/mail.rb', line 183

def move_conversations_to_folder(folder_id, *message_ids)
  @request.put(%w(conversations move), folderId: folder_id, ids: message_ids.flatten)
end

#move_messages_to_folder(folder_id, *message_ids) ⇒ Object



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

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

#remove_all_messages_from_folder(folder_id) ⇒ Object



227
228
229
# File 'lib/teamlab/modules/mail.rb', line 227

def remove_all_messages_from_folder(folder_id)
  @request.get(['folders', folder_id.to_s, 'messages'])
end

#remove_conversations(*ids) ⇒ Object



191
192
193
# File 'lib/teamlab/modules/mail.rb', line 191

def remove_conversations(*ids)
  @request.put(%w(conversations remove), ids: ids.flatten)
end

#remove_from_trusted_addresses(address) ⇒ Object



251
252
253
# File 'lib/teamlab/modules/mail.rb', line 251

def remove_from_trusted_addresses(address)
  @request.delete(%w(display_messages addresses), addres: address)
end

#remove_messages(*ids) ⇒ Object



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

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

#remove_tag_from_conversations(tag_id, *conversation_ids) ⇒ Object



211
212
213
# File 'lib/teamlab/modules/mail.rb', line 211

def remove_tag_from_conversations(tag_id, *conversation_ids)
  @request.put(['conversations', 'tag', tag_id.to_s, 'unset'], messages: conversation_ids.flatten)
end

#remove_tag_from_messages(id, *message_ids) ⇒ Object



275
276
277
# File 'lib/teamlab/modules/mail.rb', line 275

def remove_tag_from_messages(id, *message_ids)
  @request.put(['tags', id.to_s, 'remove'], messages: message_ids.flatten)
end

#restore_conversations_to_folders(*ids) ⇒ Object



195
196
197
# File 'lib/teamlab/modules/mail.rb', line 195

def restore_conversations_to_folders(*ids)
  @request.put(%w(conversations restore), ids: ids.flatten)
end

#restore_message_to_foldersObject



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

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

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



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

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

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



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

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

#set_account_state(email, state) ⇒ Object



125
126
127
# File 'lib/teamlab/modules/mail.rb', line 125

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

#set_account_state_by_mailbox(mailbox_id, email_in_folder) ⇒ Object



129
130
131
# File 'lib/teamlab/modules/mail.rb', line 129

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

#set_conversations_status(status, *ids) ⇒ Object



187
188
189
# File 'lib/teamlab/modules/mail.rb', line 187

def set_conversations_status(status, *ids)
  @request.put(%w(conversations mark), status: status, ids: ids.flatten)
end

#set_message_crm_status(emails, *user_ids) ⇒ Object



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

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



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

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

#set_tag_to_messages(id, *message_ids) ⇒ Object



271
272
273
# File 'lib/teamlab/modules/mail.rb', line 271

def set_tag_to_messages(id, *message_ids)
  @request.put(['tags', id.to_s, 'set'], messages: message_ids.flatten)
end


203
204
205
# File 'lib/teamlab/modules/mail.rb', line 203

def unmark_conversation_link_with_crm(message_id, *crm_contact_ids)
  @request.put(%w(conversations crm unmark), messageId: message_id, crmContactIds: crm_contact_ids.flatten)
end

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



121
122
123
# File 'lib/teamlab/modules/mail.rb', line 121

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

#update_signature(mailbox_id, html, options = {}) ⇒ Object



91
92
93
# File 'lib/teamlab/modules/mail.rb', line 91

def update_signature(mailbox_id, html, options = {})
  @request.post(['signature', 'update', mailbox_id.to_s], { html: html }.merge(options))
end

#update_tag(id, name, options = {}) ⇒ Object



267
268
269
# File 'lib/teamlab/modules/mail.rb', line 267

def update_tag(id, name, options = {})
  @request.put(['tags', id.to_s], { name: name }.merge(options))
end