jbr 2.1.0 → 2.2.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: 6938d7f413fe243d95247911154afacb7ec9098710f784b9032bbf5bf3d60e37
4
- data.tar.gz: 7b1b8c0f7b3b339ec96dd1f3343b75528a2a78755c752a0f779218746953b541
3
+ metadata.gz: c2e03e9b80223954e92497d75f84d2f6be78f23fadcbcfd7d82ba95e83ebacec
4
+ data.tar.gz: aac7754bb691e5b45ec8284a289eceacfc9afc961cbb71e6ffedc2f92a5fd2a9
5
5
  SHA512:
6
- metadata.gz: 9f4b95151294dc8d1119bc51d5fe63544ca66a0d7073b65e1de0e6b315e9d7cffea572d21567aa05c94a9df5692e0460aa454f531e1a86967209b6e3f81c2d11
7
- data.tar.gz: f1b7ed20d0eddab211e5a0ca5a68fbf6bfd25762ba20ccde8d76349e6a1fa986bc6dbc3cc062cced2947a8617fdd69cec3e33dcf8031158c24294fd0f8aaaff2
6
+ metadata.gz: 1a962bbdc7d20e9549fb10d55a5c52ddb1de7ce7c92a9da20e61162f040a8b2da35c2c6daa545c4ef67e36b04eec0085fa03faddf10db6435674390c20ddacde
7
+ data.tar.gz: e565f59d6f14284fd3919a048f770e060588be06850d225947b4552d88b1201ea7149afec5fe733f57d78afaa1809ea762f62377a7596729917381ecd7d65e7f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [2.2.0] - 2026-08-07
2
+
3
+ - [New] Carry the client a visit is for -- id, first name, last name, phone and email --
4
+ and the ID of the property it happens at, so an app can file a visit against the people
5
+ and places it already knows
6
+
1
7
  ## [2.1.0] - 2026-08-07
2
8
 
3
9
  - [New] Fetch the visits an account has scheduled from now on, with oauth.visits.upcoming.
data/README.md CHANGED
@@ -98,6 +98,9 @@ visit = visits.first
98
98
  visit.id # => 'Z2lkOi8vS'
99
99
  visit.title # => 'Furnace tune-up'
100
100
  visit.job_id # => 'Z2lkOi8vS'
101
+ visit.property_id # => 'Z2lkOi8vS'
102
+ visit.client # => { id: 'Z2lkOi8vS', first_name: 'Jane', last_name: 'Doe',
103
+ # phone: '5553335555', email: 'jane@example.com' }
101
104
  visit.address # => { street: '1 Main St', city: 'Raleigh', state: 'NC', zip: '27601',
102
105
  # latitude: 35.77, longitude: -78.63 }
103
106
  visit.starts_at # => 2026-08-09 14:00:00
@@ -171,6 +174,7 @@ Mock successfully fetching upcoming visits:
171
174
 
172
175
  ```ruby
173
176
  Jbr.mock.visits = [ { id: 'visit-01', title: 'Furnace tune-up', job_id: 'job-01',
177
+ property_id: 'property-01', client: { id: 'client-01', first_name: 'Jane' },
174
178
  address: { street: '1 Main St', city: 'Raleigh', state: 'NC', zip: '27601' },
175
179
  starts_at: Date.tomorrow.noon, ends_at: Date.tomorrow.end_of_day,
176
180
  all_day: false, client_confirmed: true } ]
@@ -15,6 +15,10 @@ module Jbr
15
15
 
16
16
  def job_id = @node[:job_id]
17
17
 
18
+ def property_id = @node[:property_id]
19
+
20
+ def client = @node.fetch :client, {}
21
+
18
22
  def address = @node.fetch :address, {}
19
23
 
20
24
  def all_day? = @node[:all_day]
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 = '2.1.0'
4
+ VERSION = '2.2.0'
5
5
  end
data/lib/jbr/visit.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  module Jbr
2
2
  # One stop at a property: when the work on a job is scheduled to happen.
3
3
  class Visit < Resource
4
+ # What Jobber calls each field of the client the work is for, against what a caller reads.
5
+ CLIENT_FIELDS = { id: :id, firstName: :first_name, lastName: :last_name,
6
+ phone: :phone, email: :email,
7
+ }
8
+
4
9
  # The query that reads a page of visits starting after a moment, oldest first. Forty a
5
10
  # page, not a hundred: Jobber prices a query by its page size and refuses the wider one.
6
11
  UPCOMING = <<~GRAPHQL
@@ -9,7 +14,8 @@ module Jbr
9
14
  nodes {
10
15
  id title startAt endAt allDay clientConfirmed
11
16
  job { id }
12
- property { address { #{Property::SELECTION} } }
17
+ client { #{CLIENT_FIELDS.keys.join ' '} }
18
+ property { id address { #{Property::SELECTION} } }
13
19
  }
14
20
  pageInfo { hasNextPage endCursor }
15
21
  }
@@ -47,6 +53,15 @@ module Jbr
47
53
  # @return [Boolean, nil] whether the client has confirmed the visit.
48
54
  def client_confirmed? = @node['clientConfirmed']
49
55
 
56
+ # @return [String, nil] the ID of the property the work happens at.
57
+ def property_id = @node.dig 'property', 'id'
58
+
59
+ # Who the work is for, in the fields a client is created with.
60
+ # @return [Hash] any of :id, :first_name, :last_name, :phone and :email.
61
+ def client
62
+ CLIENT_FIELDS.to_h { |jobber, ours| [ ours, @node.dig('client', jobber.to_s) ] }.compact
63
+ end
64
+
50
65
  # Where the work happens, in the fields {Property} carries.
51
66
  # @return [Hash] any of :street, :city, :state, :zip, :latitude and :longitude.
52
67
  def address = Property.fields_from @node.dig('property', 'address')
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: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo