holivia 0.13.0 → 0.18.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: 5727339aa56fea9ffe71d4f5e0c49fdcd91a2d120aa3f88f7ff33f6a7b6eb49a
4
- data.tar.gz: 6860e618178ca2b72dd346ec6f02b900cb1aaf48299db21bd6b2e98b6944ad9e
3
+ metadata.gz: 271aaa000a9c26152473b0b6cb693a8897ceca2da7ca2fd53a1e8a3beb6335a2
4
+ data.tar.gz: 69220c288809bceb7a8ed8c8873b1fbb57831d11049a371a18cd8c5d84626ae9
5
5
  SHA512:
6
- metadata.gz: 573b090f0d92ee3676f920992e1c60f71b17b423627a000a4f4d118a1f394657670ce40c19d378f29bf4f56b2f54b682716d66ee70b80db1c7ccf1b088742d37
7
- data.tar.gz: 26a6014d2c1351a3c2887c406ea572e7c5b73874077533c96c667ef8f11329e3a749954ae2ba141356066d51eff1ec970e758faa236d96687218db48f794d7da
6
+ metadata.gz: 3c682d5f11d12ca60ea9c07337a3587f3426859497c9af2c11eabe3b663124c5437a5e0f2d000b804c4d6d556d9c4d4bb7c0ed40f942382a66e1a8e9b0e7265a
7
+ data.tar.gz: 79ce0864fe511c0e75fb47f07e511376e0d35e99b412b248a103753eb21bb22b1bfb5a124a328fde5f92550a177b14bc1dab64788ad1a0a82543d108e3d25156
data/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.18.0] - 2026-11-03
4
+
5
+ - Add `holivia credit-consumption-alert index` with `--enterprise-id`, `--page`, and `--per-page`, listing alerts with their `employees_count` and `consumption`
6
+ - Add `holivia credit-consumption-alert show <id>` with the followed `employee_ids`
7
+ - Add `holivia credit-consumption-alert create` with `--enterprise-id`, `--name`, `--starts-on`, `--ends-on`, `--threshold`, repeatable `--recipient-email`, and employee IDs from repeatable `--employee-ids ID,ID` or `--employee-ids-file PATH` (one per line or comma separated), plus piped JSON
8
+ - Add `holivia credit-consumption-alert delete <id>`
9
+ - Requires an enterprise manager role
10
+ - Requires the matching Holivia backoffice API deployment
11
+
12
+ ## [0.17.0] - 2026-11-02
13
+
14
+ - Add `holivia hr-access-grant show <employee_id>` to print an employee's `hr_manager` and `hr_space_only` flags and HR access grants, with each resource's type, id, and label
15
+ - Add `holivia hr-access-grant update <employee_id>` with repeatable `--feature KEY=ID,ID` flags (each listed feature gets exactly those resource IDs, `KEY=` clears one, omitted features keep their grants), `--hr-manager true|false`, and piped JSON
16
+ - `hr_space_only` cannot be changed through the CLI, and demo employees cannot be updated
17
+ - Requires an enterprise manager or dev role
18
+ - Requires the matching Holivia backoffice API deployment
19
+
20
+ ## [0.16.0] - 2026-10-30
21
+
22
+ - Add `holivia appointment logs <id>` with `--page` and `--per-page` for an appointment's history (bookings, reschedules, cancellations, payments), newest first: log type, raw data, the backoffice title and content, and the author
23
+ - Requires an appointment viewer or limited appointment viewer role
24
+ - Requires the matching Holivia backoffice API deployment
25
+
26
+ ## [0.15.0] - 2026-10-29
27
+
28
+ - Add `--query`, `--locale`, `--state`, `--content-type`, `--page`, and `--per-page` to `holivia selfcare index`; it previously ignored its arguments and only returned the first page
29
+ - Add `--all` to `holivia selfcare index` to fetch every page of matching contents and print one JSON array
30
+ - `holivia selfcare index` lists each content's `topic_slugs`, `tag_codes`, and `format_types`; `holivia selfcare show` adds `tag_codes` and `format_types`
31
+ - Requires the matching Holivia backoffice API deployment for the new fields
32
+
33
+ ## [0.14.0] - 2026-10-23
34
+
35
+ - Add `holivia enterprise show <id>` for enterprise details: settings, headquarter, CSM, countries, employees count, and the current contract summary for contract viewers and managers
36
+ - Add `holivia enterprise employee-stats <id>` for aggregate employee counts (total, left, current, current dependents and HR managers), excluding demo employees
37
+ - Add read-only `holivia employee index` and `holivia employee show` commands with enterprise, query, left, HR manager, dependent status, demo, and pagination filters; demo employees are excluded unless `--demo` is given
38
+ - Add read-only `holivia contract index` and `holivia contract show` commands with enterprise, status (`active`, `expiring_soon`, `low_remaining`), and pagination filters
39
+ - Employee responses never include Holivia account data (user id, sign-up, or care status); SKILL.md treats employee data as personal data
40
+ - Employee commands require an employee viewer or manager role; contract commands require a contract viewer or manager role
41
+ - Requires the matching Holivia backoffice API deployment
42
+
3
43
  ## [0.13.0] - 2026-09-30
4
44
 
5
45
  - Replace terminal password login with browser OAuth authorization using PKCE and existing password/company SSO sign-in.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Ruby client and command-line interface for the Holivia API.
4
4
 
5
- The `holivia` executable is primarily used to manage Holivia backoffice data from the terminal: environments, authentication, selfcare content, objectives, enterprises, communication library items, HR intervention catalog items, HR home highlights, crises, collective interventions, and appointment diagnostics.
5
+ The `holivia` executable is primarily used to manage Holivia backoffice data from the terminal: environments, authentication, selfcare content, objectives, enterprises, employees, HR access grants, contracts, credit consumption alerts, communication library items, HR intervention catalog items, HR home highlights, crises, collective interventions, and appointment diagnostics and history.
6
6
 
7
7
  Coding agents can use [`SKILL.md`](SKILL.md) as a downloadable usage guide for operating this CLI safely.
8
8
 
@@ -115,6 +115,21 @@ List selfcare contents:
115
115
  holivia selfcare index
116
116
  ```
117
117
 
118
+ Search and filter contents (`--query` matches titles, descriptions, goals, and tag names; at most 100 per page):
119
+
120
+ ```bash
121
+ holivia selfcare index --query "communication non violente" --locale fr --state published
122
+ holivia selfcare index --content-type exercise --page 2 --per-page 100
123
+ ```
124
+
125
+ Fetch every matching content as one JSON array (`--all` ignores `--page` and `--per-page`):
126
+
127
+ ```bash
128
+ holivia selfcare index --all --locale fr --state published
129
+ ```
130
+
131
+ Each listed content includes its `topic_slugs`, `tag_codes`, and `format_types`; `selfcare show` adds `tag_codes` and `format_types` next to its full `topics`.
132
+
118
133
  Show one selfcare content:
119
134
 
120
135
  ```bash
@@ -180,12 +195,63 @@ Show video diagnostics for an appointment:
180
195
  holivia appointment video-diagnostics 42
181
196
  ```
182
197
 
198
+ Show an appointment's history (bookings, reschedules, cancellations, payments), newest first:
199
+
200
+ ```bash
201
+ holivia appointment logs 42
202
+ holivia appointment logs 42 --page 2 --per-page 50
203
+ ```
204
+
183
205
  Find an enterprise id:
184
206
 
185
207
  ```bash
186
208
  holivia enterprise lookup --query acme
187
209
  ```
188
210
 
211
+ Show details for an enterprise:
212
+
213
+ ```bash
214
+ holivia enterprise show 123
215
+ ```
216
+
217
+ Show employee counts for an enterprise:
218
+
219
+ ```bash
220
+ holivia enterprise employee-stats 123
221
+ ```
222
+
223
+ List and inspect employees of an enterprise:
224
+
225
+ ```bash
226
+ holivia employee index --enterprise-id 123 --query durand --left false
227
+ holivia employee show 42
228
+ ```
229
+
230
+ Show and update an employee's HR access grants (omitted features are kept; `KEY=` clears one):
231
+
232
+ ```bash
233
+ holivia hr-access-grant show 42
234
+ holivia hr-access-grant update 42 --feature crisis_management=3,4 --hr-manager true
235
+ ```
236
+
237
+ List and inspect contracts of an enterprise:
238
+
239
+ ```bash
240
+ holivia contract index --enterprise-id 123 --status active
241
+ holivia contract show 7
242
+ ```
243
+
244
+ Follow the credits consumed by a fixed group of employees, and email recipients once when they reach a threshold:
245
+
246
+ ```bash
247
+ holivia credit-consumption-alert create --enterprise-id 99 --name "Pavillon du Lac" \
248
+ --starts-on 2027-06-01 --ends-on 2028-06-01 --threshold 15 \
249
+ --recipient-email oceane@holivia.fr --employee-ids-file ids.txt
250
+ holivia credit-consumption-alert index --enterprise-id 99
251
+ holivia credit-consumption-alert show 5
252
+ holivia credit-consumption-alert delete 5
253
+ ```
254
+
189
255
  List crises for an enterprise:
190
256
 
191
257
  ```bash
data/SKILL.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Use this skill when you need to operate the Holivia API through the `holivia` command-line tool.
4
4
 
5
- The CLI manages Holivia backoffice data: environments, authentication, selfcare contents, objectives, selfcare-objective associations, enterprises, HR intervention catalog items, HR home highlights, crises, collective interventions, and appointment video diagnostics.
5
+ The CLI manages Holivia backoffice data: environments, authentication, selfcare contents, objectives, selfcare-objective associations, enterprises, employees, HR access grants, contracts, credit consumption alerts, HR intervention catalog items, HR home highlights, crises, collective interventions, and appointment video diagnostics and history.
6
6
 
7
7
  ## Preconditions
8
8
 
@@ -20,7 +20,8 @@ Use `holivia` in examples below. If working from a checkout before installation,
20
20
  - Before creating or updating content, run `holivia selfcare schema` and use its returned enum values and permitted item params as the source of truth.
21
21
  - Before creating or updating intervention catalog items, run `holivia intervention schema` and use its returned enum values and locales as the source of truth.
22
22
  - Before creating or updating HR home highlights, run `holivia highlight schema` and use its returned enum values and locales as the source of truth.
23
- - For destructive actions such as `holivia env remove`, `holivia selfcare objective delete`, `holivia crisis delete`, or `holivia collective-intervention delete`, confirm the target environment and ID first unless the user explicitly requested that exact action.
23
+ - For destructive actions such as `holivia env remove`, `holivia selfcare objective delete`, `holivia crisis delete`, `holivia credit-consumption-alert delete`, or `holivia collective-intervention delete`, confirm the target environment and ID first unless the user explicitly requested that exact action.
24
+ - Employee data is personal data. Query only the employees a task needs, do not copy employee lists into unrelated output, and never try to infer whether an employee has a Holivia account.
24
25
  - Treat all command output as JSON except informational commands such as `holivia env`, `holivia env list`, `holivia login`, `holivia logout`, `holivia version`, and `holivia --help`.
25
26
 
26
27
  ## Installation
@@ -156,6 +157,21 @@ List contents:
156
157
  holivia selfcare index
157
158
  ```
158
159
 
160
+ Search and filter contents (`--query` matches titles, descriptions, goals, and tag names; at most 100 per page):
161
+
162
+ ```bash
163
+ holivia selfcare index --query "communication non violente" --locale fr --state published
164
+ holivia selfcare index --content-type exercise --page 2 --per-page 100
165
+ ```
166
+
167
+ Fetch every matching content as one JSON array (`--all` ignores `--page` and `--per-page`):
168
+
169
+ ```bash
170
+ holivia selfcare index --all --locale fr --state published
171
+ ```
172
+
173
+ Each listed content includes its `topic_slugs`, `tag_codes`, and `format_types`; `selfcare show` adds `tag_codes` and `format_types` next to its full `topics`.
174
+
159
175
  Show one content:
160
176
 
161
177
  ```bash
@@ -367,6 +383,124 @@ Filter enterprise lookup:
367
383
  holivia enterprise index --headquarter-id 10 --user-id 20 --page 1 --per-page 25
368
384
  ```
369
385
 
386
+ Show details for one enterprise (settings, headquarter, CSM, countries, employees count; the current contract is included only for contract viewers and managers):
387
+
388
+ ```bash
389
+ holivia enterprise show 123
390
+ ```
391
+
392
+ Show aggregate employee counts for one enterprise (excludes demo employees; never includes account sign-up data):
393
+
394
+ ```bash
395
+ holivia enterprise employee-stats 123
396
+ ```
397
+
398
+ ## Employees
399
+
400
+ Requires an employee viewer or manager role. Responses never include Holivia account data (no user id, sign-up, or care status). `employee index` excludes demo employees unless `--demo true` (demo employees only) or `--demo all` (everyone) is given.
401
+
402
+ List employees of an enterprise:
403
+
404
+ ```bash
405
+ holivia employee index --enterprise-id 123 --page 1 --per-page 25
406
+ ```
407
+
408
+ Search and filter employees:
409
+
410
+ ```bash
411
+ holivia employee index --enterprise-id 123 --query durand --left false --hr-manager true
412
+ holivia employee index --enterprise-id 123 --dependent-status dependent
413
+ holivia employee index --enterprise-id 123 --demo true
414
+ ```
415
+
416
+ Show one employee:
417
+
418
+ ```bash
419
+ holivia employee show 42
420
+ ```
421
+
422
+ ## HR Access Grants
423
+
424
+ Requires an enterprise manager role or `dev`. Grants decide which HR space features an employee can use, and for which resource: a data scope for `usage`, a segment for `segment_summary`, an enterprise for every other feature.
425
+
426
+ Show an employee's `hr_manager` and `hr_space_only` flags and their grants, with each resource's type, id, and label:
427
+
428
+ ```bash
429
+ holivia hr-access-grant show 42
430
+ ```
431
+
432
+ Update grants. Each `--feature KEY=ID,ID` gets exactly those resource IDs; features you leave out keep their current grants, and `KEY=` clears a feature. Run `hr-access-grant show` first and pass back the IDs you want to keep:
433
+
434
+ ```bash
435
+ holivia hr-access-grant update 42 --feature crisis_management=3,4 --feature employees_list= --hr-manager true
436
+ echo '{"features": {"usage": [12]}}' | holivia hr-access-grant update 42
437
+ ```
438
+
439
+ Piped JSON is merged after flags, and stdin wins on duplicate keys: a stdin `features` object replaces every `--feature` flag.
440
+
441
+ The API answers 422 with details and changes nothing when a feature key is unknown, a resource ID is outside the employee's enterprise group, or the employee is a demo employee. `hr_space_only` cannot be changed through the CLI; ask for it to be changed in the backoffice.
442
+
443
+ ## Contracts
444
+
445
+ Requires a contract viewer or manager role.
446
+
447
+ List contracts of an enterprise, most recent first:
448
+
449
+ ```bash
450
+ holivia contract index --enterprise-id 123
451
+ ```
452
+
453
+ Find active contracts, contracts expiring within three months, or contracts with low remaining sessions:
454
+
455
+ ```bash
456
+ holivia contract index --status active
457
+ holivia contract index --status expiring_soon
458
+ holivia contract index --status low_remaining
459
+ ```
460
+
461
+ Show every setting of one contract, including notes:
462
+
463
+ ```bash
464
+ holivia contract show 7
465
+ ```
466
+
467
+ ## Credit Consumption Alerts
468
+
469
+ Requires an enterprise manager role. An alert follows a fixed list of employees of one enterprise and counts the enterprise credits they consume from `starts_on` (and until `ends_on` when given). Once the consumption reaches `threshold`, recipients get one email and `triggered_at` is set. Employees stay followed after they leave or their details change.
470
+
471
+ List alerts, most recent first, with `employees_count` and `consumption`:
472
+
473
+ ```bash
474
+ holivia credit-consumption-alert index --enterprise-id 99
475
+ ```
476
+
477
+ Show one alert with its followed `employee_ids`:
478
+
479
+ ```bash
480
+ holivia credit-consumption-alert show 5
481
+ ```
482
+
483
+ Create an alert. Employee IDs are the backoffice employee IDs (`holivia employee index --enterprise-id 99`); pass them with repeatable `--employee-ids 12,13` or with `--employee-ids-file` (one ID per line, or comma separated). `--recipient-email` is repeatable:
484
+
485
+ ```bash
486
+ holivia credit-consumption-alert create \
487
+ --enterprise-id 99 \
488
+ --name "Pavillon du Lac" \
489
+ --starts-on 2027-06-01 \
490
+ --ends-on 2028-06-01 \
491
+ --threshold 15 \
492
+ --recipient-email oceane@holivia.fr \
493
+ --employee-ids-file ids.txt
494
+ ```
495
+
496
+ Piped JSON is merged after flags, and stdin wins on duplicate keys. The API answers 422 and creates nothing when an ID is not an employee of the enterprise (the unknown IDs are listed), when no employee ID is given, or when a field is invalid.
497
+
498
+ Delete an alert (its employees are kept):
499
+
500
+ ```bash
501
+ holivia credit-consumption-alert delete 5
502
+ ```
503
+
370
504
  ## Crises
371
505
 
372
506
  List crises:
@@ -630,6 +764,15 @@ Show video diagnostics for an appointment:
630
764
  holivia appointment video-diagnostics 42
631
765
  ```
632
766
 
767
+ Show an appointment's history, newest first:
768
+
769
+ ```bash
770
+ holivia appointment logs 42
771
+ holivia appointment logs 42 --page 2 --per-page 50
772
+ ```
773
+
774
+ Each log has `log_type` (`appointment_booked`, `appointment_rescheduled`, `appointment_rescheduled_last_minute`, `appointment_canceled`, `appointment_payed`, `unconfirmed_appointment_booked`), `created_at` (UTC), raw `data` (UTC `logged_start_time`/`previous_start_time`, durations in minutes, `patient_credits` after the operation), the French `title` and `content` shown in the backoffice (dates in your time zone), and `user` (`type`, `id`, `name`) for who triggered it, or `null`. `title` and `content` are `null` for log types the backoffice cannot render. Logs contain patient names; treat them as personal data. Requires an appointment viewer or limited appointment viewer role.
775
+
633
776
  ## Errors
634
777
 
635
778
  - `401` means authentication failed or credentials could not be refreshed. Re-run `holivia login` for the active environment.
@@ -22,7 +22,9 @@ module Holivia
22
22
  Tokens are stored at ~/.holivia/credentials.<env>.json and refreshed automatically on 401.
23
23
 
24
24
  Selfcare Contents:
25
- holivia selfcare index List all selfcare contents
25
+ holivia selfcare index [options] List selfcare contents
26
+ (--query TEXT --locale LOCALE --state STATE
27
+ --content-type TYPE --page N --per-page N --all)
26
28
  holivia selfcare show <id> Show a selfcare content by id
27
29
  holivia selfcare create [options] Create a selfcare content
28
30
  (--state draft|ongoing_translation|translation_to_be_reviewed|
@@ -77,6 +79,53 @@ module Holivia
77
79
  holivia enterprise index [--query TEXT --headquarter-id ID --user-id ID --page N --per-page N]
78
80
  Find enterprises and their enterprise_id values
79
81
  holivia enterprise lookup [options] Alias for enterprise index
82
+ holivia enterprise show <id> Show enterprise details: settings, headquarter, CSM,
83
+ countries, employees count, and the current contract
84
+ for contract viewers
85
+ holivia enterprise employee-stats <id> Show aggregate employee counts (total, left, current,
86
+ current dependents, current HR managers)
87
+
88
+ Employees:
89
+ holivia employee index [--enterprise-id ID --query TEXT --left true|false --hr-manager true|false
90
+ --dependent-status creator|dependent|not_dependent --demo true|false|all
91
+ --page N --per-page N]
92
+ List employees; never includes Holivia account data.
93
+ Demo employees are excluded unless --demo is given
94
+ holivia employee show <id> Show one employee with its enterprise
95
+
96
+ HR Access Grants:
97
+ holivia hr-access-grant show <employee_id>
98
+ Show an employee's hr_manager and hr_space_only flags
99
+ and HR feature grants with their resources
100
+ holivia hr-access-grant update <employee_id> [--feature KEY=ID,ID ... --hr-manager true|false]
101
+ Grant exactly the given resource IDs for each listed feature;
102
+ omitted features keep their grants and KEY= clears one
103
+ Features: usage (data scope IDs), segment_summary (segment IDs), employees_list,
104
+ crisis_management, intervention_catalog, intervention_tracking, communication_library
105
+ (enterprise IDs). IDs outside the employee's enterprise group are rejected (422).
106
+ hr_space_only can only be changed in the backoffice. Demo employees cannot be updated.
107
+ Piped JSON ({"features": {...}, "hr_manager": true}) is merged after flags; stdin wins.
108
+ Requires enterprise_manager or dev.
109
+
110
+ Contracts:
111
+ holivia contract index [--enterprise-id ID --status active|expiring_soon|low_remaining --page N --per-page N]
112
+ List contracts, most recent first
113
+ holivia contract show <id> Show every setting of one contract with its enterprise
114
+
115
+ Credit Consumption Alerts:
116
+ holivia credit-consumption-alert index [--enterprise-id ID --page N --per-page N]
117
+ List alerts, most recent first, with consumption
118
+ holivia credit-consumption-alert show <id>
119
+ Show one alert with its followed employee IDs
120
+ holivia credit-consumption-alert create --enterprise-id ID --name NAME --starts-on YYYY-MM-DD
121
+ [--ends-on YYYY-MM-DD] --threshold N --recipient-email EMAIL ...
122
+ (--employee-ids ID,ID ... | --employee-ids-file PATH)
123
+ Follow these employees of the enterprise; an email is sent
124
+ once when their consumed credits reach the threshold
125
+ holivia credit-consumption-alert delete <id>
126
+ Delete an alert (employees are kept)
127
+ IDs that are not employees of the enterprise are rejected (422).
128
+ Piped JSON is merged after flags; stdin wins. Requires enterprise_manager.
80
129
 
81
130
  Communication Items:
82
131
  holivia communication index [--page N --per-page N --query TEXT --locale LOCALE --document-type TYPE]
@@ -145,6 +194,8 @@ module Holivia
145
194
 
146
195
  Appointments:
147
196
  holivia appointment video-diagnostics <id> Show video diagnostics for an appointment
197
+ holivia appointment logs <id> [--page N --per-page N]
198
+ Show an appointment's history, newest first
148
199
 
149
200
  Selfcare Content Objectives:
150
201
  holivia selfcare objective index [--page N --per-page N --selfcare-content-id ID --objective-id ID]
data/lib/holivia/cli.rb CHANGED
@@ -16,6 +16,10 @@ require_relative "commands/communication_item"
16
16
  require_relative "commands/intervention_item"
17
17
  require_relative "commands/hr_home_highlight"
18
18
  require_relative "commands/enterprise"
19
+ require_relative "commands/employee"
20
+ require_relative "commands/hr_access_grant"
21
+ require_relative "commands/contract"
22
+ require_relative "commands/credit_consumption_alert"
19
23
  require_relative "commands/crisis"
20
24
  require_relative "commands/collective_intervention"
21
25
  require_relative "commands/support_phone_number"
@@ -37,6 +41,10 @@ module Holivia
37
41
  when "intervention" then Commands::InterventionItem.route(args)
38
42
  when "highlight" then Commands::HrHomeHighlight.route(args)
39
43
  when "enterprise" then Commands::Enterprise.route(args)
44
+ when "employee" then Commands::Employee.route(args)
45
+ when "hr-access-grant" then Commands::HrAccessGrant.route(args)
46
+ when "contract" then Commands::Contract.route(args)
47
+ when "credit-consumption-alert" then Commands::CreditConsumptionAlert.route(args)
40
48
  when "crisis" then Commands::Crisis.route(args)
41
49
  when "collective-intervention", "collective_intervention", "collective" then Commands::CollectiveIntervention.route(args)
42
50
  when "support-phone-numbers" then Commands::SupportPhoneNumber.route(args)
@@ -11,6 +11,7 @@ module Holivia
11
11
  subcommand = args.shift
12
12
  case subcommand
13
13
  when "video-diagnostics" then new.video_diagnostics(args)
14
+ when "logs" then new.logs(args)
14
15
  else warn "Unknown appointment command: #{subcommand}"
15
16
  exit 1
16
17
  end
@@ -22,6 +23,20 @@ module Holivia
22
23
 
23
24
  output(client.get("#{BASE_PATH}/#{id}/video_diagnostics"))
24
25
  end
26
+
27
+ def logs(args = [])
28
+ id = args.shift
29
+ abort "Usage: holivia appointment logs <id> [--page N --per-page N]" unless id
30
+
31
+ params = {}
32
+ OptionParser.new do |opts|
33
+ opts.banner = "Usage: holivia appointment logs <id> [options]"
34
+ opts.on("--page N", Integer) { |v| params[:page] = v }
35
+ opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
36
+ end.parse!(args)
37
+
38
+ output(client.get("#{BASE_PATH}/#{id}/logs", params: params))
39
+ end
25
40
  end
26
41
  end
27
42
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Holivia
6
+ module Commands
7
+ class Contract < Base
8
+ BASE_PATH = "/api/v1/backoffice/contracts"
9
+
10
+ def self.route(args)
11
+ subcommand = args.shift
12
+ case subcommand
13
+ when "index" then new.index(args)
14
+ when "show" then new.show(args)
15
+ else warn "Unknown contract command: #{subcommand}"
16
+ exit 1
17
+ end
18
+ end
19
+
20
+ def index(args = [])
21
+ params = {}
22
+ OptionParser.new do |opts|
23
+ opts.banner = "Usage: holivia contract index [options]"
24
+ opts.on("--enterprise-id ID", Integer) { |v| params[:enterprise_id] = v }
25
+ opts.on("--status STATUS") { |v| params[:status] = v }
26
+ opts.on("--page N", Integer) { |v| params[:page] = v }
27
+ opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
28
+ end.parse!(args)
29
+
30
+ output(client.get(BASE_PATH, params: params))
31
+ end
32
+
33
+ def show(args = [])
34
+ id = args.shift
35
+ abort "Usage: holivia contract show <id>" unless id
36
+
37
+ output(client.get("#{BASE_PATH}/#{id}"))
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Holivia
6
+ module Commands
7
+ class CreditConsumptionAlert < Base
8
+ BASE_PATH = "/api/v1/backoffice/credit_consumption_alerts"
9
+ CREATE_BANNER = "Usage: holivia credit-consumption-alert create --enterprise-id ID --name NAME " \
10
+ "--starts-on YYYY-MM-DD [--ends-on YYYY-MM-DD] --threshold N --recipient-email EMAIL " \
11
+ "(--employee-ids ID,ID | --employee-ids-file PATH)"
12
+ EMPLOYEE_IDS_SEPARATOR = /[\s,]+/
13
+
14
+ def self.route(args)
15
+ subcommand = args.shift
16
+ case subcommand
17
+ when "index" then new.index(args)
18
+ when "show" then new.show(args)
19
+ when "create" then new.create(args)
20
+ when "delete" then new.delete(args)
21
+ else warn "Unknown credit-consumption-alert command: #{subcommand}"
22
+ exit 1
23
+ end
24
+ end
25
+
26
+ def index(args = [])
27
+ params = {}
28
+ OptionParser.new do |opts|
29
+ opts.banner = "Usage: holivia credit-consumption-alert index [options]"
30
+ opts.on("--enterprise-id ID", Integer) { |v| params[:enterprise_id] = v }
31
+ opts.on("--page N", Integer) { |v| params[:page] = v }
32
+ opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
33
+ end.parse!(args)
34
+
35
+ output(client.get(BASE_PATH, params: params))
36
+ end
37
+
38
+ def show(args = [])
39
+ id = args.shift
40
+ abort "Usage: holivia credit-consumption-alert show <id>" unless id
41
+
42
+ output(client.get("#{BASE_PATH}/#{id}"))
43
+ end
44
+
45
+ def create(args = [])
46
+ options = parse_create_options(args).merge(piped_json)
47
+ abort "No options provided. Use --help for usage." if options.empty?
48
+
49
+ output(client.post(BASE_PATH, body: options))
50
+ end
51
+
52
+ def delete(args = [])
53
+ id = args.shift
54
+ abort "Usage: holivia credit-consumption-alert delete <id>" unless id
55
+
56
+ client.delete("#{BASE_PATH}/#{id}")
57
+ output(deleted: true, id: id.to_i)
58
+ end
59
+
60
+ private
61
+
62
+ def parse_create_options(args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
63
+ options = {}
64
+ OptionParser.new do |opts|
65
+ opts.banner = CREATE_BANNER
66
+ opts.on("--enterprise-id ID", Integer) { |v| options[:enterprise_id] = v }
67
+ opts.on("--name NAME") { |v| options[:name] = v }
68
+ opts.on("--starts-on DATE") { |v| options[:starts_on] = v }
69
+ opts.on("--ends-on DATE") { |v| options[:ends_on] = v }
70
+ opts.on("--threshold N", Integer) { |v| options[:threshold] = v }
71
+ opts.on("--recipient-email EMAIL", "Repeatable") { |v| (options[:recipient_emails] ||= []) << v }
72
+ opts.on("--employee-ids IDS", "Comma separated employee IDs; repeatable") do |v|
73
+ (options[:employee_ids] ||= []).concat(parse_employee_ids(v))
74
+ end
75
+ opts.on("--employee-ids-file PATH", "One employee ID per line, or comma separated") do |v|
76
+ (options[:employee_ids] ||= []).concat(parse_employee_ids(File.read(v)))
77
+ end
78
+ end.parse!(args)
79
+ options[:employee_ids]&.uniq!
80
+ options
81
+ end
82
+
83
+ def parse_employee_ids(value)
84
+ value.split(EMPLOYEE_IDS_SEPARATOR).reject(&:empty?).map { |id| Integer(id, 10) }
85
+ rescue ArgumentError
86
+ raise OptionParser::InvalidArgument, value.strip
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Holivia
6
+ module Commands
7
+ class Employee < Base
8
+ BASE_PATH = "/api/v1/backoffice/employees"
9
+ BOOLEAN_VALUES = %w[true false].freeze
10
+ DEPENDENT_STATUSES = %w[creator dependent not_dependent].freeze
11
+ DEMO_VALUES = %w[true false all].freeze
12
+
13
+ def self.route(args)
14
+ subcommand = args.shift
15
+ case subcommand
16
+ when "index" then new.index(args)
17
+ when "show" then new.show(args)
18
+ else warn "Unknown employee command: #{subcommand}"
19
+ exit 1
20
+ end
21
+ end
22
+
23
+ def index(args = []) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
24
+ params = {}
25
+ OptionParser.new do |opts|
26
+ opts.banner = "Usage: holivia employee index [options]"
27
+ opts.on("--enterprise-id ID", Integer) { |v| params[:enterprise_id] = v }
28
+ opts.on("--query TEXT") { |v| params[:query] = v }
29
+ opts.on("--left BOOL", BOOLEAN_VALUES) { |v| params[:left] = v }
30
+ opts.on("--hr-manager BOOL", BOOLEAN_VALUES) { |v| params[:hr_manager] = v }
31
+ opts.on("--dependent-status STATUS", DEPENDENT_STATUSES) { |v| params[:dependent_status] = v }
32
+ opts.on("--demo VALUE", DEMO_VALUES) { |v| params[:demo] = v }
33
+ opts.on("--page N", Integer) { |v| params[:page] = v }
34
+ opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
35
+ end.parse!(args)
36
+
37
+ output(client.get(BASE_PATH, params: params))
38
+ end
39
+
40
+ def show(args = [])
41
+ id = args.shift
42
+ abort "Usage: holivia employee show <id>" unless id
43
+
44
+ output(client.get("#{BASE_PATH}/#{id}"))
45
+ end
46
+ end
47
+ end
48
+ end
@@ -11,6 +11,8 @@ module Holivia
11
11
  subcommand = args.shift
12
12
  case subcommand
13
13
  when "index", "lookup", "search" then new.index(args)
14
+ when "show" then new.show(args)
15
+ when "employee-stats" then new.employee_stats(args)
14
16
  else warn "Unknown enterprise command: #{subcommand}"
15
17
  exit 1
16
18
  end
@@ -29,6 +31,20 @@ module Holivia
29
31
 
30
32
  output(client.get(BASE_PATH, params: params))
31
33
  end
34
+
35
+ def show(args = [])
36
+ id = args.shift
37
+ abort "Usage: holivia enterprise show <id>" unless id
38
+
39
+ output(client.get("#{BASE_PATH}/#{id}"))
40
+ end
41
+
42
+ def employee_stats(args = [])
43
+ id = args.shift
44
+ abort "Usage: holivia enterprise employee-stats <id>" unless id
45
+
46
+ output(client.get("#{BASE_PATH}/#{id}/employee_stats"))
47
+ end
32
48
  end
33
49
  end
34
50
  end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Holivia
6
+ module Commands
7
+ class HrAccessGrant < Base
8
+ EMPLOYEES_PATH = "/api/v1/backoffice/employees"
9
+ UPDATE_BANNER = "Usage: holivia hr-access-grant update <employee_id> [--feature KEY=ID,ID ...] " \
10
+ "[--hr-manager true|false]"
11
+ BOOLEANS = { "true" => true, "false" => false }.freeze
12
+
13
+ def self.route(args)
14
+ subcommand = args.shift
15
+ case subcommand
16
+ when "show" then new.show(args)
17
+ when "update" then new.update(args)
18
+ else warn "Unknown hr-access-grant command: #{subcommand}"
19
+ exit 1
20
+ end
21
+ end
22
+
23
+ def show(args = [])
24
+ employee_id = args.shift
25
+ abort "Usage: holivia hr-access-grant show <employee_id>" unless employee_id
26
+
27
+ output(client.get(grants_path(employee_id)))
28
+ end
29
+
30
+ def update(args = [])
31
+ employee_id = args.shift
32
+ abort UPDATE_BANNER unless employee_id
33
+
34
+ options = parse_update_options(args).merge(piped_json)
35
+ abort "No options provided. Use --help for usage." if options.empty?
36
+
37
+ output(client.patch(grants_path(employee_id), body: options))
38
+ end
39
+
40
+ private
41
+
42
+ def parse_update_options(args)
43
+ options = {}
44
+ OptionParser.new do |opts|
45
+ opts.banner = UPDATE_BANNER
46
+ opts.on("--feature KEY=IDS", "Grant exactly these resource IDs for a feature; KEY= clears it") do |v|
47
+ key, ids = parse_feature(v)
48
+ (options[:features] ||= {})[key] = ids
49
+ end
50
+ opts.on("--hr-manager BOOL", BOOLEANS) { |v| options[:hr_manager] = v }
51
+ end.parse!(args)
52
+ options
53
+ end
54
+
55
+ def parse_feature(value)
56
+ key, ids = value.split("=", 2)
57
+ raise OptionParser::InvalidArgument, value if key.to_s.empty? || ids.nil?
58
+
59
+ [key.to_sym, ids.split(",").map { |id| Integer(id) }]
60
+ rescue ArgumentError
61
+ raise OptionParser::InvalidArgument, value
62
+ end
63
+
64
+ def grants_path(employee_id)
65
+ "#{EMPLOYEES_PATH}/#{employee_id}/hr_access_grants"
66
+ end
67
+ end
68
+ end
69
+ end
@@ -5,8 +5,9 @@ require_relative "selfcare_objective"
5
5
 
6
6
  module Holivia
7
7
  module Commands
8
- class Selfcare < Base
8
+ class Selfcare < Base # rubocop:disable Metrics/ClassLength
9
9
  BASE_PATH = "/api/v1/backoffice/selfcare_contents"
10
+ MAX_PER_PAGE = 100
10
11
  COMPOSE_EXAMPLE_PATH = Holivia.root.join("examples", "compose.json").to_s
11
12
  IMAGE_MIME_TYPES = {
12
13
  ".jpg" => "image/jpeg",
@@ -34,8 +35,21 @@ module Holivia
34
35
  end
35
36
  end
36
37
 
37
- def index(_args = [])
38
- output(client.get(BASE_PATH))
38
+ def index(args = []) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
39
+ params = {}
40
+ all = false
41
+ OptionParser.new do |opts|
42
+ opts.banner = "Usage: holivia selfcare index [options]"
43
+ opts.on("--query TEXT") { |v| params[:query] = v }
44
+ opts.on("--locale LOCALE") { |v| params[:locale] = v }
45
+ opts.on("--state STATE") { |v| params[:state] = v }
46
+ opts.on("--content-type TYPE") { |v| params[:content_type] = v }
47
+ opts.on("--page N", Integer) { |v| params[:page] = v }
48
+ opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
49
+ opts.on("--all", "Fetch every page and print one JSON array (ignores --page and --per-page)") { all = true }
50
+ end.parse!(args)
51
+
52
+ output(all ? all_pages(params.except(:page, :per_page)) : client.get(BASE_PATH, params: params))
39
53
  end
40
54
 
41
55
  def show(args = [])
@@ -110,6 +124,19 @@ module Holivia
110
124
 
111
125
  private
112
126
 
127
+ def all_pages(params)
128
+ contents = []
129
+ page = 1
130
+ loop do
131
+ response = client.get(BASE_PATH, params: params.merge(page: page, per_page: MAX_PER_PAGE))
132
+ contents.concat(response.fetch("selfcare_contents"))
133
+ break if page >= response.dig("meta", "total_pages").to_i
134
+
135
+ page += 1
136
+ end
137
+ contents
138
+ end
139
+
113
140
  def build_body(options)
114
141
  image_path = options.delete(:image)
115
142
  return options unless image_path
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Holivia
4
- VERSION = "0.13.0"
4
+ VERSION = "0.18.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holivia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Holivia
@@ -66,10 +66,14 @@ files:
66
66
  - lib/holivia/commands/base.rb
67
67
  - lib/holivia/commands/collective_intervention.rb
68
68
  - lib/holivia/commands/communication_item.rb
69
+ - lib/holivia/commands/contract.rb
70
+ - lib/holivia/commands/credit_consumption_alert.rb
69
71
  - lib/holivia/commands/crisis.rb
72
+ - lib/holivia/commands/employee.rb
70
73
  - lib/holivia/commands/enterprise.rb
71
74
  - lib/holivia/commands/env.rb
72
75
  - lib/holivia/commands/format.rb
76
+ - lib/holivia/commands/hr_access_grant.rb
73
77
  - lib/holivia/commands/hr_home_highlight.rb
74
78
  - lib/holivia/commands/intervention_item.rb
75
79
  - lib/holivia/commands/item.rb
@@ -107,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
111
  - !ruby/object:Gem::Version
108
112
  version: '0'
109
113
  requirements: []
110
- rubygems_version: 4.0.10
114
+ rubygems_version: 4.0.23
111
115
  specification_version: 4
112
116
  summary: Ruby client and CLI for the Holivia API
113
117
  test_files: []