Module: Teamlab::CrmFiles

Included in:
Crm
Defined in:
lib/teamlab/modules/crm/crm_files.rb

Overview

Methods for working with crm files

Instance Method Summary collapse

Instance Method Details

#associate_file_with_entity(entity_type, entity_id, *fileids) ⇒ Object



16
17
18
19
20
21
# File 'lib/teamlab/modules/crm/crm_files.rb', line 16

def associate_file_with_entity(entity_type, entity_id, *fileids)
  @request.post([entity_type,
                 entity_id,
                 'files'],
                fileids: fileids.flatten)
end

#create_txt(entity_type, entity_id, title, content) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/teamlab/modules/crm/crm_files.rb', line 23

def create_txt(entity_type, entity_id, title, content)
  @request.post([entity_type.to_s,
                 entity_id.to_s,
                 'files',
                 'text'],
                title: title,
                content: content)
end

#delete_file(id) ⇒ Object



40
41
42
# File 'lib/teamlab/modules/crm/crm_files.rb', line 40

def delete_file(id)
  @request.delete(['files', id.to_s])
end

#get_file_list(entity_type, entity_id) ⇒ Object



10
11
12
13
14
# File 'lib/teamlab/modules/crm/crm_files.rb', line 10

def get_file_list(entity_type, entity_id)
  @request.get([entity_type.to_s,
                entity_id.to_s,
                'files'])
end

#get_root_folder_idObject



6
7
8
# File 'lib/teamlab/modules/crm/crm_files.rb', line 6

def get_root_folder_id
  @request.get(%w[files root])
end

#upload_file(entity_type, entity_id, file) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/teamlab/modules/crm/crm_files.rb', line 32

def upload_file(entity_type, entity_id, file)
  @request.post([entity_type.to_s,
                 entity_id.to_s,
                 'files',
                 'upload'],
                somefile: File.new(file))
end