Class: Hcp::Event
- Inherits:
-
Object
- Object
- Hcp::Event
- Defined in:
- lib/hcp/event.rb
Constant Summary collapse
- SIGNATURE_HEADER =
'Api-Signature'- TIMESTAMP_HEADER =
'Api-Timestamp'
Instance Method Summary collapse
-
#completed_at ⇒ Time
Time when the job was completed a :job_completed event.
-
#conversion_id ⇒ String
The latest conversion ID, can be an estimate ID or a job ID.
-
#conversion_type ⇒ Symbol
The latest conversion type, can be :estimate or :job.
-
#customer_id ⇒ String
Unique identifier of the customer in a :lead_converted or :job_created event.
-
#estimate_id ⇒ String
Unique identifier of the estimate in a :job_created event.
-
#initialize(params = {}) ⇒ Event
constructor
A new instance of Event.
-
#invoice_amount ⇒ BigDecimal
Dollar amount of the invoice in an :invoice_sent event.
-
#invoice_id ⇒ String
Unique identifier of the invoice in an :invoice_sent event.
-
#invoice_job_id ⇒ String
Unique identifier of the job in an :invoice_sent event.
-
#job_id ⇒ String
Unique identifier of the job in a :job_created/scheduled/completed event.
-
#lead_id ⇒ String
Unique identifier of the lead in a :lead_converted event.
-
#scheduled_at ⇒ Time
Time when the job is scheduled a :job_scheduled event.
-
#type ⇒ Symbol
The type of event, e.g.: :lead_converted, :job_created, :invoice_sent.
Constructor Details
#initialize(params = {}) ⇒ Event
Returns a new instance of Event.
10 11 12 |
# File 'lib/hcp/event.rb', line 10 def initialize(params = {}) @params = params end |
Instance Method Details
#completed_at ⇒ Time
Returns time when the job was completed a :job_completed event.
39 |
# File 'lib/hcp/event.rb', line 39 def completed_at = Time.iso8601(@params.dig :job, :work_timestamps, :completed_at) |
#conversion_id ⇒ String
Returns the latest conversion ID, can be an estimate ID or a job ID.
33 |
# File 'lib/hcp/event.rb', line 33 def conversion_id = conversion['id'] |
#conversion_type ⇒ Symbol
Returns the latest conversion type, can be :estimate or :job.
30 |
# File 'lib/hcp/event.rb', line 30 def conversion_type = conversion['type'].downcase.to_sym |
#customer_id ⇒ String
Returns unique identifier of the customer in a :lead_converted or :job_created event.
21 |
# File 'lib/hcp/event.rb', line 21 def customer_id = @params.dig resource_type, :customer, :id |
#estimate_id ⇒ String
Returns unique identifier of the estimate in a :job_created event.
27 |
# File 'lib/hcp/event.rb', line 27 def estimate_id = @params.dig :job, :original_estimate_id |
#invoice_amount ⇒ BigDecimal
Returns dollar amount of the invoice in an :invoice_sent event.
48 |
# File 'lib/hcp/event.rb', line 48 def invoice_amount = BigDecimal(@params.dig :invoice, :amount) / 100.0 |
#invoice_id ⇒ String
Returns unique identifier of the invoice in an :invoice_sent event.
42 |
# File 'lib/hcp/event.rb', line 42 def invoice_id = @params.dig :invoice, :id |
#invoice_job_id ⇒ String
Returns unique identifier of the job in an :invoice_sent event.
45 |
# File 'lib/hcp/event.rb', line 45 def invoice_job_id = @params.dig :invoice, :job_id |
#job_id ⇒ String
Returns unique identifier of the job in a :job_created/scheduled/completed event.
24 |
# File 'lib/hcp/event.rb', line 24 def job_id = @params.dig :job, :id |
#lead_id ⇒ String
Returns unique identifier of the lead in a :lead_converted event.
18 |
# File 'lib/hcp/event.rb', line 18 def lead_id = @params.dig :lead, :id |
#scheduled_at ⇒ Time
Returns time when the job is scheduled a :job_scheduled event.
36 |
# File 'lib/hcp/event.rb', line 36 def scheduled_at = Time.iso8601(@params.dig :job, :schedule, :scheduled_start) |
#type ⇒ Symbol
Returns the type of event, e.g.: :lead_converted, :job_created, :invoice_sent.
15 |
# File 'lib/hcp/event.rb', line 15 def type = @params[:event].gsub('.', '_').to_sym |