hcp 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90d571ad7e7872688843090321835c3f6d8b0c02a5793acee7673575d61e44f3
4
- data.tar.gz: 78bd3365a5feabeced0e6a94739f091708b94722e509d2447aba4986053dd24c
3
+ metadata.gz: 2c507e653633d17395829ab18ff34b44313aa37c8e19286aecad3096adae8848
4
+ data.tar.gz: 3677c714fefd88238ff2ebee783f2d6ba6141bf6a2aa37d994a43b7cd0b292e5
5
5
  SHA512:
6
- metadata.gz: 9dd74a5fda91a8dd80376cea9825bcd4d11db89263679ec6d21ebe382a90c14e3f4ae5a5e438ab43612f492843c26b364a40ed0a83a31389d6809b40700e80ae
7
- data.tar.gz: ec5410256cfcca4f65ac92aaa0e1988eec68009ae3ae440667f71097dabc9a5e1abceb962cc7c44e3154842837130f17bddf6cf082bba7afd26f46b620fd81d5
6
+ metadata.gz: 34f585b624bec1d61839a69a6c2678bad38e8b24bd02605e5fb47aa11fc5fdff5c31cd8e2aab802daa75f943a72cf9c7f39ac97fafa5d15dd52b0efb52ef42d6
7
+ data.tar.gz: a498b1a75b5f8170837a99661c265800eccaec5d3384c626f5bbbd086373488afbc063172876e04c15abb7c520418aa51e7c6fb3ef2c5ac28d580bcc1795304c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.1.0] - 2026-05-27
2
+
3
+ - [New] Add Hcp::Event
4
+
1
5
  ## [1.0.0] - 2026-05-15
2
6
 
3
7
  - Initial release: Lead and Lead::Pipeline classes
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Housecall Pro API Ruby client
1
+ # The Housecall Pro API Ruby client
2
2
 
3
3
  ## Available methods
4
4
 
data/lib/hcp/event.rb ADDED
@@ -0,0 +1,58 @@
1
+ module Hcp
2
+ class Event
3
+ # @see https://docs.housecallpro.com/docs/housecall-public-api/46e9e1be07621-webhooks
4
+ SIGNATURE_HEADER = 'Api-Signature'
5
+
6
+ # @see https://docs.housecallpro.com/docs/housecall-public-api/46e9e1be07621-webhooks
7
+ TIMESTAMP_HEADER = 'Api-Timestamp'
8
+
9
+ # @param params [Hash] the payload for an event webhook.
10
+ def initialize(params = {})
11
+ @params = params
12
+ end
13
+
14
+ # @return [Symbol] the type of event, e.g.: :lead_converted, :job_created, :invoice_sent.
15
+ def type = @params[:event].gsub('.', '_').to_sym
16
+
17
+ # @return [String] unique identifier of the lead in a :lead_converted event.
18
+ def lead_id = @params.dig :lead, :id
19
+
20
+ # @return [String] unique identifier of the customer in a :lead_converted or :job_created event.
21
+ def customer_id = @params.dig resource_type, :customer, :id
22
+
23
+ # @return [String] unique identifier of the job in a :job_created/scheduled/completed event.
24
+ def job_id = @params.dig :job, :id
25
+
26
+ # @return [String] unique identifier of the estimate in a :job_created event.
27
+ def estimate_id = @params.dig :job, :original_estimate_id
28
+
29
+ # @return [Symbol] the latest conversion type, can be :estimate or :job.
30
+ def conversion_type = conversion['type'].downcase.to_sym
31
+
32
+ # @return [String] the latest conversion ID, can be an estimate ID or a job ID.
33
+ def conversion_id = conversion['id']
34
+
35
+ # @return [Time] time when the job is scheduled a :job_scheduled event.
36
+ def scheduled_at = Time.iso8601(@params.dig :job, :schedule, :scheduled_start)
37
+
38
+ # @return [Time] time when the job was completed a :job_completed event.
39
+ def completed_at = Time.iso8601(@params.dig :job, :work_timestamps, :completed_at)
40
+
41
+ # @return [String] unique identifier of the invoice in an :invoice_sent event.
42
+ def invoice_id = @params.dig :invoice, :id
43
+
44
+ # @return [String] unique identifier of the job in an :invoice_sent event.
45
+ def invoice_job_id = @params.dig :invoice, :job_id
46
+
47
+ # @return [BigDecimal] dollar amount of the invoice in an :invoice_sent event.
48
+ def invoice_amount = BigDecimal(@params.dig :invoice, :amount) / 100.0
49
+
50
+ private
51
+
52
+ # @return [Hash] the latest conversion, applies to 'lead.converted' events.
53
+ def conversion = @params.dig(:lead, :conversions).last
54
+
55
+ # @return [Symbol] the type of resource affected by the event, can be :lead or :job.
56
+ def resource_type = @params[:event].split('.').first.to_sym
57
+ end
58
+ end
data/lib/hcp/version.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Ruby client for the Housecall Pro API.
3
4
  module Hcp
4
- VERSION = '1.0.0'
5
+ # Current version of the gem.
6
+ VERSION = '1.1.0'
5
7
  end
data/lib/hcp.rb CHANGED
@@ -7,3 +7,5 @@ require 'hcp/error'
7
7
  require 'hcp/resource'
8
8
  require 'hcp/lead'
9
9
  require 'hcp/lead/pipeline'
10
+
11
+ require 'hcp/event'
metadata CHANGED
@@ -1,14 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies: []
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: activesupport
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
12
26
  description: Housecall Pro API
13
27
  email:
14
28
  - claudiob@users.noreply.github.com
@@ -21,17 +35,18 @@ files:
21
35
  - README.md
22
36
  - lib/hcp.rb
23
37
  - lib/hcp/error.rb
38
+ - lib/hcp/event.rb
24
39
  - lib/hcp/lead.rb
25
40
  - lib/hcp/lead/pipeline.rb
26
41
  - lib/hcp/resource.rb
27
42
  - lib/hcp/version.rb
28
- homepage: https://github.com/HouseAccountEng/hcp
43
+ homepage: https://github.com/claudiob/hcp
29
44
  licenses:
30
45
  - MIT
31
46
  metadata:
32
- homepage_uri: https://github.com/HouseAccountEng/hcp
33
- source_code_uri: https://github.com/HouseAccountEng/hcp
34
- changelog_uri: https://github.com/HouseAccountEng/hcp
47
+ homepage_uri: https://github.com/claudiob/hcp
48
+ source_code_uri: https://github.com/claudiob/hcp
49
+ changelog_uri: https://github.com/claudiob/hcp
35
50
  rdoc_options: []
36
51
  require_paths:
37
52
  - lib