Module: Teamlab::CrmContacts

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

Overview

Methods for working with crm contacts methods

Instance Method Summary collapse

Instance Method Details

#add_address_info(contact_id, address = {}) ⇒ Hash

Adds the address information to the contact with the selected ID

Parameters:

  • contact_id (String)

    Contact ID

  • address (Hash) (defaults to: {})

    Contact address parameters: street, city, state, zip, country, isPrimary

Returns:

  • (Hash)

    Contact information



261
262
263
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 261

def add_address_info(contact_id, address = {})
  @request.post(['contact', contact_id.to_s, 'addressdata'], { address: address })
end

#add_contact_info(contact_id, infotype, data, category, options = {}) ⇒ Object



161
162
163
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 161

def add_contact_info(contact_id, infotype, data, category, options = {})
  @request.post(['contact', contact_id.to_s, 'data'], { infoType: infotype, data: data, category: category }.merge(options))
end

#add_contact_opportunity(contact_id, opportunity_id) ⇒ Object



177
178
179
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 177

def add_contact_opportunity(contact_id, opportunity_id)
  @request.post(['contact', contact_id.to_s, 'opportunity', opportunity_id.to_s])
end

#add_persons_to_company(company_id, person_id) ⇒ Object



169
170
171
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 169

def add_persons_to_company(company_id, person_id)
  @request.post(['contact', 'company', company_id.to_s, 'person'], personId: person_id)
end

#add_tag_to_batch_contacts(tags, options = {}) ⇒ Object



46
47
48
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 46

def add_tag_to_batch_contacts(tags, options = {})
  @request.post(%w[contact filter taglist], { tags: tags }.merge(options))
end

#change_contact_photo(contact_id, photo) ⇒ Object



86
87
88
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 86

def change_contact_photo(contact_id, photo)
  @request.put(['contact', contact_id.to_s, 'changephoto'], photo: File.new(photo))
end

#change_contact_photo_by_url(contact_id, photo_url) ⇒ Object



233
234
235
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 233

def change_contact_photo_by_url(contact_id, photo_url)
  @request.put(['contact', contact_id.to_s, 'changephotobyurl'], photourl: photo_url)
end

#create_company(company_name, managers, options = {}) ⇒ Object



38
39
40
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 38

def create_company(company_name, managers, options = {})
  @request.post(%w[contact company], { companyName: company_name, managerList: managers }.merge(options))
end

#create_contact_status(title, color, options = {}) ⇒ Object



30
31
32
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 30

def create_contact_status(title, color, options = {})
  @request.post(%w[contact status], { title: title, color: color }.merge(options))
end

#create_contact_type(title, options = {}) ⇒ Object



26
27
28
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 26

def create_contact_type(title, options = {})
  @request.post(%w[contact type], { title: title }.merge(options))
end

#create_person(first_name, last_name, options = {}) ⇒ Object



34
35
36
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 34

def create_person(first_name, last_name, options = {})
  @request.post(%w[contact person], { firstName: first_name, lastName: last_name }.merge(options))
end

#create_task_group(title, options = {}) ⇒ Object



42
43
44
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 42

def create_task_group(title, options = {})
  @request.post(%w[contact task group], { title: title }.merge(options))
end

#delete_batch_contacts_by_filter(options = {}) ⇒ Object



98
99
100
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 98

def delete_batch_contacts_by_filter(options = {})
  @request.delete(%w[contact filter], options)
end

#delete_contact(id) ⇒ Object



237
238
239
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 237

def delete_contact(id)
  @request.delete(['contact', id.to_s])
end

#delete_contact_group(*contact_ids) ⇒ Object Also known as: delete_contacts_bulk



181
182
183
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 181

def delete_contact_group(*contact_ids)
  @request.put(%w[contact], contactids: contact_ids.flatten)
end

#delete_contact_info(contact_id, info_id) ⇒ Object



245
246
247
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 245

def delete_contact_info(contact_id, info_id)
  @request.delete(['contact', contact_id.to_s, 'data', info_id.to_s])
end

#delete_contact_status(contact_status_id) ⇒ Object



102
103
104
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 102

def delete_contact_status(contact_status_id)
  @request.delete(['contact', 'status', contact_status_id])
end

#delete_contact_type(contact_type_id) ⇒ Object



241
242
243
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 241

def delete_contact_type(contact_type_id)
  @request.delete(['contact', 'type', contact_type_id.to_s])
end

#delete_deal_from_contact(contact_id, opportunity_id) ⇒ Object



106
107
108
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 106

def delete_deal_from_contact(contact_id, opportunity_id)
  @request.delete(['contact', contact_id.to_s, 'opportunity', opportunity_id.to_s])
end

#delete_person_from_company(company_id, person_id) ⇒ Object



249
250
251
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 249

def delete_person_from_company(company_id, person_id)
  @request.delete(['contact', 'company', company_id.to_s, 'person'], personId: person_id)
end

#get_all_categories(info_type) ⇒ Object



134
135
136
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 134

def get_all_categories(info_type)
  @request.get(['contact', 'data', info_type.to_s, 'category'])
end

#get_all_contact_info_typesObject



118
119
120
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 118

def get_all_contact_info_types
  @request.get(%w[contact data infotype])
end

#get_all_contact_typesObject



110
111
112
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 110

def get_all_contact_types
  @request.get(%w[contact type])
end

#get_company_linked_persons_list(company_id) ⇒ Object



138
139
140
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 138

def get_company_linked_persons_list(company_id)
  @request.get(['contact', 'company', company_id.to_s, 'person'])
end

#get_contact_access_rights(contact_id) ⇒ Array

Returns access rights to the contact with the ID specified in the request

Parameters:

  • contact_id (String)

    Contact ID

Returns:

  • (Array)

    List of contacts



205
206
207
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 205

def get_contact_access_rights(contact_id)
  @request.get(['contact', contact_id.to_s, 'access'])
end

#get_contact_by_id(id) ⇒ Object



114
115
116
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 114

def get_contact_by_id(id)
  @request.get(['contact', id.to_s])
end

#get_contact_info(contact_id, contact_info_id) ⇒ Object



130
131
132
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 130

def get_contact_info(contact_id, contact_info_id)
  @request.get(['contact', contact_id.to_s, 'data', contact_info_id.to_s])
end

#get_contact_information(contact_id) ⇒ Hash

Returns the detailed information about the contacts Email, Phone, Web Site/Social Networks and Address information with the ID

Parameters:

  • contact_id (String)

    Contact ID

Returns:

  • (Hash)

    Contact information



145
146
147
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 145

def get_contact_information(contact_id)
  @request.get(['contact', contact_id.to_s, 'data'])
end

#get_contact_information_by_type(contact_id, info_type) ⇒ Object



149
150
151
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 149

def get_contact_information_by_type(contact_id, info_type)
  @request.get(['contact', contact_id.to_s, 'data', info_type.to_s])
end

#get_contact_status_by_id(contact_status_id) ⇒ Object



22
23
24
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 22

def get_contact_status_by_id(contact_status_id)
  @request.get(['contact', 'status', contact_status_id.to_s])
end

#get_contact_statusesObject



10
11
12
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 10

def get_contact_statuses
  @request.get(%w[contact status])
end

#get_contact_type(id) ⇒ Object



126
127
128
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 126

def get_contact_type(id)
  @request.get(['contact', 'type', id.to_s])
end

#get_contacts_by_filter(options = {}) ⇒ Object



14
15
16
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 14

def get_contacts_by_filter(options = {})
  @request.get(%w[contact filter], options)
end

#get_contacts_by_project_id(id) ⇒ Object



122
123
124
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 122

def get_contacts_by_project_id(id)
  @request.get(['contact', 'project', id.to_s])
end

#get_contacts_for_mail(*contact_ids) ⇒ Object



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

def get_contacts_for_mail(*contact_ids)
  @request.get(%w[contact mail], contactids: contact_ids.flatten)
end

#get_simple_contacts(options = {}) ⇒ Object



18
19
20
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 18

def get_simple_contacts(options = {})
  @request.get(%w[contact simple filter], options)
end


165
166
167
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 165

def link_contact_list_with_project(project_id, *contact_ids)
  @request.post(['contact', 'project', project_id.to_s], contactId: contact_ids.flatten)
end


173
174
175
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 173

def link_contact_with_project(contact_id, project_id)
  @request.post(['contact', contact_id.to_s, 'project', project_id.to_s])
end

#merge_contacts(from_contact_id, to_contact_id) ⇒ Object



186
187
188
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 186

def merge_contacts(from_contact_id, to_contact_id)
  @request.put(%w[contact merge], fromcontactid: from_contact_id, tocontactid: to_contact_id)
end

#quick_company_list_creation(*names) ⇒ Object



157
158
159
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 157

def quick_company_list_creation(*names)
  @request.post(%w[contact company quick], companyName: names.flatten)
end

#quick_person_list_creation(data) ⇒ Object



153
154
155
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 153

def quick_person_list_creation(data)
  @request.post(%w[contact person quick], data: data)
end

#remove_contact_from_project(contact_id, project_id) ⇒ Object



253
254
255
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 253

def remove_contact_from_project(contact_id, project_id)
  @request.delete(['contact', contact_id.to_s, 'project', project_id.to_s])
end

#set_access_to_batch_contact(options = {}) ⇒ Object



62
63
64
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 62

def set_access_to_batch_contact(options = {})
  @request.put(%w[contact filter access], options)
end

#set_contact_access_rights(contact_id, options = {}) ⇒ Object



198
199
200
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 198

def set_contact_access_rights(contact_id, options = {})
  @request.put(['contact', contact_id.to_s, 'access'], options)
end

#set_contacts_access_rights(contact_ids, options = {}) ⇒ Object



190
191
192
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 190

def set_contacts_access_rights(contact_ids, options = {})
  @request.put(%w[contact access], { contactId: contact_ids }.merge(options))
end

#update_address_info(contact_id, info_id, address = {}) ⇒ Hash

Updates the address information with the parameters specified in the request for the contact with the selected ID

Parameters:

  • contact_id (String)

    Contact ID

  • info_id (String)

    Contact information record ID

  • address (Hash) (defaults to: {})

    Contact address parameters: street, city, state, zip, country, isPrimary

Returns:

  • (Hash)

    Contact information



270
271
272
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 270

def update_address_info(contact_id, info_id, address = {})
  @request.put(['contact', contact_id.to_s, 'addressdata', info_id.to_s], { address: address })
end

#update_company(company_id, company_name, options = {}) ⇒ Object



209
210
211
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 209

def update_company(company_id, company_name, options = {})
  @request.put(['contact', 'company', company_id.to_s], { companyName: company_name.to_s }.merge(options))
end

#update_company_and_participants_status(company_id, contact_status_id) ⇒ Object



94
95
96
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 94

def update_company_and_participants_status(company_id, contact_status_id)
  @request.put(['contact', 'company', company_id.to_s, 'status'], contactStatusId: contact_status_id)
end

#update_contact_info(information_id, contact_id, data, options = {}) ⇒ Object



229
230
231
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 229

def update_contact_info(information_id, contact_id, data, options = {})
  @request.put(['contact', contact_id.to_s, 'data', information_id.to_s], { data: data }.merge(options))
end

#update_contact_status(id, title, options = {}) ⇒ Object



54
55
56
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 54

def update_contact_status(id, title, options = {})
  @request.put(['contact', 'status', id.to_s], { title: title.to_s }.merge(options))
end

#update_contact_status_by_id(contact_id, contact_status_id) ⇒ Object



82
83
84
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 82

def update_contact_status_by_id(contact_id, contact_status_id)
  @request.put(['contact', contact_id, 'status'], contactStatusid: contact_status_id)
end

#update_contact_status_color(status_id, color) ⇒ Object



74
75
76
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 74

def update_contact_status_color(status_id, color)
  @request.put(['contact', 'status', status_id.to_s, 'color'], color: color)
end

#update_contact_type(id, title, options = {}) ⇒ Object



50
51
52
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 50

def update_contact_type(id, title, options = {})
  @request.put(['contact', 'type', id.to_s], { title: title }.merge(options))
end

#update_contact_types_order(*titles) ⇒ Object



194
195
196
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 194

def update_contact_types_order(*titles)
  @request.put(%w[contact type reorder], titles: titles.flatten)
end

#update_crm_contact_status_settings(options = {}) ⇒ Object



70
71
72
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 70

def update_crm_contact_status_settings(options = {})
  @request.put(%w[contact status settings], options)
end

#update_crm_contact_tag_setting(options = {}) ⇒ Object



58
59
60
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 58

def update_crm_contact_tag_setting(options = {})
  @request.put(%w[contact tag settings], options)
end

#update_crm_entity_creation_date(entity_name, entity_id, date = '2007-01-01') ⇒ Object



213
214
215
216
217
218
219
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 213

def update_crm_entity_creation_date(entity_name, entity_id, date = '2007-01-01')
  id_field = "#{entity_name}id".to_sym
  options = {}
  options[id_field] = entity_id.to_s
  options[:creationDate] = date.to_s
  @request.put([entity_name.to_s, entity_id.to_s, 'creationdate'], options)
end

#update_crm_entity_modification_date(entity_name, entity_id, date = '2007-01-01') ⇒ Object



221
222
223
224
225
226
227
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 221

def update_crm_entity_modification_date(entity_name, entity_id, date = '2007-01-01')
  id_field = "#{entity_name}id".to_sym
  options = {}
  options[id_field] = entity_id.to_s
  options[:lastModifedDate] = date.to_s
  @request.put([entity_name.to_s, entity_id.to_s, 'lastmodifeddate'], options)
end

#update_person(id, first_name, last_name, options = {}) ⇒ Object



78
79
80
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 78

def update_person(id, first_name, last_name, options = {})
  @request.put(['contact', 'person', id.to_s], { firstName: first_name, lastName: last_name }.merge(options))
end

#update_person_and_its_company_status(person_id, contact_status_id) ⇒ Object



90
91
92
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 90

def update_person_and_its_company_status(person_id, contact_status_id)
  @request.put(['contact', 'person', person_id.to_s, 'status'], contactStatusId: contact_status_id)
end

#update_statuses_contact_order(options = {}) ⇒ Object



66
67
68
# File 'lib/teamlab/modules/crm/crm_contacts.rb', line 66

def update_statuses_contact_order(options = {})
  @request.put(%w[contact status reorder], options)
end