hcp 4.0.0 → 5.0.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 +23 -0
- data/README.md +6 -2
- data/lib/hcp/collections/visits.rb +11 -7
- data/lib/hcp/collections/windows.rb +5 -5
- data/lib/hcp/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c68dd1ad565d18c93e6682c1e8d75598f3ef742d93c3e477c6a1bdd82f840fec
|
|
4
|
+
data.tar.gz: fe27f4cc519612a192baf591a5cabc458ea1d3e56ff5c4837ec6ad17a923c96d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c83f06540c5cb55fbc276c8c8c565e52626ab5371fc4711b9a19332155fbc708faf9d8e9f7bf872c1f754410460a9b7a4c6e97dfd1c197fdd6705640907c3df
|
|
7
|
+
data.tar.gz: 66439b6015456b0110de1635c912f3c10827b77d850baeb9d49e12db49da012bc8be7962b705daed05885a7453ad7ef877a18b6c58e8983eb8b23cf844b0dc55
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [5.0.0] - 2026-09-17
|
|
4
|
+
|
|
5
|
+
- [Breaking change] The vocabulary is `company` 4.0: `of` takes the ID Housecall Pro files a
|
|
6
|
+
technician under rather than the technician, so `account.visits.of(technician.id)` is what
|
|
7
|
+
`account.visits.of(technician)` was, and the same for `account.windows`. The pin is `~> 4.0`.
|
|
8
|
+
|
|
9
|
+
- [Note] The ID is the whole of what this gem ever narrowed by -- `employee_ids` on both lists,
|
|
10
|
+
and a comparison on the walk -- and taking it plainly is what stops a caller handing over a
|
|
11
|
+
record of its own whose `id` is not the one Housecall Pro knows. That has already happened
|
|
12
|
+
once, and Housecall Pro answered with everybody's free time rather than one person's.
|
|
13
|
+
|
|
14
|
+
## [4.1.0] - 2026-09-17
|
|
15
|
+
|
|
16
|
+
- [Feature] `account.visits.for_work`, the stops of jobs and of estimates together and the hours
|
|
17
|
+
held around them left unread. `/events` narrows by nothing, so reading blocked-out time costs
|
|
18
|
+
a sweep of every page on top of the two requests the work itself takes -- fifteen of them on
|
|
19
|
+
an account with 2,877 events. A caller that wants the work and not the holds now says so and
|
|
20
|
+
is spared them.
|
|
21
|
+
|
|
22
|
+
- [Note] The vocabulary is `company` 3.1, where `for_work` is named. A platform that answers its
|
|
23
|
+
whole list at once gets the narrowing for free; this one pushes it down to the requests it
|
|
24
|
+
does not then make.
|
|
25
|
+
|
|
3
26
|
## [4.0.0] - 2026-09-16
|
|
4
27
|
|
|
5
28
|
- [Breaking change] The vocabulary is `company` 3.0: `assigned_to` is `of`, so
|
data/README.md
CHANGED
|
@@ -118,8 +118,12 @@ for the stops of work alone:
|
|
|
118
118
|
```ruby
|
|
119
119
|
account.visits.upcoming(2.weeks).for_jobs # => only the appointments, one request
|
|
120
120
|
account.visits.upcoming(2.weeks).for_leads # => only the estimates' slots, one request
|
|
121
|
+
account.visits.upcoming(2.weeks).for_work # => both kinds of stop, and no sweep
|
|
121
122
|
```
|
|
122
123
|
|
|
124
|
+
`for_work` is the one to ask for where a caller wants the work and not the hours held around it:
|
|
125
|
+
the jobs and the estimates are still read, and the fifteen requests of the sweep are not spent.
|
|
126
|
+
|
|
123
127
|
A stop says where it is without being asked what it was booked for: an appointment has no
|
|
124
128
|
address of its own and takes the job's, and an estimate's slot takes the estimate's. A caller
|
|
125
129
|
reading a schedule never reaches through `visit.job` for an address.
|
|
@@ -147,7 +151,7 @@ One technician's week is the visits in it narrowed to them, which is how a sched
|
|
|
147
151
|
|
|
148
152
|
```ruby
|
|
149
153
|
monday = Date.today.beginning_of_week.in_time_zone
|
|
150
|
-
account.visits.between(monday, monday + 1.week).of(technician).each do |visit|
|
|
154
|
+
account.visits.between(monday, monday + 1.week).of(technician.id).each do |visit|
|
|
151
155
|
visit.starts_at, visit.ends_at, visit.job.location.street
|
|
152
156
|
end
|
|
153
157
|
```
|
|
@@ -163,7 +167,7 @@ The other half of that week is the hours they are *not* out, which Housecall Pro
|
|
|
163
167
|
itself and answers whole:
|
|
164
168
|
|
|
165
169
|
```ruby
|
|
166
|
-
account.windows.between(monday, monday + 1.week).of(technician).each do |window|
|
|
170
|
+
account.windows.between(monday, monday + 1.week).of(technician.id).each do |window|
|
|
167
171
|
window.starts_at, window.ends_at
|
|
168
172
|
end
|
|
169
173
|
```
|
|
@@ -6,7 +6,7 @@ module Hcp
|
|
|
6
6
|
# @param client [Client] how to reach Housecall Pro as the location.
|
|
7
7
|
# @param from [Time, nil] the moment the window opens, or nothing for every visit there was.
|
|
8
8
|
# @param to [Time, nil] the moment the window closes, or nothing for every visit to come.
|
|
9
|
-
# @param technician [
|
|
9
|
+
# @param technician [String, nil] ID of whose work to ask for, or nothing for all.
|
|
10
10
|
# @param jobs [Boolean] whether to read the stops of jobs.
|
|
11
11
|
# @param leads [Boolean] whether to read the stops of estimates.
|
|
12
12
|
# @param events [Boolean] whether to read the hours blocked out around them.
|
|
@@ -29,12 +29,12 @@ module Hcp
|
|
|
29
29
|
# Housecall Pro narrows both lists by who is assigned to the work, so the window is asked
|
|
30
30
|
# for as this technician's; a job's stop is the whole crew's until somebody is dispatched
|
|
31
31
|
# to it, so the stops they are not on are let go once the work comes back.
|
|
32
|
-
# @param
|
|
33
|
-
# @return [Company::Selection] the same list, narrowed to the
|
|
34
|
-
def of(
|
|
35
|
-
theirs = with technician:
|
|
32
|
+
# @param id [String] ID Housecall Pro files whoever the work is booked for under.
|
|
33
|
+
# @return [Company::Selection] the same list, narrowed to the visits they are booked for.
|
|
34
|
+
def of(id)
|
|
35
|
+
theirs = with technician: id
|
|
36
36
|
Company::Selection.new(collection: theirs) do |visit|
|
|
37
|
-
visit.technicians.any? { |
|
|
37
|
+
visit.technicians.any? { |technician| technician.id == id }
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -44,6 +44,10 @@ module Hcp
|
|
|
44
44
|
# @return [Visits] the same list, read off the estimates alone: one request rather than many.
|
|
45
45
|
def for_leads = with(jobs: false, events: false)
|
|
46
46
|
|
|
47
|
+
# @return [Visits] the same list, read off the work alone: two requests rather than the
|
|
48
|
+
# fifteen a sweep of the calendar costs on top of them.
|
|
49
|
+
def for_work = with(events: false)
|
|
50
|
+
|
|
47
51
|
# Work booked across the window carries every stop in it, so each list is read once and
|
|
48
52
|
# what was called off keeps its stops to itself.
|
|
49
53
|
# @yield [Company::Visit] each visit in the window, the work's stops before the hours
|
|
@@ -71,7 +75,7 @@ module Hcp
|
|
|
71
75
|
|
|
72
76
|
def window = @from..@to
|
|
73
77
|
|
|
74
|
-
def crew = { employee_ids: (@technician && [ @technician
|
|
78
|
+
def crew = { employee_ids: (@technician && [ @technician ]) }
|
|
75
79
|
|
|
76
80
|
def jobs
|
|
77
81
|
bounds = { scheduled_end_min: @from&.utc&.iso8601, scheduled_start_max: @to&.utc&.iso8601 }
|
|
@@ -9,8 +9,8 @@ module Hcp
|
|
|
9
9
|
DAYS = 7
|
|
10
10
|
|
|
11
11
|
# @param client [Client] how to reach Housecall Pro as the location.
|
|
12
|
-
# @param technician [
|
|
13
|
-
#
|
|
12
|
+
# @param technician [String, nil] ID of whose free time to ask for, or nothing for whether
|
|
13
|
+
# anybody at all is free.
|
|
14
14
|
# @param from [Time, nil] the moment the window opens, or nothing for the first day open.
|
|
15
15
|
# @param to [Time, nil] the moment the window closes, or nothing for a week of it.
|
|
16
16
|
def initialize(client:, technician: nil, from: nil, to: nil)
|
|
@@ -27,9 +27,9 @@ module Hcp
|
|
|
27
27
|
|
|
28
28
|
# Housecall Pro narrows free time by who it is free for, so the technician joins the window
|
|
29
29
|
# in the one request and nobody else's hours are answered or paid for.
|
|
30
|
-
# @param
|
|
30
|
+
# @param id [String] ID Housecall Pro files whoever is free under.
|
|
31
31
|
# @return [Windows] the same list, as that technician's alone.
|
|
32
|
-
def of(
|
|
32
|
+
def of(id) = with(technician: id)
|
|
33
33
|
|
|
34
34
|
# Housecall Pro answers a week as a row of short windows, each open or not. Consecutive open
|
|
35
35
|
# ones are one stretch of free time and are joined back into it, so what comes out is as long
|
|
@@ -61,7 +61,7 @@ module Hcp
|
|
|
61
61
|
|
|
62
62
|
def params
|
|
63
63
|
{ start_date: @from&.utc&.strftime('%Y-%m-%dT%H:%M:%S'), show_for_days: days,
|
|
64
|
-
employee_ids: (@technician && [ @technician
|
|
64
|
+
employee_ids: (@technician && [ @technician ]), }.compact
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def days = (@to && @from) ? ((@to - @from) / 1.day).ceil : DAYS
|
data/lib/hcp/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hcp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 5.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Claudio Baccigalupo
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '4.0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
39
|
+
version: '4.0'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: ice_cube
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|