jbr 3.11.0 → 3.13.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: eff06d450e1e4c357e208ca25d49eec46229009623dac5fab0d2316784b10ddc
4
+ data.tar.gz: 85cd26058f5eec17b84f143e61c1d366f2ac7702d44d0cd8b6fb80694041f6d3
5
5
  SHA512:
6
- metadata.gz: 61093edd19c3bd0b71472619e6b8cb5a9b2131571714ce2aa4091b0c0c51cb3c302ec8d8fed03b17f305cf147cb6f66fe32b3112ca890076a4d58ff08ce73907
7
- data.tar.gz: db03655e533202b01e4a4b1d0c9d69e55fc66233996a622770ded307cf7d6d227eceb01504bb8af9604e619053cc7a1894a7b33f87cd50117f5e338c96cff8d2
6
+ metadata.gz: 8cef0ee9b3d02ec476d890d6d34367d896e77ab374fa75f923d77fb6535415c3958c43aefea6ee7512e09606eb75cf92583c8c0ddf79e2ccf7d111b49a858af4
7
+ data.tar.gz: 1bdaf92404d72cf9ad5abaf26711e9cba47fa0054e1ab1e4b53114bfe0d157ed073959783ef8a23cdf101ac6ea95da798ca0e4723ffb06d907600b3857018aef
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [3.13.0] - 2026-08-31
2
+
3
+ - [New] `Jbr::LineItem#id`, `#description` and `#amount`, beside the `#quantity` and `#name` a
4
+ line already answered. The ID is how an app tells a line it has seen before from a new one,
5
+ the description is what the line says beyond what it is called, and the amount is what
6
+ Jobber calls `totalPrice`. Every query that lists lines now asks for all five, and a mocked
7
+ line answers whatever a test names for each
8
+
9
+ ## [3.12.0] - 2026-08-28
10
+
11
+ - [New] `Jbr::Account#name` and `#phone`, beside the `#id` it already answered. An app storing
12
+ which account it is connected to had nothing to show for it but a GID; the three are read in
13
+ one query the first time any of them is asked for. `Jbr.mock.account` names all three for a
14
+ test, and answers `account-01` for the ID where an app names none
15
+
1
16
  ## [3.11.0] - 2026-08-19
2
17
 
3
18
  - [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
@@ -150,7 +159,10 @@ job.line_items # => an Array of the lines the job is made of
150
159
  line = job.line_items.first
151
160
  line.quantity # => 3, whole where Jobber's own Float has nothing after the point, and 3.5
152
161
  # where it has: `3 Faucets`, or `3.5 Hours` for what was really billed
162
+ line.id # => 'Njc5MjAw', the ID Jobber files the line by
153
163
  line.name # => 'Bathroom Faucet Installation'
164
+ line.description # => 'Replace washers and reseat', what the line says beyond its name
165
+ line.amount # => 285.0, what the line comes to -- what Jobber calls totalPrice
154
166
  line.to_s # => '3 Bathroom Faucet Installation', how many of what, and the name alone where
155
167
  # Jobber holds no quantity for the line
156
168
  ```
@@ -299,6 +311,12 @@ Mock a custom redirect URL:
299
311
  Jbr.mock.oauth_url = 'https://example.com'
300
312
  ```
301
313
 
314
+ Mock the account the credentials belong to. Left unset, its ID is `account-01`:
315
+
316
+ ```ruby
317
+ Jbr.mock.account = { id: 'account-01', name: 'Acme Plumbing', phone: '(704) 459-7540' }
318
+ ```
319
+
302
320
  ### Requests
303
321
 
304
322
  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
data/lib/jbr/line_item.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  module Jbr
2
- # One line of the work a job is made of: how many of a thing, and what it is called.
2
+ # One line of the work a job is made of: how many of a thing, what it is called,
3
+ # what it says, and what it comes to.
3
4
  class LineItem < Resource
4
- # What Jobber calls each field of a line.
5
- FIELDS = %w[quantity name]
5
+ # What Jobber calls each field of a line. The ID reads through {Resource#id}, so an app
6
+ # can tell a line it has seen before from a new one.
7
+ FIELDS = %w[id quantity name description totalPrice]
6
8
 
7
9
  # The most lines to read off one record. Bounded because Jobber prices a connection by the
8
10
  # page it is asked for and prices an unbounded one at its own maximum, so the lines of a
@@ -22,6 +24,12 @@ module Jbr
22
24
  # @return [String, nil] what the line is called.
23
25
  def name = @node['name']
24
26
 
27
+ # @return [String, nil] what the line says, beyond what it is called.
28
+ def description = @node['description']
29
+
30
+ # @return [Float, nil] what the line comes to — what Jobber calls `totalPrice`.
31
+ def amount = @node['totalPrice']
32
+
25
33
  # @return [String] how many of what: `3 Bathroom Faucet Installation`, and the name alone
26
34
  # where Jobber holds no quantity for the line.
27
35
  def to_s = [ quantity, name ].compact.join ' '
@@ -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
@@ -3,8 +3,14 @@ module Jbr
3
3
  class Mock::LineItem < LineItem
4
4
  # @return [Object, nil] the values the app asked for. The quantity is still read whole,
5
5
  # so an app that mocks `3.0` of a thing sees the `3` a page would show.
6
+ def id = @node[:id]
7
+
6
8
  def quantity = whole @node[:quantity]
7
9
 
8
10
  def name = @node[:name]
11
+
12
+ def description = @node[:description]
13
+
14
+ def amount = @node[:amount]
9
15
  end
10
16
  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.13.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.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo