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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +15 -0
- data/lib/jbr/account.rb +14 -5
- data/lib/jbr/mock/account.rb +11 -3
- data/lib/jbr/mock.rb +2 -1
- data/lib/jbr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c97671522675aa1f7ae29743d5edb7188a49251adb4d485c50b144bfa64f27cf
|
|
4
|
+
data.tar.gz: 12c24e22c88f4880ed86c6b8377b34dafda2939e6ffd46b95a2f329cdcbc8c03
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
10
|
-
def id
|
|
11
|
-
|
|
12
|
-
|
|
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
|
data/lib/jbr/mock/account.rb
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
module Jbr
|
|
2
|
-
# The
|
|
2
|
+
# The account that reads from {Jbr.mock} instead of Jobber.
|
|
3
3
|
class Mock::Account < Account
|
|
4
|
-
# @return [
|
|
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,
|
|
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