Module: BitrixWebhook::CRM::LEAD
- Defined in:
- lib/bitrix_webhook/CRM/lead.rb
Class Method Summary collapse
- .add(options = {}) ⇒ Object
- .base_url(method) ⇒ Object
- .config ⇒ Object
- .update_one_filed(id, filed, value) ⇒ Object
Class Method Details
.add(options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bitrix_webhook/CRM/lead.rb', line 20 def self.add( = {}) = config.merge( ) post_url = base_url("add").to_s + "fields%5BTITLE%5D=#{[:fname].to_s + '+' + [:lname].to_s}&" + "fields%5BNAME%5D=#{[:fname]}&" + "fields%5BLAST_NAME%5D=#{[:lname]}&" + "fields%5BSTATUS_ID%5D=#{[:status_id]}&" + "fields%5BOPENED%5D=#{[:opened]}&" + "fields%5BASSIGNED_BY_ID%5D=#{[:assigned_by_id]}&" + "fields%5BPHONE%5D%5B0%5D%5BVALUE%5D=#{[:phone]}&" + "fields%5BEMAIL%5D%5B0%5D%5BVALUE%5D=#{[:email]}&" + "params%5BREGISTER_SONET_EVENT%5D=#{[:register_sonet_event]}" begin JSON.parse(HTTP.post(post_url).body) rescue => e {error:e}.to_json end end |
.base_url(method) ⇒ Object
16 17 18 |
# File 'lib/bitrix_webhook/CRM/lead.rb', line 16 def self.base_url(method) "https://#{BitrixWebhook.bitrix24_url}/rest/#{BitrixWebhook.webhook_user}/#{ BitrixWebhook.hook}/crm.lead.#{method}?" end |
.config ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/bitrix_webhook/CRM/lead.rb', line 5 def self.config { fname: '', lname: '', status_id: 'NEW', opened: 'Y', assigned_by_id: BitrixWebhook.webhook_user, register_sonet_event: 'Y', } end |
.update_one_filed(id, filed, value) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/bitrix_webhook/CRM/lead.rb', line 40 def self.update_one_filed(id,filed,value) post_url = base_url("update").to_s + "id=#{id}&fields%5B#{filed}%5D=#{value}" begin JSON.parse(HTTP.post(post_url).body) rescue => e {error:e}.to_json end end |