jbr 3.10.0 → 3.12.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: 5a315b6ba52c573f0d7fa1a0adec8145578550bd67a136071e7b8a02ea328ea1
4
- data.tar.gz: 8c338c2f5a13ce4e98c99c2b5c11377274c71908a2b93fc6c114d8fb109ae540
3
+ metadata.gz: c97671522675aa1f7ae29743d5edb7188a49251adb4d485c50b144bfa64f27cf
4
+ data.tar.gz: 12c24e22c88f4880ed86c6b8377b34dafda2939e6ffd46b95a2f329cdcbc8c03
5
5
  SHA512:
6
- metadata.gz: e82a0f7dac54170d4f791a752f7497d0b783dce98f4057c606c3ee1f5fe73c85ef32032eb297e2406b95d82bf531d6ba1cf2f4db8a9de5be1fbef38ac1c1c69b
7
- data.tar.gz: 82a90ec3316204bb8ccf87c4d4011e249cd7b5d4484697fc30477f553bd4146baa9402bff10f4c6c2f893ce93bc7d06509831ecaf4a7d8a16a60dfad5b0ae67d
6
+ metadata.gz: 814518f518e0a4fb14f738462991b675c2f249f88e652fa76cb36e4685d00fd393250d8b4ec12256541ddd5318ecb30b23c712384fda2a6ee588b0ff2c2ba1fb
7
+ data.tar.gz: 9d8755f3c9ccab26b72f18d76d465f23fd949bf36b2f5d2dfe2a3a96d6f99d500c5e8fefb9ab019044205934dd0eb6dd1111762853087a9605e40257e13490f5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [3.12.0] - 2026-08-28
2
+
3
+ - [New] `Jbr::Account#name` and `#phone`, beside the `#id` it already answered. An app storing
4
+ which account it is connected to had nothing to show for it but a GID; the three are read in
5
+ one query the first time any of them is asked for. `Jbr.mock.account` names all three for a
6
+ test, and answers `account-01` for the ID where an app names none
7
+
8
+ ## [3.11.0] - 2026-08-19
9
+
10
+ - [New] `Jbr::Property#latitude` and `#longitude`, reading the two the address already carried.
11
+ Every property query has asked Jobber for its `coordinates` for some time and `#address` has
12
+ answered them, but a caller wanting one had to open the hash -- and a mocked property answered
13
+ nothing for the whole address, so under `Jbr.mock` there was no way to reach them at all
14
+
1
15
  ## [3.8.0] - 2026-08-18
2
16
 
3
17
  - [New] `Jbr::Retriable`, a `Jbr::Error` for a query Jobber refused over what it costs rather
data/README.md CHANGED
@@ -61,6 +61,15 @@ oauth.expires_at # => 2026-05-22 14:32:53
61
61
  oauth.account_id # => 'Z2lkOi8vSm9iYmV'
62
62
  ```
63
63
 
64
+ Read the account they belong to, once, however much of it is asked for:
65
+
66
+ ```ruby
67
+ account = oauth.account
68
+ account.id # => 'Z2lkOi8vSm9iYmV'
69
+ account.name # => 'Acme Plumbing'
70
+ account.phone # => '(704) 459-7540', as Jobber holds it
71
+ ```
72
+
64
73
  Revoke credentials:
65
74
 
66
75
  ```ruby
@@ -215,6 +224,8 @@ visit.property.id # => 'Z2lkOi8vS'
215
224
  visit.property.street # => '1 Main St'
216
225
  visit.property.city # => 'Raleigh'
217
226
  visit.property.zip # => '27601'
227
+ visit.property.latitude # => 35.77
228
+ visit.property.longitude # => -78.63
218
229
  visit.property.address # => { street: '1 Main St', city: 'Raleigh', state: 'NC',
219
230
  # zip: '27601', latitude: 35.77, longitude: -78.63 }
220
231
  visit.property.client.name # => whoever the place sits on the file of
@@ -297,6 +308,12 @@ Mock a custom redirect URL:
297
308
  Jbr.mock.oauth_url = 'https://example.com'
298
309
  ```
299
310
 
311
+ Mock the account the credentials belong to. Left unset, its ID is `account-01`:
312
+
313
+ ```ruby
314
+ Jbr.mock.account = { id: 'account-01', name: 'Acme Plumbing', phone: '(704) 459-7540' }
315
+ ```
316
+
300
317
  ### Requests
301
318
 
302
319
  Mock successfully creating a request:
data/lib/jbr/account.rb CHANGED
@@ -3,12 +3,21 @@ module Jbr
3
3
  class Account < Resource
4
4
  # The query that reads the account behind the current credentials.
5
5
  FIND = <<~GRAPHQL
6
- { account { id } }
6
+ { account { id name phone } }
7
7
  GRAPHQL
8
8
 
9
- # @return [String] the account ID, read once and remembered.
10
- def id
11
- @id ||= @oauth.query(FIND).dig 'account', 'id'
12
- end
9
+ # @return [String, nil] the account ID.
10
+ def id = node['id']
11
+
12
+ # @return [String, nil] what the business calls itself.
13
+ def name = node['name']
14
+
15
+ # @return [String, nil] the number the business is reached on, as Jobber holds it.
16
+ def phone = node['phone']
17
+
18
+ private
19
+
20
+ # Read once and remembered, whichever of the three is asked for first.
21
+ def node = @node = @node.presence || @oauth.query(FIND).fetch('account', {})
13
22
  end
14
23
  end
@@ -1,7 +1,15 @@
1
1
  module Jbr
2
- # The one account every mocked set of credentials belongs to.
2
+ # The account that reads from {Jbr.mock} instead of Jobber.
3
3
  class Mock::Account < Account
4
- # @return [String] the mocked account ID.
5
- def id = 'account-01'
4
+ # @return [Object, nil] the values the app asked for, and 'account-01' for an ID it did not.
5
+ def id = node.fetch :id, 'account-01'
6
+
7
+ def name = node[:name]
8
+
9
+ def phone = node[:phone]
10
+
11
+ private
12
+
13
+ def node = Jbr.mock.account.to_h
6
14
  end
7
15
  end
@@ -10,6 +10,10 @@ module Jbr
10
10
 
11
11
  def zip = @node[:zip]
12
12
 
13
+ def latitude = @node[:latitude]
14
+
15
+ def longitude = @node[:longitude]
16
+
13
17
  def client = Mock::Client.new(node: @node.fetch(:client, {}))
14
18
  end
15
19
  end
data/lib/jbr/mock.rb CHANGED
@@ -2,6 +2,7 @@ module Jbr
2
2
  # What an app under test wants Jobber to answer.
3
3
  class Mock
4
4
  # The canned answers, each read by the matching Mock resource.
5
- attr_accessor :quote, :job, :invoice, :request, :visits, :jobs, :oauth_url, :oauth_error
5
+ attr_accessor :account, :quote, :job, :invoice, :request, :visits, :jobs, :oauth_url,
6
+ :oauth_error
6
7
  end
7
8
  end
data/lib/jbr/property.rb CHANGED
@@ -35,6 +35,12 @@ module Jbr
35
35
  # @return [String, nil] the postal code the work happens in.
36
36
  def zip = address[:zip]
37
37
 
38
+ # @return [Float, nil] how far north the work happens.
39
+ def latitude = address[:latitude]
40
+
41
+ # @return [Float, nil] how far east the work happens.
42
+ def longitude = address[:longitude]
43
+
38
44
  # The fields a match is made on. City and state are written but never matched:
39
45
  # Jobber holds whatever was typed, so "NC" and "North Carolina" -- or "Winston Salem"
40
46
  # and "Winston-Salem" -- would read as two homes. The ZIP already places the home.
data/lib/jbr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # A Ruby client for the Jobber API.
2
2
  module Jbr
3
3
  # The version of this gem.
4
- VERSION = '3.10.0'
4
+ VERSION = '3.12.0'
5
5
  end
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: 3.10.0
4
+ version: 3.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo