jbr 3.11.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: 85448f81e07f54907f8ea7dd6d3cd3c75cdc2b7283c282fee36a650a509140ba
4
- data.tar.gz: 47ca67d4e752524a7c14109968e949ec23951925863d9785a6a7dcde38932094
3
+ metadata.gz: c97671522675aa1f7ae29743d5edb7188a49251adb4d485c50b144bfa64f27cf
4
+ data.tar.gz: 12c24e22c88f4880ed86c6b8377b34dafda2939e6ffd46b95a2f329cdcbc8c03
5
5
  SHA512:
6
- metadata.gz: 61093edd19c3bd0b71472619e6b8cb5a9b2131571714ce2aa4091b0c0c51cb3c302ec8d8fed03b17f305cf147cb6f66fe32b3112ca890076a4d58ff08ce73907
7
- data.tar.gz: db03655e533202b01e4a4b1d0c9d69e55fc66233996a622770ded307cf7d6d227eceb01504bb8af9604e619053cc7a1894a7b33f87cd50117f5e338c96cff8d2
6
+ metadata.gz: 814518f518e0a4fb14f738462991b675c2f249f88e652fa76cb36e4685d00fd393250d8b4ec12256541ddd5318ecb30b23c712384fda2a6ee588b0ff2c2ba1fb
7
+ data.tar.gz: 9d8755f3c9ccab26b72f18d76d465f23fd949bf36b2f5d2dfe2a3a96d6f99d500c5e8fefb9ab019044205934dd0eb6dd1111762853087a9605e40257e13490f5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
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
+
1
8
  ## [3.11.0] - 2026-08-19
2
9
 
3
10
  - [New] `Jbr::Property#latitude` and `#longitude`, reading the two the address already carried.
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
@@ -299,6 +308,12 @@ Mock a custom redirect URL:
299
308
  Jbr.mock.oauth_url = 'https://example.com'
300
309
  ```
301
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
+
302
317
  ### Requests
303
318
 
304
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
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/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.11.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.11.0
4
+ version: 3.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo