Class: SalesforceIntegration::SalesforceIntegrationLead
- Inherits:
-
Object
- Object
- SalesforceIntegration::SalesforceIntegrationLead
- Defined in:
- lib/salesforceintegration.rb
Instance Method Summary collapse
-
#create_lead_on_salesforce(fields) ⇒ Object
TODO: Permitir associar a contas.
-
#initialize(options) ⇒ SalesforceIntegrationLead
constructor
A new instance of SalesforceIntegrationLead.
Constructor Details
#initialize(options) ⇒ SalesforceIntegrationLead
9 10 11 12 13 14 15 16 17 |
# File 'lib/salesforceintegration.rb', line 9 def initialize() raise "It's necessary to inform client_id, client_secret, url, username and password!" unless .has_key?(:client_id) and .has_key?(:client_secret) and .has_key?(:url) and .has_key?(:username) and .has_key?(:password) client = Databasedotcom::Client.new(:client_id => [:client_id], :client_secret => [:client_secret], :host => [:url]) client.authenticate(:username => [:username], :password => [:password]) client.materialize("Lead") client.materialize("User") end |
Instance Method Details
#create_lead_on_salesforce(fields) ⇒ Object
TODO: Permitir associar a contas
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/salesforceintegration.rb', line 20 def create_lead_on_salesforce(fields) raise "The fields last_name and company are required" unless fields.has_key?(:last_name) and fields.has_key?(:company) raise "The fields last_name and company cannot be blank" if fields[:last_name].blank? or fields[:company].blank? lead = Lead.new #TODO: Nao esta claro ao que corresponde esse usuario no salesforce. Verificar user = User.first lead['OwnerId'] = user.Id lead['FirstName'] = fields[:first_name] lead['LastName'] = fields[:last_name] lead['Email'] = fields[:email] lead['Company'] = fields[:company] lead['Title'] = fields[:job_title] lead['Phone'] = fields[:phone] lead['Website'] = fields[:website] lead['IsConverted'] = false lead['IsUnreadByOwner'] = true lead.save lead.Id end |