module BitrixWebhook::CRM::LEAD
Public Class Methods
add(options = {})
click to toggle source
# File lib/bitrix_webhook/CRM/lead.rb, line 20 def self.add(options = {}) options = config.merge(options ) query_params = { fields: { TITLE: "#{options[:fname]} #{options[:lname]}", NAME: options[:fname], LAST_NAME: options[:lname], STATUS_ID: options[:status_id], ADDRESS_CITY: options[:address_city], ADDRESS_COUNTRY: options[:address_country], ADDRESS_REGION: options[:address_region], OPENED: options[:opened], ASSIGNED_BY_ID: options[:assigned_by_id], PHONE: { '0': { VALUE: options[:phone] } }, EMAIL: { '0': { VALUE: options[:email] } } }, params: { REGISTER_SONET_EVENT: options[:register_sonet_event] } }.to_query post_url = base_url('add').to_s + query_params begin JSON.parse(HTTP.post(post_url).body) rescue => e {error:e}.to_json end end
base_url(method)
click to toggle source
# 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()
click to toggle source
# 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
get(id)
click to toggle source
# File lib/bitrix_webhook/CRM/lead.rb, line 48 def self.get(id) query_params = { id: id }.to_query get_url = base_url('get').to_s + query_params begin JSON.parse(HTTP.get(get_url).body) rescue => e {error:e}.to_json end end
update_one_filed(id,filed,value)
click to toggle source
# File lib/bitrix_webhook/CRM/lead.rb, line 60 def self.update_one_filed(id,filed,value) query_params = { id: id, fields: { filed => value } }.to_query post_url = base_url('update').to_s + query_params begin JSON.parse(HTTP.post(post_url).body) rescue => e {error:e}.to_json end end