Class: SfIntegrator::Lead

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/sf_integrator/lead.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Lead

Returns a new instance of Lead.



11
12
13
14
15
16
17
18
19
# File 'lib/sf_integrator/lead.rb', line 11

def initialize(args)
  @first_name = args[:first_name]
  @last_name  = args[:last_name]
  @email      = args[:email]
  @company    = args[:company]
  @job_title  = args[:job_title]
  @phone      = args[:phone]
  @website    = args[:website]
end

Instance Attribute Details

#companyObject

Returns the value of attribute company.



9
10
11
# File 'lib/sf_integrator/lead.rb', line 9

def company
  @company
end

#emailObject

Returns the value of attribute email.



9
10
11
# File 'lib/sf_integrator/lead.rb', line 9

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



9
10
11
# File 'lib/sf_integrator/lead.rb', line 9

def first_name
  @first_name
end

#job_titleObject

Returns the value of attribute job_title.



9
10
11
# File 'lib/sf_integrator/lead.rb', line 9

def job_title
  @job_title
end

#last_nameObject

Returns the value of attribute last_name.



9
10
11
# File 'lib/sf_integrator/lead.rb', line 9

def last_name
  @last_name
end

#phoneObject

Returns the value of attribute phone.



9
10
11
# File 'lib/sf_integrator/lead.rb', line 9

def phone
  @phone
end

#websiteObject

Returns the value of attribute website.



9
10
11
# File 'lib/sf_integrator/lead.rb', line 9

def website
  @website
end

Class Method Details

.allObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/sf_integrator/lead.rb', line 29

def self.all
  records = client.query('select FirstName, LastName, Email, Company, Title, Phone, Website from Lead')
  records.map do |record|
    attributes = {
      first_name: record.FirstName, last_name: record.LastName, email: record.Email,
      company: record.Company, job_title: record.Title, phone: record.Phone, website: record.Website
    }
    Lead.new(attributes)
  end
end

Instance Method Details

#createObject



21
22
23
24
25
26
27
# File 'lib/sf_integrator/lead.rb', line 21

def create
  params = {
    FirstName: first_name, LastName: last_name, Email: email,
    Company: company, Title: job_title, Phone: phone, Website: website
  }
  self.class.client.create('Lead', params)
end