jbr 1.0.6 → 1.0.8

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: 2a5324bd1f1d013b3c4284542e4f5fb35437174789bd8e99a05eee9a9346811e
4
- data.tar.gz: c18756f37f36bd03e476ff8e5e838418765e6a9d933bd54ff43bfebd1bd856d2
3
+ metadata.gz: 5b22d779d7e688eaf8a64353655a11e880b961fee0dea0eafc4d56ae833dd77c
4
+ data.tar.gz: 8423c77d2b898f07d0125e66852f10373493d10ce09f37b3f489e581df2d73b0
5
5
  SHA512:
6
- metadata.gz: f7f5b06138be3b3cf73aca22357c841be01a2dee43731369007dd67901f47128cf79ea9bc3a5170903fe21cb7c8f01791df4c24333455890cc226b7a07b96846
7
- data.tar.gz: 32520407af951f696fffb1f2107c3f40d49e42ae4e5a1c846779c8a43e74cbb04ee54a425e07c70c27e12f364522845d65e7b3ed597aef33aff5e3011ce56332
6
+ metadata.gz: dded60918e2560621fde6a80ed20018f5aaf1d1391db9ba7144a12c11be90fc5bf5318dcfb16cab143c99d25cbc64fdfbf7f010c9560a5ca80e7eb7bd42e08a4
7
+ data.tar.gz: d5c5dfc9260eba1ec87c9fb6b05db5a039837820f01d544d1f07e438773f2f6e553be462e0ef594df07ffd77baca3c993537ef667cc43bcdf7138872eee76311
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.0.8] - 2026-05-26
2
+
3
+ - [New] Add Jbr.client_id and Jbr.client_secret
4
+
5
+ ## [1.0.7] - 2026-05-26
6
+
7
+ - [New] Add Jbr::Event to parse webhook payloads
8
+
1
9
  ## [1.0.6] - 2026-05-24
2
10
 
3
11
  - [Change] Return mock.oauth_error as the message of Jbr::Error
data/README.md CHANGED
@@ -83,6 +83,17 @@ invoice.issued_at # => 2026-05-22 12:12:53
83
83
  invoice.completed_at # => 2026-05-22 14:32:53
84
84
  ```
85
85
 
86
+ ### Events
87
+
88
+ Parse the payload of a Jobber event webhook:
89
+
90
+ ```ruby
91
+ event = Jbr::Event.new data: { webHookEvent: { topic: 'JOB_CREATE', appId: 'app-1',
92
+ accountId: 'account-1', itemId: 'job-1', occurredAt: '2026-05-22T15:46:33Z' } }
93
+ event.account_id = 'account-1
94
+ event.item_id = 'job-1
95
+ ```
96
+
86
97
  ## Available mocks
87
98
 
88
99
  Use these methods to mock request to Jobber when testing an app:
data/lib/jbr/event.rb ADDED
@@ -0,0 +1,17 @@
1
+ module Jbr
2
+ class Event
3
+ # @see https://developer.getjobber.com/docs/using_jobbers_api/setting_up_webhooks
4
+ SIGNATURE_HEADER = 'X-Jobber-Hmac-SHA256'
5
+
6
+ # @param params [Hash] the payload for an event webhook.
7
+ def initialize(params = {})
8
+ @params = params
9
+ end
10
+
11
+ # @return [String] unique identifier of the event target.
12
+ def item_id = @params.dig :data, :webHookEvent, :itemId
13
+
14
+ # @return [String] unique identifier of the event account.
15
+ def account_id = @params.dig :data, :webHookEvent, :accountId
16
+ end
17
+ end
data/lib/jbr/oauth.rb CHANGED
@@ -44,6 +44,12 @@ module Jbr
44
44
  new(credentials).tap { |oauth| oauth.account_id = oauth.account.id }
45
45
  end
46
46
 
47
+ # @return [String, nil] The client ID to interact with the API.
48
+ def self.client_id = ENV['JOBBER_CLIENT_ID']
49
+
50
+ # @return [String, nil] The client secret to interact with the API.
51
+ def self.client_secret = ENV['JOBBER_CLIENT_SECRET']
52
+
47
53
  private
48
54
 
49
55
  def refresh
@@ -65,10 +71,6 @@ module Jbr
65
71
  expires_at: (Time.current + output.fetch('expires_in', 3600).to_i) }
66
72
  end
67
73
 
68
- def self.client_id = ENV['JOBBER_CLIENT_ID']
69
-
70
- def self.client_secret = ENV['JOBBER_CLIENT_SECRET']
71
-
72
74
  def client
73
75
  GraphQL::Client.new endpoint: 'https://api.getjobber.com/api/graphql', token: @access_token, headers: headers
74
76
  end
data/lib/jbr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jbr
4
- VERSION = '1.0.6'
4
+ VERSION = '1.0.8'
5
5
  end
data/lib/jbr.rb CHANGED
@@ -30,3 +30,5 @@ require 'jbr/mock/account'
30
30
  require 'jbr/mock/url'
31
31
 
32
32
  require 'jbr/mocking'
33
+
34
+ require 'jbr/event'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
@@ -27,6 +27,7 @@ files:
27
27
  - lib/jbr/client.rb
28
28
  - lib/jbr/configuration.rb
29
29
  - lib/jbr/error.rb
30
+ - lib/jbr/event.rb
30
31
  - lib/jbr/invoice.rb
31
32
  - lib/jbr/job.rb
32
33
  - lib/jbr/mock.rb