holivia 0.14.0 → 0.19.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: fab1251135002a03f719e93cb2f2d1fcb52842e2f5c5fecc3fa8c47c279b8747
4
- data.tar.gz: 8e2dd66d735bf875c123d42d90c25ab7d853024c5378dc8445d2f8c4eeb233aa
3
+ metadata.gz: f48cd0cfc125dae15d0ee9bcbdde6ba33bc7776a10a51491c8e604f20ebe5559
4
+ data.tar.gz: 751270d4fdc10546f597e4e3f42ee478a6d9bfbcdb07e72f5598f11eac6c3d74
5
5
  SHA512:
6
- metadata.gz: a0c502ac53052598fff122e0b5bafc5028c7cd2dee25ebc6629879f0a77d17516314608012493d41ee8571cb79802d5a276c43e64d03236f2e86d8e7a4c68e77
7
- data.tar.gz: 5454072e3f4e4d046b1a8de6e60a9a9641db2a5d16eaf85441de7340e065572f4606c83a603bc4f615ef0c86b02f4a03babf28fa267559375c9fa0602fac3c56
6
+ metadata.gz: 584bcae6722a7f2dcd078dd0730653df07f187234eeeebb3c3175efbcdc1fc7fabff2575327a9f42eb46eee915c733f2f1f246d91374f58b884b14612f4c27bc
7
+ data.tar.gz: 1847411588f4980e0820491cf78debe0b32cf7dd0f6656de617c68de5789dab93bb34b07ac63db7b3d8cadb8be23b6526fd5e58c5431d40cd9b4d3d73e213c08
data/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.19.0] - 2026-11-11
4
+
5
+ - Add `holivia selfcare text <id>` to print the plain text of a selfcare content's text format: slide titles and rich text, in reading order; returns 404 when the content has no text format
6
+ - Add `--format-type TYPE` (`text`, `audio`, or `video`) to `holivia selfcare index`, also with `--all`, to list only contents that have a format of that type
7
+ - Requires a content viewer, content manager, or dev role
8
+ - Requires the matching Holivia backoffice API deployment
9
+
10
+ ## [0.18.0] - 2026-11-03
11
+
12
+ - Add `holivia credit-consumption-alert index` with `--enterprise-id`, `--page`, and `--per-page`, listing alerts with their `employees_count` and `consumption`
13
+ - Add `holivia credit-consumption-alert show <id>` with the followed `employee_ids`
14
+ - 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
15
+ - Add `holivia credit-consumption-alert delete <id>`
16
+ - Requires an enterprise manager role
17
+ - Requires the matching Holivia backoffice API deployment
18
+
19
+ ## [0.17.0] - 2026-11-02
20
+
21
+ - 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
22
+ - 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
23
+ - `hr_space_only` cannot be changed through the CLI, and demo employees cannot be updated
24
+ - Requires an enterprise manager or dev role
25
+ - Requires the matching Holivia backoffice API deployment
26
+
27
+ ## [0.16.0] - 2026-10-30
28
+
29
+ - 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
30
+ - Requires an appointment viewer or limited appointment viewer role
31
+ - Requires the matching Holivia backoffice API deployment
32
+
33
+ ## [0.15.0] - 2026-10-29
34
+
35
+ - 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
36
+ - Add `--all` to `holivia selfcare index` to fetch every page of matching contents and print one JSON array
37
+ - `holivia selfcare index` lists each content's `topic_slugs`, `tag_codes`, and `format_types`; `holivia selfcare show` adds `tag_codes` and `format_types`
38
+ - Requires the matching Holivia backoffice API deployment for the new fields
39
+
3
40
  ## [0.14.0] - 2026-10-23
4
41
 
5
42
  - Add `holivia enterprise show <id>` for enterprise details: settings, headquarter, CSM, countries, employees count, and the current contract summary for contract viewers and managers
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, employees, contracts, 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,12 +115,39 @@ 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
+ Keep only contents that have a format of a given type (`text`, `audio`, or `video`):
126
+
127
+ ```bash
128
+ holivia selfcare index --format-type text --all
129
+ ```
130
+
131
+ Fetch every matching content as one JSON array (`--all` ignores `--page` and `--per-page`):
132
+
133
+ ```bash
134
+ holivia selfcare index --all --locale fr --state published
135
+ ```
136
+
137
+ 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`.
138
+
118
139
  Show one selfcare content:
119
140
 
120
141
  ```bash
121
142
  holivia selfcare show 123
122
143
  ```
123
144
 
145
+ Read the plain text of a content's text format (slide titles and rich text, in reading order; returns 404 when the content has no text format):
146
+
147
+ ```bash
148
+ holivia selfcare text 123
149
+ ```
150
+
124
151
  Create a selfcare content from flags:
125
152
 
126
153
  ```bash
@@ -180,6 +207,13 @@ Show video diagnostics for an appointment:
180
207
  holivia appointment video-diagnostics 42
181
208
  ```
182
209
 
210
+ Show an appointment's history (bookings, reschedules, cancellations, payments), newest first:
211
+
212
+ ```bash
213
+ holivia appointment logs 42
214
+ holivia appointment logs 42 --page 2 --per-page 50
215
+ ```
216
+
183
217
  Find an enterprise id:
184
218
 
185
219
  ```bash
@@ -205,6 +239,13 @@ holivia employee index --enterprise-id 123 --query durand --left false
205
239
  holivia employee show 42
206
240
  ```
207
241
 
242
+ Show and update an employee's HR access grants (omitted features are kept; `KEY=` clears one):
243
+
244
+ ```bash
245
+ holivia hr-access-grant show 42
246
+ holivia hr-access-grant update 42 --feature crisis_management=3,4 --hr-manager true
247
+ ```
248
+
208
249
  List and inspect contracts of an enterprise:
209
250
 
210
251
  ```bash
@@ -212,6 +253,17 @@ holivia contract index --enterprise-id 123 --status active
212
253
  holivia contract show 7
213
254
  ```
214
255
 
256
+ Follow the credits consumed by a fixed group of employees, and email recipients once when they reach a threshold:
257
+
258
+ ```bash
259
+ holivia credit-consumption-alert create --enterprise-id 99 --name "Pavillon du Lac" \
260
+ --starts-on 2027-06-01 --ends-on 2028-06-01 --threshold 15 \
261
+ --recipient-email oceane@holivia.fr --employee-ids-file ids.txt
262
+ holivia credit-consumption-alert index --enterprise-id 99
263
+ holivia credit-consumption-alert show 5
264
+ holivia credit-consumption-alert delete 5
265
+ ```
266
+
215
267
  List crises for an enterprise:
216
268
 
217
269
  ```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, employees, contracts, 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,7 @@ 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
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.
25
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`.
26
26
 
@@ -157,12 +157,39 @@ List contents:
157
157
  holivia selfcare index
158
158
  ```
159
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
+ Keep only contents that have a format of a given type (`text`, `audio`, or `video`):
168
+
169
+ ```bash
170
+ holivia selfcare index --format-type text --all
171
+ ```
172
+
173
+ Fetch every matching content as one JSON array (`--all` ignores `--page` and `--per-page`):
174
+
175
+ ```bash
176
+ holivia selfcare index --all --locale fr --state published
177
+ ```
178
+
179
+ 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`.
180
+
160
181
  Show one content:
161
182
 
162
183
  ```bash
163
184
  holivia selfcare show 123
164
185
  ```
165
186
 
187
+ Read the plain text of a content's text format (slide titles and rich text, in reading order; returns 404 when the content has no text format):
188
+
189
+ ```bash
190
+ holivia selfcare text 123
191
+ ```
192
+
166
193
  Create a content with flags:
167
194
 
168
195
  ```bash
@@ -404,6 +431,27 @@ Show one employee:
404
431
  holivia employee show 42
405
432
  ```
406
433
 
434
+ ## HR Access Grants
435
+
436
+ 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.
437
+
438
+ Show an employee's `hr_manager` and `hr_space_only` flags and their grants, with each resource's type, id, and label:
439
+
440
+ ```bash
441
+ holivia hr-access-grant show 42
442
+ ```
443
+
444
+ 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:
445
+
446
+ ```bash
447
+ holivia hr-access-grant update 42 --feature crisis_management=3,4 --feature employees_list= --hr-manager true
448
+ echo '{"features": {"usage": [12]}}' | holivia hr-access-grant update 42
449
+ ```
450
+
451
+ Piped JSON is merged after flags, and stdin wins on duplicate keys: a stdin `features` object replaces every `--feature` flag.
452
+
453
+ 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.
454
+
407
455
  ## Contracts
408
456
 
409
457
  Requires a contract viewer or manager role.
@@ -428,6 +476,43 @@ Show every setting of one contract, including notes:
428
476
  holivia contract show 7
429
477
  ```
430
478
 
479
+ ## Credit Consumption Alerts
480
+
481
+ 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.
482
+
483
+ List alerts, most recent first, with `employees_count` and `consumption`:
484
+
485
+ ```bash
486
+ holivia credit-consumption-alert index --enterprise-id 99
487
+ ```
488
+
489
+ Show one alert with its followed `employee_ids`:
490
+
491
+ ```bash
492
+ holivia credit-consumption-alert show 5
493
+ ```
494
+
495
+ 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:
496
+
497
+ ```bash
498
+ holivia credit-consumption-alert create \
499
+ --enterprise-id 99 \
500
+ --name "Pavillon du Lac" \
501
+ --starts-on 2027-06-01 \
502
+ --ends-on 2028-06-01 \
503
+ --threshold 15 \
504
+ --recipient-email oceane@holivia.fr \
505
+ --employee-ids-file ids.txt
506
+ ```
507
+
508
+ 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.
509
+
510
+ Delete an alert (its employees are kept):
511
+
512
+ ```bash
513
+ holivia credit-consumption-alert delete 5
514
+ ```
515
+
431
516
  ## Crises
432
517
 
433
518
  List crises:
@@ -691,6 +776,15 @@ Show video diagnostics for an appointment:
691
776
  holivia appointment video-diagnostics 42
692
777
  ```
693
778
 
779
+ Show an appointment's history, newest first:
780
+
781
+ ```bash
782
+ holivia appointment logs 42
783
+ holivia appointment logs 42 --page 2 --per-page 50
784
+ ```
785
+
786
+ 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.
787
+
694
788
  ## Errors
695
789
 
696
790
  - `401` means authentication failed or credentials could not be refreshed. Re-run `holivia login` for the active environment.
@@ -53,6 +53,8 @@ module Holivia
53
53
 
54
54
  def launch_browser(url)
55
55
  command = RUBY_PLATFORM.include?("darwin") ? "open" : "xdg-open"
56
+ # Fixed command with an argument list (no shell); the URL is built by this class.
57
+ # nosemgrep: ruby.lang.security.dangerous-exec.dangerous-exec
56
58
  system(command, url, out: File::NULL, err: File::NULL)
57
59
  end
58
60
 
@@ -22,8 +22,12 @@ 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 --format-type TYPE
28
+ --page N --per-page N --all)
26
29
  holivia selfcare show <id> Show a selfcare content by id
30
+ holivia selfcare text <id> Show the plain text of a selfcare content's text format
27
31
  holivia selfcare create [options] Create a selfcare content
28
32
  (--state draft|ongoing_translation|translation_to_be_reviewed|
29
33
  translation_reviewed|published)
@@ -91,11 +95,40 @@ module Holivia
91
95
  Demo employees are excluded unless --demo is given
92
96
  holivia employee show <id> Show one employee with its enterprise
93
97
 
98
+ HR Access Grants:
99
+ holivia hr-access-grant show <employee_id>
100
+ Show an employee's hr_manager and hr_space_only flags
101
+ and HR feature grants with their resources
102
+ holivia hr-access-grant update <employee_id> [--feature KEY=ID,ID ... --hr-manager true|false]
103
+ Grant exactly the given resource IDs for each listed feature;
104
+ omitted features keep their grants and KEY= clears one
105
+ Features: usage (data scope IDs), segment_summary (segment IDs), employees_list,
106
+ crisis_management, intervention_catalog, intervention_tracking, communication_library
107
+ (enterprise IDs). IDs outside the employee's enterprise group are rejected (422).
108
+ hr_space_only can only be changed in the backoffice. Demo employees cannot be updated.
109
+ Piped JSON ({"features": {...}, "hr_manager": true}) is merged after flags; stdin wins.
110
+ Requires enterprise_manager or dev.
111
+
94
112
  Contracts:
95
113
  holivia contract index [--enterprise-id ID --status active|expiring_soon|low_remaining --page N --per-page N]
96
114
  List contracts, most recent first
97
115
  holivia contract show <id> Show every setting of one contract with its enterprise
98
116
 
117
+ Credit Consumption Alerts:
118
+ holivia credit-consumption-alert index [--enterprise-id ID --page N --per-page N]
119
+ List alerts, most recent first, with consumption
120
+ holivia credit-consumption-alert show <id>
121
+ Show one alert with its followed employee IDs
122
+ holivia credit-consumption-alert create --enterprise-id ID --name NAME --starts-on YYYY-MM-DD
123
+ [--ends-on YYYY-MM-DD] --threshold N --recipient-email EMAIL ...
124
+ (--employee-ids ID,ID ... | --employee-ids-file PATH)
125
+ Follow these employees of the enterprise; an email is sent
126
+ once when their consumed credits reach the threshold
127
+ holivia credit-consumption-alert delete <id>
128
+ Delete an alert (employees are kept)
129
+ IDs that are not employees of the enterprise are rejected (422).
130
+ Piped JSON is merged after flags; stdin wins. Requires enterprise_manager.
131
+
99
132
  Communication Items:
100
133
  holivia communication index [--page N --per-page N --query TEXT --locale LOCALE --document-type TYPE]
101
134
  List communication library items
@@ -163,6 +196,8 @@ module Holivia
163
196
 
164
197
  Appointments:
165
198
  holivia appointment video-diagnostics <id> Show video diagnostics for an appointment
199
+ holivia appointment logs <id> [--page N --per-page N]
200
+ Show an appointment's history, newest first
166
201
 
167
202
  Selfcare Content Objectives:
168
203
  holivia selfcare objective index [--page N --per-page N --selfcare-content-id ID --objective-id ID]
data/lib/holivia/cli.rb CHANGED
@@ -17,7 +17,9 @@ require_relative "commands/intervention_item"
17
17
  require_relative "commands/hr_home_highlight"
18
18
  require_relative "commands/enterprise"
19
19
  require_relative "commands/employee"
20
+ require_relative "commands/hr_access_grant"
20
21
  require_relative "commands/contract"
22
+ require_relative "commands/credit_consumption_alert"
21
23
  require_relative "commands/crisis"
22
24
  require_relative "commands/collective_intervention"
23
25
  require_relative "commands/support_phone_number"
@@ -40,7 +42,9 @@ module Holivia
40
42
  when "highlight" then Commands::HrHomeHighlight.route(args)
41
43
  when "enterprise" then Commands::Enterprise.route(args)
42
44
  when "employee" then Commands::Employee.route(args)
45
+ when "hr-access-grant" then Commands::HrAccessGrant.route(args)
43
46
  when "contract" then Commands::Contract.route(args)
47
+ when "credit-consumption-alert" then Commands::CreditConsumptionAlert.route(args)
44
48
  when "crisis" then Commands::Crisis.route(args)
45
49
  when "collective-intervention", "collective_intervention", "collective" then Commands::CollectiveIntervention.route(args)
46
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,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,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",
@@ -21,6 +22,7 @@ module Holivia
21
22
  case subcommand
22
23
  when "index" then new.index(args)
23
24
  when "show" then new.show(args)
25
+ when "text" then new.text(args)
24
26
  when "create" then new.create(args)
25
27
  when "update" then new.update(args)
26
28
  when "compose" then new.compose(args)
@@ -34,8 +36,24 @@ module Holivia
34
36
  end
35
37
  end
36
38
 
37
- def index(_args = [])
38
- output(client.get(BASE_PATH))
39
+ def index(args = []) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
40
+ params = {}
41
+ all = false
42
+ OptionParser.new do |opts|
43
+ opts.banner = "Usage: holivia selfcare index [options]"
44
+ opts.on("--query TEXT") { |v| params[:query] = v }
45
+ opts.on("--locale LOCALE") { |v| params[:locale] = v }
46
+ opts.on("--state STATE") { |v| params[:state] = v }
47
+ opts.on("--content-type TYPE") { |v| params[:content_type] = v }
48
+ opts.on("--format-type TYPE", "Only contents with a format of this type (text, audio, video)") do |v|
49
+ params[:format_type] = v
50
+ end
51
+ opts.on("--page N", Integer) { |v| params[:page] = v }
52
+ opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
53
+ opts.on("--all", "Fetch every page and print one JSON array (ignores --page and --per-page)") { all = true }
54
+ end.parse!(args)
55
+
56
+ output(all ? all_pages(params.except(:page, :per_page)) : client.get(BASE_PATH, params: params))
39
57
  end
40
58
 
41
59
  def show(args = [])
@@ -45,6 +63,13 @@ module Holivia
45
63
  output(client.get("#{BASE_PATH}/#{id}"))
46
64
  end
47
65
 
66
+ def text(args = [])
67
+ id = args.shift
68
+ abort "Usage: holivia selfcare text <id>" unless id
69
+
70
+ output(client.get("#{BASE_PATH}/#{id}/text"))
71
+ end
72
+
48
73
  def create(args = []) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
49
74
  options = {}
50
75
  OptionParser.new do |opts|
@@ -110,6 +135,19 @@ module Holivia
110
135
 
111
136
  private
112
137
 
138
+ def all_pages(params)
139
+ contents = []
140
+ page = 1
141
+ loop do
142
+ response = client.get(BASE_PATH, params: params.merge(page: page, per_page: MAX_PER_PAGE))
143
+ contents.concat(response.fetch("selfcare_contents"))
144
+ break if page >= response.dig("meta", "total_pages").to_i
145
+
146
+ page += 1
147
+ end
148
+ contents
149
+ end
150
+
113
151
  def build_body(options)
114
152
  image_path = options.delete(:image)
115
153
  return options unless image_path
@@ -58,6 +58,8 @@ module Holivia
58
58
  return default_config unless raw["environments"].is_a?(Hash)
59
59
  return default_config unless raw["current_env"].is_a?(String)
60
60
 
61
+ # Not a Rails view; raw is a local variable holding the parsed config.
62
+ # nosemgrep: ruby.rails.security.audit.xss.avoid-raw.avoid-raw
61
63
  raw
62
64
  end
63
65
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Holivia
4
- VERSION = "0.14.0"
4
+ VERSION = "0.19.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.14.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Holivia
@@ -67,11 +67,13 @@ files:
67
67
  - lib/holivia/commands/collective_intervention.rb
68
68
  - lib/holivia/commands/communication_item.rb
69
69
  - lib/holivia/commands/contract.rb
70
+ - lib/holivia/commands/credit_consumption_alert.rb
70
71
  - lib/holivia/commands/crisis.rb
71
72
  - lib/holivia/commands/employee.rb
72
73
  - lib/holivia/commands/enterprise.rb
73
74
  - lib/holivia/commands/env.rb
74
75
  - lib/holivia/commands/format.rb
76
+ - lib/holivia/commands/hr_access_grant.rb
75
77
  - lib/holivia/commands/hr_home_highlight.rb
76
78
  - lib/holivia/commands/intervention_item.rb
77
79
  - lib/holivia/commands/item.rb
@@ -109,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
111
  - !ruby/object:Gem::Version
110
112
  version: '0'
111
113
  requirements: []
112
- rubygems_version: 4.0.10
114
+ rubygems_version: 4.0.23
113
115
  specification_version: 4
114
116
  summary: Ruby client and CLI for the Holivia API
115
117
  test_files: []