Class: Closeio::Rails::Lead

Inherits:
Base
  • Object
show all
Defined in:
app/models/closeio/rails/lead.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Attributes

#attributes

Instance Attribute Details

#contactsObject (readonly)

Returns the value of attribute contacts.



4
5
6
# File 'app/models/closeio/rails/lead.rb', line 4

def contacts
  @contacts
end

Class Method Details

.allObject



6
7
8
9
10
# File 'app/models/closeio/rails/lead.rb', line 6

def self.all
  Closeio::Rails.configuration.client.list_leads("*", paginate: true)[:data].collect do |lead|
    self.new(lead.to_hash)
  end
end

.create!(payload) ⇒ Object



22
23
24
# File 'app/models/closeio/rails/lead.rb', line 22

def self.create!(payload)
  Closeio::Rails.configuration.client.create_lead(payload)
end

.find(id) ⇒ Object



18
19
20
# File 'app/models/closeio/rails/lead.rb', line 18

def self.find(id)
  self.new(Closeio::Rails.configuration.client.find_lead(id))
end

.with_status(status) ⇒ Object



12
13
14
15
16
# File 'app/models/closeio/rails/lead.rb', line 12

def self.with_status(status)
  Closeio::Rails.configuration.client.list_leads("lead_status: #{status}", paginate: true)[:data].collect do |lead|
    self.new(lead.to_hash)
  end
end