holivia 0.8.0 → 0.9.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: 37fbbbbc00a19fce307307f0d0d0465383b83759a1bbb30977131edfff1c3a98
4
- data.tar.gz: 0241e8e1ece96ea66fdabe38c188e2914f071a26d225a778a6373c1a5c74fb64
3
+ metadata.gz: db5748262c860764f5d29eb0fc184f3a1af3eb5bfb0456f11d51b0b0b42cb4ef
4
+ data.tar.gz: e4acfa1c1ffa4994f9bc5244be6e306e680a2dbed9605db234c1cb197e63f896
5
5
  SHA512:
6
- metadata.gz: b310a7ef0b2f389a796a352d60455b33798c796821577623686b6658030d7716d4b7445fbac599630f5cf39d0ddc5db3c32d2ac3930dde8ec5692b37b3f300a8
7
- data.tar.gz: 13a99d2b9dd8e0b27e2bc3ad941d9e7756f8b629d30b347f13785f818f58db8df1c460fed7518b6b458a9752323028ed67e0325ab8448a8da39fd09f76884044
6
+ metadata.gz: 557e344b1c20c531f9261345f7697ab404c660d3da956649b5912d5b095222c5eac68eb46883b66a6bd1b4b816cc62fdb6ce01896b52bbacd060cdafc01507dc
7
+ data.tar.gz: 74c71712389a8b2c9ce184e5385a3011cf3f2fc26304605bd23c996d862e1321c6be2cbb508b971b5df15b5a4be98bb0fb4c6f788e547a2bcdd616726cfdb0f0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.9.0] - 2026-07-11
4
+
5
+ - Add `holivia highlight` commands for HR home highlight CRUD, publishing, schema discovery, and cover/document uploads
6
+ - Add `holivia enterprise` lookup commands for backoffice enterprise discovery
7
+ - Add `holivia crisis` CRUD commands for backoffice crisis management
8
+ - Add `holivia collective-intervention` CRUD commands for backoffice collective intervention management
9
+
10
+ ## [0.8.1] - 2026-07-08
11
+
12
+ - Add provider filtering and write support to `holivia intervention` commands
13
+
3
14
  ## [0.8.0] - 2026-07-07
4
15
 
5
16
  - Add `holivia intervention` commands for HR intervention catalog CRUD, publishing, schema discovery, and cover image uploads
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, communication library items, HR intervention catalog items, and appointment diagnostics.
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.
6
6
 
7
7
  Coding agents can use [`SKILL.md`](SKILL.md) as a downloadable usage guide for operating this CLI safely.
8
8
 
@@ -166,6 +166,54 @@ Show video diagnostics for an appointment:
166
166
  holivia appointment video-diagnostics 42
167
167
  ```
168
168
 
169
+ Find an enterprise id:
170
+
171
+ ```bash
172
+ holivia enterprise lookup --query acme
173
+ ```
174
+
175
+ List crises for an enterprise:
176
+
177
+ ```bash
178
+ holivia crisis index --enterprise-id 123 --status reported
179
+ ```
180
+
181
+ Create a crisis:
182
+
183
+ ```bash
184
+ holivia crisis create \
185
+ --enterprise-id 123 \
186
+ --title "Critical site situation" \
187
+ --description "A manager reported an urgent situation." \
188
+ --contact-json '{"first_name":"Marie","last_name":"Dupont","phone":"+33612345678","email":"marie.dupont@example.com","job_title":"DRH"}'
189
+ ```
190
+
191
+ Resolve it:
192
+
193
+ ```bash
194
+ holivia crisis update 42 --status resolved
195
+ ```
196
+
197
+ List collective interventions for an enterprise:
198
+
199
+ ```bash
200
+ holivia collective-intervention index --enterprise-id 123 --status submitted
201
+ ```
202
+
203
+ Create a collective intervention:
204
+
205
+ ```bash
206
+ holivia collective-intervention create \
207
+ --enterprise-id 123 \
208
+ --intervention-item-id 456 \
209
+ --title "Manager workshop for Paris" \
210
+ --description "Collective support for a management team." \
211
+ --location "12 rue de la Paix, 75002 Paris" \
212
+ --scheduled-starts-at "2026-08-01T09:00:00Z" \
213
+ --scheduled-ends-at "2026-08-01T11:00:00Z" \
214
+ --contact-json '{"first_name":"Marie","last_name":"Dupont","phone":"+33612345678","email":"marie.dupont@example.com","job_title":"DRH"}'
215
+ ```
216
+
169
217
  List communication library items:
170
218
 
171
219
  ```bash
@@ -189,7 +237,7 @@ Publish it:
189
237
  holivia communication publish 123
190
238
  ```
191
239
 
192
- Discover intervention catalog enum values and locales:
240
+ Discover intervention catalog enum values, providers, and locales:
193
241
 
194
242
  ```bash
195
243
  holivia intervention schema
@@ -201,11 +249,18 @@ List intervention catalog items:
201
249
  holivia intervention index --locale fr --state published --category audit_diagnose
202
250
  ```
203
251
 
252
+ Filter intervention catalog items by provider:
253
+
254
+ ```bash
255
+ holivia intervention index --locale fr --provider wpo --state published
256
+ ```
257
+
204
258
  Create an intervention item:
205
259
 
206
260
  ```bash
207
261
  holivia intervention create \
208
262
  --locale fr \
263
+ --provider wpo \
209
264
  --title "Manager burnout workshop" \
210
265
  --intervention-type workshop \
211
266
  --category raise_awareness_train \
@@ -224,6 +279,45 @@ Publish it:
224
279
  holivia intervention publish 123
225
280
  ```
226
281
 
282
+ Discover HR home highlight enum values and locales:
283
+
284
+ ```bash
285
+ holivia highlight schema
286
+ ```
287
+
288
+ List HR home highlights:
289
+
290
+ ```bash
291
+ holivia highlight index --locale fr --state published --highlight-type feature
292
+ ```
293
+
294
+ Create an HR home highlight that points to a URL:
295
+
296
+ ```bash
297
+ holivia highlight create \
298
+ --locale fr \
299
+ --highlight-type feature \
300
+ --title "New manager toolkit" \
301
+ --resource-url https://example.com/toolkit \
302
+ --cover-image cover.png
303
+ ```
304
+
305
+ Or create one with a document target:
306
+
307
+ ```bash
308
+ holivia highlight create \
309
+ --locale fr \
310
+ --title "Benefits guide" \
311
+ --document benefits-guide.pdf \
312
+ --cover-image cover.png
313
+ ```
314
+
315
+ Publish it:
316
+
317
+ ```bash
318
+ holivia highlight publish 123
319
+ ```
320
+
227
321
  ## Files And Uploads
228
322
 
229
323
  Selfcare create and update commands can upload images with `--image <path>`.
@@ -244,6 +338,10 @@ Communication item create and update commands upload the required document with
244
338
 
245
339
  Intervention item create and update commands can upload or replace the cover image with `--cover-image <path>`.
246
340
 
341
+ HR home highlight create and update commands require `--cover-image <path>` and exactly one target: either `--resource-url <url>` or `--document <path>`.
342
+
343
+ Crisis and collective intervention create and update commands accept nested contacts as repeated `--contact-json <json>` flags or through piped JSON with a `contacts_attributes` array.
344
+
247
345
  ## Development
248
346
 
249
347
  After checking out the repo, run:
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, HR intervention catalog items, and appointment video diagnostics.
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.
6
6
 
7
7
  ## Preconditions
8
8
 
@@ -19,7 +19,8 @@ Use `holivia` in examples below. If working from a checkout before installation,
19
19
  - Prefer interactive `holivia login` when a human can enter credentials. Use `--password` only when the user explicitly provides it for automation.
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
- - For destructive actions such as `holivia env remove` or `holivia selfcare objective delete`, confirm the target environment and ID first unless the user explicitly requested that exact action.
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
24
  - 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`.
24
25
 
25
26
  ## Installation
@@ -137,7 +138,15 @@ For intervention catalog work, discover the live schema first:
137
138
  holivia intervention schema
138
139
  ```
139
140
 
140
- Use the schema response for intervention types, modalities, audiences, durations, categories, states, and locales.
141
+ Use the schema response for intervention types, providers, modalities, audiences, durations, categories, states, and locales.
142
+
143
+ For HR home highlight work, discover the live schema first:
144
+
145
+ ```bash
146
+ holivia highlight schema
147
+ ```
148
+
149
+ Use the schema response for highlight types, states, and locales.
141
150
 
142
151
  ## Selfcare Content
143
152
 
@@ -278,6 +287,102 @@ holivia objective show 123
278
287
 
279
288
  Objective translated fields are returned in the default locale, currently `fr`.
280
289
 
290
+ ## Enterprises
291
+
292
+ Find an enterprise id:
293
+
294
+ ```bash
295
+ holivia enterprise lookup --query acme
296
+ ```
297
+
298
+ Filter enterprise lookup:
299
+
300
+ ```bash
301
+ holivia enterprise index --headquarter-id 10 --user-id 20 --page 1 --per-page 25
302
+ ```
303
+
304
+ ## Crises
305
+
306
+ List crises:
307
+
308
+ ```bash
309
+ holivia crisis index --enterprise-id 123 --status reported
310
+ ```
311
+
312
+ Show one crisis:
313
+
314
+ ```bash
315
+ holivia crisis show 42
316
+ ```
317
+
318
+ Create a crisis:
319
+
320
+ ```bash
321
+ holivia crisis create \
322
+ --enterprise-id 123 \
323
+ --title "Critical site situation" \
324
+ --description "A manager reported an urgent situation." \
325
+ --contact-json '{"first_name":"Marie","last_name":"Dupont","phone":"+33612345678","email":"marie.dupont@example.com","job_title":"DRH"}'
326
+ ```
327
+
328
+ Update crisis status:
329
+
330
+ ```bash
331
+ holivia crisis update 42 --status resolved
332
+ ```
333
+
334
+ Delete a crisis:
335
+
336
+ ```bash
337
+ holivia crisis delete 42
338
+ ```
339
+
340
+ Status values are `reported`, `in_progress`, and `resolved`.
341
+
342
+ ## Collective Interventions
343
+
344
+ List collective interventions:
345
+
346
+ ```bash
347
+ holivia collective-intervention index --enterprise-id 123 --status submitted
348
+ ```
349
+
350
+ Show one collective intervention:
351
+
352
+ ```bash
353
+ holivia collective-intervention show 42
354
+ ```
355
+
356
+ Create a collective intervention:
357
+
358
+ ```bash
359
+ holivia collective-intervention create \
360
+ --enterprise-id 123 \
361
+ --intervention-item-id 456 \
362
+ --title "Manager workshop for Paris" \
363
+ --description "Collective support for a management team." \
364
+ --location "12 rue de la Paix, 75002 Paris" \
365
+ --scheduled-starts-at "2026-08-01T09:00:00Z" \
366
+ --scheduled-ends-at "2026-08-01T11:00:00Z" \
367
+ --contact-json '{"first_name":"Marie","last_name":"Dupont","phone":"+33612345678","email":"marie.dupont@example.com","job_title":"DRH"}'
368
+ ```
369
+
370
+ Schedule or complete a collective intervention:
371
+
372
+ ```bash
373
+ holivia collective-intervention update 42 --status scheduled
374
+ holivia collective-intervention update 42 --status completed
375
+ ```
376
+
377
+ Delete a collective intervention:
378
+
379
+ ```bash
380
+ holivia collective-intervention delete 42
381
+ ```
382
+
383
+ Status values are `submitted`, `scheduled`, `in_progress`, `completed`, and `canceled`.
384
+ Use piped JSON instead of `--contact-json` when the payload has multiple contacts or long text.
385
+
281
386
  ## Intervention Items
282
387
 
283
388
  List intervention catalog items:
@@ -286,10 +391,16 @@ List intervention catalog items:
286
391
  holivia intervention index --locale fr --state published
287
392
  ```
288
393
 
394
+ Filter by provider:
395
+
396
+ ```bash
397
+ holivia intervention index --locale fr --provider wpo --state published
398
+ ```
399
+
289
400
  Filter by catalog metadata:
290
401
 
291
402
  ```bash
292
- holivia intervention index --query burnout --category raise_awareness_train --intervention-type workshop
403
+ holivia intervention index --query burnout --provider wpo --category raise_awareness_train --intervention-type workshop
293
404
  ```
294
405
 
295
406
  Show one intervention item:
@@ -303,6 +414,7 @@ Create an intervention item:
303
414
  ```bash
304
415
  holivia intervention create \
305
416
  --locale fr \
417
+ --provider wpo \
306
418
  --title "Manager burnout workshop" \
307
419
  --intervention-type workshop \
308
420
  --category raise_awareness_train \
@@ -318,13 +430,13 @@ holivia intervention create \
318
430
  Create or update from JSON for complex multiline text:
319
431
 
320
432
  ```bash
321
- printf '{"locale":"fr","title":"Team audit","intervention_type":"audit","category":"audit_diagnose","modalities":["online"],"audience":["hr"]}' | holivia intervention create
433
+ printf '{"locale":"fr","provider":"wpo","title":"Team audit","intervention_type":"audit","category":"audit_diagnose","modalities":["online"],"audience":["hr"]}' | holivia intervention create
322
434
  ```
323
435
 
324
436
  Update one localized item:
325
437
 
326
438
  ```bash
327
- holivia intervention update 123 --title "Updated title" --modality in_person
439
+ holivia intervention update 123 --provider holivia --title "Updated title" --modality in_person
328
440
  ```
329
441
 
330
442
  Publish or unpublish one localized item:
@@ -340,6 +452,66 @@ Delete one localized item:
340
452
  holivia intervention delete 123
341
453
  ```
342
454
 
455
+ ## HR Home Highlights
456
+
457
+ List HR home highlights:
458
+
459
+ ```bash
460
+ holivia highlight index --locale fr --state published
461
+ ```
462
+
463
+ Filter by highlight metadata:
464
+
465
+ ```bash
466
+ holivia highlight index --query toolkit --locale fr --highlight-type feature --state published
467
+ ```
468
+
469
+ Show one highlight:
470
+
471
+ ```bash
472
+ holivia highlight show 123
473
+ ```
474
+
475
+ Create a highlight that points to a URL:
476
+
477
+ ```bash
478
+ holivia highlight create \
479
+ --locale fr \
480
+ --highlight-type feature \
481
+ --title "Manager toolkit" \
482
+ --resource-url https://example.com/toolkit \
483
+ --cover-image cover.png
484
+ ```
485
+
486
+ Create a highlight that points to an uploaded document:
487
+
488
+ ```bash
489
+ holivia highlight create \
490
+ --locale fr \
491
+ --title "Benefits guide" \
492
+ --document benefits-guide.pdf \
493
+ --cover-image cover.png
494
+ ```
495
+
496
+ Create or update from JSON for metadata-only changes:
497
+
498
+ ```bash
499
+ printf '{"locale":"fr","title":"Manager toolkit","resource_url":"https://example.com/toolkit"}' | holivia highlight create
500
+ ```
501
+
502
+ Publish or unpublish one localized highlight:
503
+
504
+ ```bash
505
+ holivia highlight publish 123
506
+ holivia highlight unpublish 123
507
+ ```
508
+
509
+ Delete one localized highlight:
510
+
511
+ ```bash
512
+ holivia highlight delete 123
513
+ ```
514
+
343
515
  ## Selfcare Objective Associations
344
516
 
345
517
  List associations:
@@ -405,6 +577,8 @@ Before making API changes:
405
577
  - Run `holivia env` and verify the active URL/environment.
406
578
  - Run `holivia selfcare schema` before selfcare create/update/compose work.
407
579
  - Run `holivia intervention schema` before intervention create/update work.
580
+ - Run `holivia highlight schema` before highlight create/update work.
581
+ - Run `holivia enterprise lookup --query <name>` when you need an `enterprise_id`.
408
582
  - Use existing IDs from list/show commands or explicit user input.
409
583
  - Prefer draft states unless the user explicitly requests publishing.
410
584
  - Use JSON files or stdin for complex payloads.
@@ -49,6 +49,11 @@ module Holivia
49
49
  holivia objective show <id> Show one objective
50
50
  Translated fields are returned in the default locale (fr).
51
51
 
52
+ Enterprises:
53
+ holivia enterprise index [--query TEXT --headquarter-id ID --user-id ID --page N --per-page N]
54
+ Find enterprises and their enterprise_id values
55
+ holivia enterprise lookup [options] Alias for enterprise index
56
+
52
57
  Communication Items:
53
58
  holivia communication index [--page N --per-page N --query TEXT --locale LOCALE --document-type TYPE]
54
59
  List communication library items
@@ -62,9 +67,10 @@ module Holivia
62
67
 
63
68
  Intervention Items:
64
69
  holivia intervention index [--page N --per-page N --query TEXT --locale LOCALE --state STATE
65
- --category KEY --translation-group-id UUID --intervention-type TYPE]
70
+ --provider PROVIDER --category KEY --translation-group-id UUID
71
+ --intervention-type TYPE]
66
72
  List HR intervention catalog items
67
- holivia intervention schema Show allowed intervention enum values and locales
73
+ holivia intervention schema Show allowed intervention enum values, providers, and locales
68
74
  holivia intervention show <id> Show one intervention item
69
75
  holivia intervention create [options] Create one localized intervention item
70
76
  holivia intervention update <id> [options] Update one localized intervention item
@@ -72,6 +78,36 @@ module Holivia
72
78
  holivia intervention unpublish <id> Unpublish one intervention item
73
79
  holivia intervention delete <id> Delete one localized intervention item
74
80
 
81
+ HR Home Highlights:
82
+ holivia highlight index [--page N --per-page N --query TEXT --locale LOCALE
83
+ --highlight-type TYPE --state STATE]
84
+ List HR home highlights
85
+ holivia highlight schema Show allowed highlight_types, states, and locales
86
+ holivia highlight show <id> Show one HR home highlight
87
+ holivia highlight create [options] Create one localized HR home highlight
88
+ holivia highlight update <id> [options] Update one localized HR home highlight
89
+ holivia highlight publish <id> Publish one HR home highlight
90
+ holivia highlight unpublish <id> Unpublish one HR home highlight
91
+ holivia highlight delete <id> Delete one localized HR home highlight
92
+
93
+ Crises:
94
+ holivia crisis index [--enterprise-id ID --status STATUS --page N --per-page N]
95
+ List crises
96
+ holivia crisis show <id> Show one crisis
97
+ holivia crisis create [options] Create a crisis
98
+ holivia crisis update <id> [options] Update a crisis
99
+ holivia crisis delete <id> Delete a crisis
100
+ Status values: reported, in_progress, resolved.
101
+
102
+ Collective Interventions:
103
+ holivia collective-intervention index [--enterprise-id ID --status STATUS --page N --per-page N]
104
+ List collective interventions
105
+ holivia collective-intervention show <id> Show one collective intervention
106
+ holivia collective-intervention create [options] Create a collective intervention
107
+ holivia collective-intervention update <id> [options] Update a collective intervention
108
+ holivia collective-intervention delete <id> Delete a collective intervention
109
+ Status values: submitted, scheduled, in_progress, completed, canceled.
110
+
75
111
  Appointments:
76
112
  holivia appointment video-diagnostics <id> Show video diagnostics for an appointment
77
113
 
@@ -115,6 +151,9 @@ module Holivia
115
151
  Communication uploads use --document <path> and optional --cover-image <path>.
116
152
  The API validates accepted communication upload formats and file sizes.
117
153
  Intervention cover images use --cover-image <path> on intervention create/update.
154
+ Highlight uploads use required --cover-image <path> and either --resource-url URL or --document <path>.
155
+ Crisis and collective intervention contacts can be passed as repeated --contact-json JSON flags,
156
+ or as "contacts_attributes": [...] in piped JSON.
118
157
  Compose is JSON-only — to attach an image to a composed tree, PATCH the returned id:
119
158
  holivia selfcare update <id> --image <path>
120
159
 
@@ -129,6 +168,8 @@ module Holivia
129
168
  values — it is the source of truth.
130
169
  Run holivia intervention schema before creating or updating intervention items
131
170
  to discover current intervention enum values and locales.
171
+ Run holivia highlight schema before creating or updating HR home highlights
172
+ to discover current highlight types, states, and locales.
132
173
 
133
174
  Version:
134
175
  holivia version Print version
data/lib/holivia/cli.rb CHANGED
@@ -12,10 +12,14 @@ require_relative "commands/objective"
12
12
  require_relative "commands/appointment"
13
13
  require_relative "commands/communication_item"
14
14
  require_relative "commands/intervention_item"
15
+ require_relative "commands/hr_home_highlight"
16
+ require_relative "commands/enterprise"
17
+ require_relative "commands/crisis"
18
+ require_relative "commands/collective_intervention"
15
19
 
16
20
  module Holivia
17
21
  class CLI
18
- def self.start(args) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
22
+ def self.start(args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
19
23
  command = args.shift
20
24
  case command
21
25
  when "login" then Commands::Auth.new.login(args)
@@ -26,6 +30,10 @@ module Holivia
26
30
  when "appointment" then Commands::Appointment.route(args)
27
31
  when "communication" then Commands::CommunicationItem.route(args)
28
32
  when "intervention" then Commands::InterventionItem.route(args)
33
+ when "highlight" then Commands::HrHomeHighlight.route(args)
34
+ when "enterprise" then Commands::Enterprise.route(args)
35
+ when "crisis" then Commands::Crisis.route(args)
36
+ when "collective-intervention", "collective_intervention", "collective" then Commands::CollectiveIntervention.route(args)
29
37
  when "version", "--version", "-v" then puts "holivia #{Holivia::VERSION}"
30
38
  when "--help", "-h", nil then puts Help::HELP_TEXT
31
39
  else warn "Unknown command: #{command}"
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Holivia
6
+ module Commands
7
+ class CollectiveIntervention < Base
8
+ BASE_PATH = "/api/v1/backoffice/collective_interventions"
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
+ when "create" then new.create(args)
16
+ when "update" then new.update(args)
17
+ when "delete" then new.delete(args)
18
+ else warn "Unknown collective intervention command: #{subcommand}"
19
+ exit 1
20
+ end
21
+ end
22
+
23
+ def index(args = [])
24
+ params = {}
25
+ OptionParser.new do |opts|
26
+ opts.banner = "Usage: holivia collective-intervention index [options]"
27
+ opts.on("--enterprise-id ID", Integer) { |v| params[:enterprise_id] = v }
28
+ opts.on("--status STATUS") { |v| params[:status] = v }
29
+ opts.on("--page N", Integer) { |v| params[:page] = v }
30
+ opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
31
+ end.parse!(args)
32
+
33
+ output(client.get(BASE_PATH, params: params))
34
+ end
35
+
36
+ def show(args = [])
37
+ id = args.shift
38
+ abort "Usage: holivia collective-intervention show <id>" unless id
39
+
40
+ output(client.get("#{BASE_PATH}/#{id}"))
41
+ end
42
+
43
+ def create(args = [])
44
+ options = parse_write_options(args, "Usage: holivia collective-intervention create [options]")
45
+ abort "No options provided. Use --help for usage." if options.empty?
46
+
47
+ output(client.post(BASE_PATH, body: options))
48
+ end
49
+
50
+ def update(args = [])
51
+ id = args.shift
52
+ abort "Usage: holivia collective-intervention update <id> [options]" unless id
53
+
54
+ options = parse_write_options(args, "Usage: holivia collective-intervention update <id> [options]")
55
+ abort "No options provided. Use --help for usage." if options.empty?
56
+
57
+ output(client.patch("#{BASE_PATH}/#{id}", body: options))
58
+ end
59
+
60
+ def delete(args = [])
61
+ id = args.shift
62
+ abort "Usage: holivia collective-intervention delete <id>" unless id
63
+
64
+ client.delete("#{BASE_PATH}/#{id}")
65
+ output(deleted: true, id: id.to_i)
66
+ end
67
+
68
+ private
69
+
70
+ def parse_write_options(args, banner) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
71
+ options = {}
72
+ OptionParser.new do |opts|
73
+ opts.banner = banner
74
+ opts.on("--enterprise-id ID", Integer) { |v| options[:enterprise_id] = v }
75
+ opts.on("--intervention-item-id ID", Integer) { |v| options[:intervention_item_id] = v }
76
+ opts.on("--title TITLE") { |v| options[:title] = v }
77
+ opts.on("--description DESC") { |v| options[:description] = v }
78
+ opts.on("--location LOCATION") { |v| options[:location] = v }
79
+ opts.on("--scheduled-starts-at TIME") { |v| options[:scheduled_starts_at] = v }
80
+ opts.on("--scheduled-ends-at TIME") { |v| options[:scheduled_ends_at] = v }
81
+ opts.on("--status STATUS") { |v| options[:status] = v }
82
+ opts.on("--contact-json JSON") { |v| append_contact(options, v) }
83
+ end.parse!(args)
84
+ options.merge(piped_json)
85
+ end
86
+
87
+ def append_contact(options, json)
88
+ options[:contacts_attributes] ||= []
89
+ options[:contacts_attributes] << JSON.parse(json, symbolize_names: true)
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Holivia
6
+ module Commands
7
+ class Crisis < Base
8
+ BASE_PATH = "/api/v1/backoffice/crises"
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
+ when "create" then new.create(args)
16
+ when "update" then new.update(args)
17
+ when "delete" then new.delete(args)
18
+ else warn "Unknown crisis command: #{subcommand}"
19
+ exit 1
20
+ end
21
+ end
22
+
23
+ def index(args = [])
24
+ params = {}
25
+ OptionParser.new do |opts|
26
+ opts.banner = "Usage: holivia crisis index [options]"
27
+ opts.on("--enterprise-id ID", Integer) { |v| params[:enterprise_id] = v }
28
+ opts.on("--status STATUS") { |v| params[:status] = v }
29
+ opts.on("--page N", Integer) { |v| params[:page] = v }
30
+ opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
31
+ end.parse!(args)
32
+
33
+ output(client.get(BASE_PATH, params: params))
34
+ end
35
+
36
+ def show(args = [])
37
+ id = args.shift
38
+ abort "Usage: holivia crisis show <id>" unless id
39
+
40
+ output(client.get("#{BASE_PATH}/#{id}"))
41
+ end
42
+
43
+ def create(args = [])
44
+ options = parse_write_options(args, "Usage: holivia crisis create [options]")
45
+ abort "No options provided. Use --help for usage." if options.empty?
46
+
47
+ output(client.post(BASE_PATH, body: options))
48
+ end
49
+
50
+ def update(args = [])
51
+ id = args.shift
52
+ abort "Usage: holivia crisis update <id> [options]" unless id
53
+
54
+ options = parse_write_options(args, "Usage: holivia crisis update <id> [options]")
55
+ abort "No options provided. Use --help for usage." if options.empty?
56
+
57
+ output(client.patch("#{BASE_PATH}/#{id}", body: options))
58
+ end
59
+
60
+ def delete(args = [])
61
+ id = args.shift
62
+ abort "Usage: holivia crisis delete <id>" unless id
63
+
64
+ client.delete("#{BASE_PATH}/#{id}")
65
+ output(deleted: true, id: id.to_i)
66
+ end
67
+
68
+ private
69
+
70
+ def parse_write_options(args, banner)
71
+ options = {}
72
+ OptionParser.new do |opts|
73
+ opts.banner = banner
74
+ opts.on("--enterprise-id ID", Integer) { |v| options[:enterprise_id] = v }
75
+ opts.on("--title TITLE") { |v| options[:title] = v }
76
+ opts.on("--description DESC") { |v| options[:description] = v }
77
+ opts.on("--status STATUS") { |v| options[:status] = v }
78
+ opts.on("--contact-json JSON") { |v| append_contact(options, v) }
79
+ end.parse!(args)
80
+ options.merge(piped_json)
81
+ end
82
+
83
+ def append_contact(options, json)
84
+ options[:contacts_attributes] ||= []
85
+ options[:contacts_attributes] << JSON.parse(json, symbolize_names: true)
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Holivia
6
+ module Commands
7
+ class Enterprise < Base
8
+ BASE_PATH = "/api/v1/backoffice/enterprises"
9
+
10
+ def self.route(args)
11
+ subcommand = args.shift
12
+ case subcommand
13
+ when "index", "lookup", "search" then new.index(args)
14
+ else warn "Unknown enterprise command: #{subcommand}"
15
+ exit 1
16
+ end
17
+ end
18
+
19
+ def index(args = []) # rubocop:disable Metrics/AbcSize
20
+ params = {}
21
+ OptionParser.new do |opts|
22
+ opts.banner = "Usage: holivia enterprise index [options]"
23
+ opts.on("--query TEXT") { |v| params[:query] = v }
24
+ opts.on("--headquarter-id ID", Integer) { |v| params[:headquarter_id] = v }
25
+ opts.on("--user-id ID", Integer) { |v| params[:user_id] = 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
+ end
33
+ end
34
+ end
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Holivia
6
+ module Commands
7
+ class HrHomeHighlight < Base # rubocop:disable Metrics/ClassLength
8
+ BASE_PATH = "/api/v1/backoffice/hr_home_highlights"
9
+ CONTENT_TYPE_BY_EXTENSION = {
10
+ ".gif" => "image/gif",
11
+ ".jpeg" => "image/jpeg",
12
+ ".jpg" => "image/jpeg",
13
+ ".mov" => "video/quicktime",
14
+ ".mp4" => "video/mp4",
15
+ ".pdf" => "application/pdf",
16
+ ".png" => "image/png",
17
+ ".ppt" => "application/vnd.ms-powerpoint",
18
+ ".pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
19
+ ".webm" => "video/webm",
20
+ ".webp" => "image/webp",
21
+ ".zip" => "application/zip"
22
+ }.freeze
23
+
24
+ def self.route(args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
25
+ subcommand = args.shift
26
+ case subcommand
27
+ when "index" then new.index(args)
28
+ when "show" then new.show(args)
29
+ when "create" then new.create(args)
30
+ when "update" then new.update(args)
31
+ when "publish" then new.publish(args)
32
+ when "unpublish" then new.unpublish(args)
33
+ when "delete" then new.delete(args)
34
+ when "schema" then new.schema(args)
35
+ else warn "Unknown highlight command: #{subcommand}"
36
+ exit 1
37
+ end
38
+ end
39
+
40
+ def index(args = []) # rubocop:disable Metrics/AbcSize
41
+ params = {}
42
+ OptionParser.new do |opts|
43
+ opts.banner = "Usage: holivia highlight index [options]"
44
+ opts.on("--page N", Integer) { |v| params[:page] = v }
45
+ opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
46
+ opts.on("--query TEXT") { |v| params[:query] = v }
47
+ opts.on("--locale LOCALE") { |v| params[:locale] = v }
48
+ opts.on("--highlight-type TYPE") { |v| params[:highlight_type] = v }
49
+ opts.on("--state STATE") { |v| params[:state] = v }
50
+ end.parse!(args)
51
+
52
+ output(client.get(BASE_PATH, params: params))
53
+ end
54
+
55
+ def show(args = [])
56
+ id = args.shift
57
+ abort "Usage: holivia highlight show <id>" unless id
58
+
59
+ output(client.get("#{BASE_PATH}/#{id}"))
60
+ end
61
+
62
+ def create(args = [])
63
+ options = {}
64
+ OptionParser.new do |opts|
65
+ opts.banner = "Usage: holivia highlight create [options]"
66
+ add_write_options(opts, options)
67
+ end.parse!(args)
68
+ options = options.merge(piped_json)
69
+
70
+ abort "No options provided. Use --help for usage." if options.empty?
71
+ output(client.post(BASE_PATH, body: build_body(options)))
72
+ end
73
+
74
+ def update(args = [])
75
+ id = args.shift
76
+ abort "Usage: holivia highlight update <id> [options]" unless id
77
+
78
+ options = {}
79
+ OptionParser.new do |opts|
80
+ opts.banner = "Usage: holivia highlight update <id> [options]"
81
+ add_write_options(opts, options)
82
+ end.parse!(args)
83
+ options = options.merge(piped_json)
84
+
85
+ abort "No options provided. Use --help for usage." if options.empty?
86
+ output(client.patch("#{BASE_PATH}/#{id}", body: build_body(options)))
87
+ end
88
+
89
+ def publish(args = [])
90
+ transition(args, "publish")
91
+ end
92
+
93
+ def unpublish(args = [])
94
+ transition(args, "unpublish")
95
+ end
96
+
97
+ def delete(args = [])
98
+ id = args.shift
99
+ abort "Usage: holivia highlight delete <id>" unless id
100
+
101
+ client.delete("#{BASE_PATH}/#{id}")
102
+ output(deleted: true, id: id.to_i)
103
+ end
104
+
105
+ def schema(_args = [])
106
+ output(client.get("#{BASE_PATH}/schema"))
107
+ end
108
+
109
+ private
110
+
111
+ def add_write_options(opts, options)
112
+ opts.on("--translation-group-id UUID") { |v| options[:translation_group_id] = v }
113
+ opts.on("--locale LOCALE") { |v| options[:locale] = v }
114
+ opts.on("--highlight-type TYPE") { |v| options[:highlight_type] = v }
115
+ opts.on("--title TITLE") { |v| options[:title] = v }
116
+ opts.on("--resource-url URL") { |v| options[:resource_url] = v }
117
+ opts.on("--cover-image FILE") { |v| options[:cover_image] = v }
118
+ opts.on("--document FILE") { |v| options[:document] = v }
119
+ end
120
+
121
+ def transition(args, event)
122
+ id = args.shift
123
+ abort "Usage: holivia highlight #{event} <id>" unless id
124
+
125
+ output(client.patch("#{BASE_PATH}/#{id}/#{event}"))
126
+ end
127
+
128
+ def build_body(options)
129
+ options = options.dup
130
+ attach_file_part(options, :cover_image)
131
+ attach_file_part(options, :document)
132
+ options
133
+ end
134
+
135
+ def attach_file_part(options, key)
136
+ path = options[key]
137
+ return unless path
138
+
139
+ options[key] = Faraday::Multipart::FilePart.new(path, detect_mime(path))
140
+ end
141
+
142
+ def detect_mime(path)
143
+ CONTENT_TYPE_BY_EXTENSION.fetch(File.extname(path).downcase, "application/octet-stream")
144
+ end
145
+ end
146
+ end
147
+ end
@@ -38,6 +38,7 @@ module Holivia
38
38
  opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
39
39
  opts.on("--query TEXT") { |v| params[:query] = v }
40
40
  opts.on("--locale LOCALE") { |v| params[:locale] = v }
41
+ opts.on("--provider PROVIDER") { |v| params[:provider] = v }
41
42
  opts.on("--state STATE") { |v| params[:state] = v }
42
43
  opts.on("--category CATEGORY") { |v| params[:category] = v }
43
44
  opts.on("--translation-group-id UUID") { |v| params[:translation_group_id] = v }
@@ -106,6 +107,7 @@ module Holivia
106
107
  def add_write_options(opts, options) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
107
108
  opts.on("--translation-group-id UUID") { |v| options[:translation_group_id] = v }
108
109
  opts.on("--locale LOCALE") { |v| options[:locale] = v }
110
+ opts.on("--provider PROVIDER") { |v| options[:provider] = v }
109
111
  opts.on("--title TITLE") { |v| options[:title] = v }
110
112
  opts.on("--description DESC") { |v| options[:description] = v }
111
113
  opts.on("--program PROGRAM") { |v| options[:program] = v }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Holivia
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Holivia
@@ -65,9 +65,13 @@ files:
65
65
  - lib/holivia/commands/appointment.rb
66
66
  - lib/holivia/commands/auth.rb
67
67
  - lib/holivia/commands/base.rb
68
+ - lib/holivia/commands/collective_intervention.rb
68
69
  - lib/holivia/commands/communication_item.rb
70
+ - lib/holivia/commands/crisis.rb
71
+ - lib/holivia/commands/enterprise.rb
69
72
  - lib/holivia/commands/env.rb
70
73
  - lib/holivia/commands/format.rb
74
+ - lib/holivia/commands/hr_home_highlight.rb
71
75
  - lib/holivia/commands/intervention_item.rb
72
76
  - lib/holivia/commands/item.rb
73
77
  - lib/holivia/commands/objective.rb