Class: Hcp::Lead
Overview
Somebody who asked a Housecall Pro user for work, before there is a job.
Defined Under Namespace
Classes: Pipeline
Instance Attribute Summary collapse
-
#customer_id ⇒ Object
readonly
Returns the value of attribute customer_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#create(params = {}) ⇒ Object
Opens the lead on Housecall Pro, and keeps what it filed the lead and customer under.
-
#initialize(id: nil, customer_id: nil, key:, company_id:) ⇒ Lead
constructor
A new instance of Lead.
Constructor Details
#initialize(id: nil, customer_id: nil, key:, company_id:) ⇒ Lead
Returns a new instance of Lead.
8 9 10 11 12 13 |
# File 'lib/hcp/lead.rb', line 8 def initialize(id: nil, customer_id: nil, key:, company_id:) @id = id @key = key @company_id = company_id @customer_id = customer_id end |
Instance Attribute Details
#customer_id ⇒ Object (readonly)
Returns the value of attribute customer_id.
6 7 8 |
# File 'lib/hcp/lead.rb', line 6 def customer_id @customer_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/hcp/lead.rb', line 6 def id @id end |
Instance Method Details
#create(params = {}) ⇒ Object
Opens the lead on Housecall Pro, and keeps what it filed the lead and customer under.
17 18 19 20 21 22 23 24 |
# File 'lib/hcp/lead.rb', line 17 def create(params = {}) response = Net::HTTP.post uri, lead_for(params).to_json, headers raise Error, response.body unless response.is_a? Net::HTTPSuccess body = JSON response.body @id, @customer_id = body['id'], body.dig('customer', 'id') rescue Errno::ECONNREFUSED => error raise Error, error end |