holivia 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +63 -1
- data/SKILL.md +73 -1
- data/lib/holivia/cli/help.rb +29 -1
- data/lib/holivia/cli.rb +4 -0
- data/lib/holivia/commands/communication_item.rb +145 -0
- data/lib/holivia/commands/intervention_item.rb +152 -0
- data/lib/holivia/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37fbbbbc00a19fce307307f0d0d0465383b83759a1bbb30977131edfff1c3a98
|
|
4
|
+
data.tar.gz: 0241e8e1ece96ea66fdabe38c188e2914f071a26d225a778a6373c1a5c74fb64
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b310a7ef0b2f389a796a352d60455b33798c796821577623686b6658030d7716d4b7445fbac599630f5cf39d0ddc5db3c32d2ac3930dde8ec5692b37b3f300a8
|
|
7
|
+
data.tar.gz: 13a99d2b9dd8e0b27e2bc3ad941d9e7756f8b629d30b347f13785f818f58db8df1c460fed7518b6b458a9752323028ed67e0325ab8448a8da39fd09f76884044
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.8.0] - 2026-07-07
|
|
4
|
+
|
|
5
|
+
- Add `holivia intervention` commands for HR intervention catalog CRUD, publishing, schema discovery, and cover image uploads
|
|
6
|
+
|
|
7
|
+
## [0.7.0] - 2026-07-02
|
|
8
|
+
|
|
9
|
+
- Add `holivia communication` commands for communication library CRUD, publishing, schema discovery, and document/cover uploads
|
|
10
|
+
|
|
3
11
|
## [0.6.0] - 2026-06-05
|
|
4
12
|
|
|
5
13
|
- Add `holivia appointment video-diagnostics <id>` for appointment video diagnostics
|
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, and appointment diagnostics.
|
|
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.
|
|
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,64 @@ Show video diagnostics for an appointment:
|
|
|
166
166
|
holivia appointment video-diagnostics 42
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
+
List communication library items:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
holivia communication index --locale fr --document-type poster
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Create a communication item:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
holivia communication create \
|
|
179
|
+
--title "Launch poster" \
|
|
180
|
+
--locale fr \
|
|
181
|
+
--document-type poster \
|
|
182
|
+
--document launch-poster.pdf \
|
|
183
|
+
--cover-image cover.png
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Publish it:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
holivia communication publish 123
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Discover intervention catalog enum values and locales:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
holivia intervention schema
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
List intervention catalog items:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
holivia intervention index --locale fr --state published --category audit_diagnose
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Create an intervention item:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
holivia intervention create \
|
|
208
|
+
--locale fr \
|
|
209
|
+
--title "Manager burnout workshop" \
|
|
210
|
+
--intervention-type workshop \
|
|
211
|
+
--category raise_awareness_train \
|
|
212
|
+
--duration 90_min \
|
|
213
|
+
--short-outcome "Spot warning signs" \
|
|
214
|
+
--short-outcome "Choose support routines" \
|
|
215
|
+
--long-outcome "Map team risks" \
|
|
216
|
+
--modality online \
|
|
217
|
+
--audience managers \
|
|
218
|
+
--cover-image cover.png
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Publish it:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
holivia intervention publish 123
|
|
225
|
+
```
|
|
226
|
+
|
|
169
227
|
## Files And Uploads
|
|
170
228
|
|
|
171
229
|
Selfcare create and update commands can upload images with `--image <path>`.
|
|
@@ -182,6 +240,10 @@ holivia selfcare item create --slide-id 456 --item-type AudioItem --audio medita
|
|
|
182
240
|
|
|
183
241
|
Compose is JSON-only. To attach an image to a composed content tree, update the returned content id afterward with `holivia selfcare update <id> --image <path>`.
|
|
184
242
|
|
|
243
|
+
Communication item create and update commands upload the required document with `--document <path>` and can upload or replace the cover image with `--cover-image <path>`.
|
|
244
|
+
|
|
245
|
+
Intervention item create and update commands can upload or replace the cover image with `--cover-image <path>`.
|
|
246
|
+
|
|
185
247
|
## Development
|
|
186
248
|
|
|
187
249
|
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, and appointment video diagnostics.
|
|
5
|
+
The CLI manages Holivia backoffice data: environments, authentication, selfcare contents, objectives, selfcare-objective associations, HR intervention catalog items, and appointment video diagnostics.
|
|
6
6
|
|
|
7
7
|
## Preconditions
|
|
8
8
|
|
|
@@ -18,6 +18,7 @@ Use `holivia` in examples below. If working from a checkout before installation,
|
|
|
18
18
|
- Never print, store, or commit passwords, access tokens, refresh tokens, or files under `~/.holivia/credentials.*.json`.
|
|
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
|
+
- Before creating or updating intervention catalog items, run `holivia intervention schema` and use its returned enum values and locales as the source of truth.
|
|
21
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
23
|
- 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`.
|
|
23
24
|
|
|
@@ -130,6 +131,14 @@ Use the schema response for:
|
|
|
130
131
|
- objective tiers
|
|
131
132
|
- item-specific permitted params
|
|
132
133
|
|
|
134
|
+
For intervention catalog work, discover the live schema first:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
holivia intervention schema
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Use the schema response for intervention types, modalities, audiences, durations, categories, states, and locales.
|
|
141
|
+
|
|
133
142
|
## Selfcare Content
|
|
134
143
|
|
|
135
144
|
List contents:
|
|
@@ -269,6 +278,68 @@ holivia objective show 123
|
|
|
269
278
|
|
|
270
279
|
Objective translated fields are returned in the default locale, currently `fr`.
|
|
271
280
|
|
|
281
|
+
## Intervention Items
|
|
282
|
+
|
|
283
|
+
List intervention catalog items:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
holivia intervention index --locale fr --state published
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Filter by catalog metadata:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
holivia intervention index --query burnout --category raise_awareness_train --intervention-type workshop
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Show one intervention item:
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
holivia intervention show 123
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Create an intervention item:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
holivia intervention create \
|
|
305
|
+
--locale fr \
|
|
306
|
+
--title "Manager burnout workshop" \
|
|
307
|
+
--intervention-type workshop \
|
|
308
|
+
--category raise_awareness_train \
|
|
309
|
+
--duration 90_min \
|
|
310
|
+
--short-outcome "Spot warning signs" \
|
|
311
|
+
--short-outcome "Choose support routines" \
|
|
312
|
+
--long-outcome "Map team risks" \
|
|
313
|
+
--modality online \
|
|
314
|
+
--audience managers \
|
|
315
|
+
--cover-image cover.png
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Create or update from JSON for complex multiline text:
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
printf '{"locale":"fr","title":"Team audit","intervention_type":"audit","category":"audit_diagnose","modalities":["online"],"audience":["hr"]}' | holivia intervention create
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Update one localized item:
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
holivia intervention update 123 --title "Updated title" --modality in_person
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Publish or unpublish one localized item:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
holivia intervention publish 123
|
|
334
|
+
holivia intervention unpublish 123
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Delete one localized item:
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
holivia intervention delete 123
|
|
341
|
+
```
|
|
342
|
+
|
|
272
343
|
## Selfcare Objective Associations
|
|
273
344
|
|
|
274
345
|
List associations:
|
|
@@ -333,6 +404,7 @@ Before making API changes:
|
|
|
333
404
|
|
|
334
405
|
- Run `holivia env` and verify the active URL/environment.
|
|
335
406
|
- Run `holivia selfcare schema` before selfcare create/update/compose work.
|
|
407
|
+
- Run `holivia intervention schema` before intervention create/update work.
|
|
336
408
|
- Use existing IDs from list/show commands or explicit user input.
|
|
337
409
|
- Prefer draft states unless the user explicitly requests publishing.
|
|
338
410
|
- Use JSON files or stdin for complex payloads.
|
data/lib/holivia/cli/help.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Holivia
|
|
4
4
|
class CLI
|
|
5
|
-
module Help
|
|
5
|
+
module Help # rubocop:disable Metrics/ModuleLength
|
|
6
6
|
HELP_TEXT = <<~HELP
|
|
7
7
|
HOLIVIA CLI
|
|
8
8
|
===========
|
|
@@ -49,6 +49,29 @@ 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
|
+
Communication Items:
|
|
53
|
+
holivia communication index [--page N --per-page N --query TEXT --locale LOCALE --document-type TYPE]
|
|
54
|
+
List communication library items
|
|
55
|
+
holivia communication show <id> Show one communication item
|
|
56
|
+
holivia communication create [options] Create a communication item with a required document upload
|
|
57
|
+
holivia communication update <id> [options] Update metadata or replace uploads
|
|
58
|
+
holivia communication publish <id> Publish a draft communication item
|
|
59
|
+
holivia communication unpublish <id> Unpublish a communication item and clear published_at
|
|
60
|
+
holivia communication delete <id> Delete a communication item
|
|
61
|
+
holivia communication schema Show allowed document_types and locales
|
|
62
|
+
|
|
63
|
+
Intervention Items:
|
|
64
|
+
holivia intervention index [--page N --per-page N --query TEXT --locale LOCALE --state STATE
|
|
65
|
+
--category KEY --translation-group-id UUID --intervention-type TYPE]
|
|
66
|
+
List HR intervention catalog items
|
|
67
|
+
holivia intervention schema Show allowed intervention enum values and locales
|
|
68
|
+
holivia intervention show <id> Show one intervention item
|
|
69
|
+
holivia intervention create [options] Create one localized intervention item
|
|
70
|
+
holivia intervention update <id> [options] Update one localized intervention item
|
|
71
|
+
holivia intervention publish <id> Publish one intervention item
|
|
72
|
+
holivia intervention unpublish <id> Unpublish one intervention item
|
|
73
|
+
holivia intervention delete <id> Delete one localized intervention item
|
|
74
|
+
|
|
52
75
|
Appointments:
|
|
53
76
|
holivia appointment video-diagnostics <id> Show video diagnostics for an appointment
|
|
54
77
|
|
|
@@ -89,6 +112,9 @@ module Holivia
|
|
|
89
112
|
Accepted audio formats: MP3, MP4, WAV, OGG, FLAC, AAC, M4A, WebM. Max size: 100 MB.
|
|
90
113
|
Image uploads use --image <path> on selfcare create/update (sent as multipart/form-data).
|
|
91
114
|
Accepted image formats: JPEG, PNG, WebP, GIF. Max size: 5 MB.
|
|
115
|
+
Communication uploads use --document <path> and optional --cover-image <path>.
|
|
116
|
+
The API validates accepted communication upload formats and file sizes.
|
|
117
|
+
Intervention cover images use --cover-image <path> on intervention create/update.
|
|
92
118
|
Compose is JSON-only — to attach an image to a composed tree, PATCH the returned id:
|
|
93
119
|
holivia selfcare update <id> --image <path>
|
|
94
120
|
|
|
@@ -101,6 +127,8 @@ module Holivia
|
|
|
101
127
|
Run holivia selfcare schema to get current allowed values for all enums
|
|
102
128
|
and item types with their permitted params. Always use this over hardcoded
|
|
103
129
|
values — it is the source of truth.
|
|
130
|
+
Run holivia intervention schema before creating or updating intervention items
|
|
131
|
+
to discover current intervention enum values and locales.
|
|
104
132
|
|
|
105
133
|
Version:
|
|
106
134
|
holivia version Print version
|
data/lib/holivia/cli.rb
CHANGED
|
@@ -10,6 +10,8 @@ require_relative "commands/env"
|
|
|
10
10
|
require_relative "commands/item"
|
|
11
11
|
require_relative "commands/objective"
|
|
12
12
|
require_relative "commands/appointment"
|
|
13
|
+
require_relative "commands/communication_item"
|
|
14
|
+
require_relative "commands/intervention_item"
|
|
13
15
|
|
|
14
16
|
module Holivia
|
|
15
17
|
class CLI
|
|
@@ -22,6 +24,8 @@ module Holivia
|
|
|
22
24
|
when "selfcare" then Commands::Selfcare.route(args)
|
|
23
25
|
when "objective" then Commands::Objective.route(args)
|
|
24
26
|
when "appointment" then Commands::Appointment.route(args)
|
|
27
|
+
when "communication" then Commands::CommunicationItem.route(args)
|
|
28
|
+
when "intervention" then Commands::InterventionItem.route(args)
|
|
25
29
|
when "version", "--version", "-v" then puts "holivia #{Holivia::VERSION}"
|
|
26
30
|
when "--help", "-h", nil then puts Help::HELP_TEXT
|
|
27
31
|
else warn "Unknown command: #{command}"
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "base"
|
|
4
|
+
|
|
5
|
+
module Holivia
|
|
6
|
+
module Commands
|
|
7
|
+
class CommunicationItem < Base # rubocop:disable Metrics/ClassLength
|
|
8
|
+
BASE_PATH = "/api/v1/backoffice/communication_items"
|
|
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 communication 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 communication 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("--document-type TYPE") { |v| params[:document_type] = v }
|
|
49
|
+
end.parse!(args)
|
|
50
|
+
|
|
51
|
+
output(client.get(BASE_PATH, params: params))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def show(args = [])
|
|
55
|
+
id = args.shift
|
|
56
|
+
abort "Usage: holivia communication show <id>" unless id
|
|
57
|
+
|
|
58
|
+
output(client.get("#{BASE_PATH}/#{id}"))
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def create(args = [])
|
|
62
|
+
options = {}
|
|
63
|
+
OptionParser.new do |opts|
|
|
64
|
+
opts.banner = "Usage: holivia communication create [options]"
|
|
65
|
+
add_write_options(opts, options)
|
|
66
|
+
end.parse!(args)
|
|
67
|
+
options = options.merge(piped_json)
|
|
68
|
+
|
|
69
|
+
abort "No options provided. Use --help for usage." if options.empty?
|
|
70
|
+
output(client.post(BASE_PATH, body: build_body(options)))
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def update(args = [])
|
|
74
|
+
id = args.shift
|
|
75
|
+
abort "Usage: holivia communication update <id> [options]" unless id
|
|
76
|
+
|
|
77
|
+
options = {}
|
|
78
|
+
OptionParser.new do |opts|
|
|
79
|
+
opts.banner = "Usage: holivia communication update <id> [options]"
|
|
80
|
+
add_write_options(opts, options)
|
|
81
|
+
end.parse!(args)
|
|
82
|
+
options = options.merge(piped_json)
|
|
83
|
+
|
|
84
|
+
abort "No options provided. Use --help for usage." if options.empty?
|
|
85
|
+
output(client.patch("#{BASE_PATH}/#{id}", body: build_body(options)))
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def publish(args = [])
|
|
89
|
+
transition(args, "publish")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def unpublish(args = [])
|
|
93
|
+
transition(args, "unpublish")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def delete(args = [])
|
|
97
|
+
id = args.shift
|
|
98
|
+
abort "Usage: holivia communication delete <id>" unless id
|
|
99
|
+
|
|
100
|
+
client.delete("#{BASE_PATH}/#{id}")
|
|
101
|
+
output(deleted: true, id: id.to_i)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def schema(_args = [])
|
|
105
|
+
output(client.get("#{BASE_PATH}/schema"))
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
private
|
|
109
|
+
|
|
110
|
+
def add_write_options(opts, options)
|
|
111
|
+
opts.on("--title TITLE") { |v| options[:title] = v }
|
|
112
|
+
opts.on("--description DESC") { |v| options[:description] = v }
|
|
113
|
+
opts.on("--document-type TYPE") { |v| options[:document_type] = v }
|
|
114
|
+
opts.on("--locale LOCALE") { |v| options[:locale] = v }
|
|
115
|
+
opts.on("--cover-image FILE") { |v| options[:cover_image] = v }
|
|
116
|
+
opts.on("--document FILE") { |v| options[:document] = v }
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def transition(args, event)
|
|
120
|
+
id = args.shift
|
|
121
|
+
abort "Usage: holivia communication #{event} <id>" unless id
|
|
122
|
+
|
|
123
|
+
output(client.patch("#{BASE_PATH}/#{id}/#{event}"))
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def build_body(options)
|
|
127
|
+
options = options.dup
|
|
128
|
+
attach_file_part(options, :cover_image)
|
|
129
|
+
attach_file_part(options, :document)
|
|
130
|
+
options
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def attach_file_part(options, key)
|
|
134
|
+
path = options[key]
|
|
135
|
+
return unless path
|
|
136
|
+
|
|
137
|
+
options[key] = Faraday::Multipart::FilePart.new(path, detect_mime(path))
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def detect_mime(path)
|
|
141
|
+
CONTENT_TYPE_BY_EXTENSION.fetch(File.extname(path).downcase, "application/octet-stream")
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "base"
|
|
4
|
+
|
|
5
|
+
module Holivia
|
|
6
|
+
module Commands
|
|
7
|
+
class InterventionItem < Base # rubocop:disable Metrics/ClassLength
|
|
8
|
+
BASE_PATH = "/api/v1/backoffice/intervention_items"
|
|
9
|
+
IMAGE_MIME_TYPES = {
|
|
10
|
+
".gif" => "image/gif",
|
|
11
|
+
".jpeg" => "image/jpeg",
|
|
12
|
+
".jpg" => "image/jpeg",
|
|
13
|
+
".png" => "image/png",
|
|
14
|
+
".webp" => "image/webp"
|
|
15
|
+
}.freeze
|
|
16
|
+
|
|
17
|
+
def self.route(args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
|
|
18
|
+
subcommand = args.shift
|
|
19
|
+
case subcommand
|
|
20
|
+
when "index" then new.index(args)
|
|
21
|
+
when "schema" then new.schema(args)
|
|
22
|
+
when "show" then new.show(args)
|
|
23
|
+
when "create" then new.create(args)
|
|
24
|
+
when "update" then new.update(args)
|
|
25
|
+
when "publish" then new.publish(args)
|
|
26
|
+
when "unpublish" then new.unpublish(args)
|
|
27
|
+
when "delete" then new.delete(args)
|
|
28
|
+
else warn "Unknown intervention command: #{subcommand}"
|
|
29
|
+
exit 1
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def index(args = []) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
34
|
+
params = {}
|
|
35
|
+
OptionParser.new do |opts|
|
|
36
|
+
opts.banner = "Usage: holivia intervention index [options]"
|
|
37
|
+
opts.on("--page N", Integer) { |v| params[:page] = v }
|
|
38
|
+
opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
|
|
39
|
+
opts.on("--query TEXT") { |v| params[:query] = v }
|
|
40
|
+
opts.on("--locale LOCALE") { |v| params[:locale] = v }
|
|
41
|
+
opts.on("--state STATE") { |v| params[:state] = v }
|
|
42
|
+
opts.on("--category CATEGORY") { |v| params[:category] = v }
|
|
43
|
+
opts.on("--translation-group-id UUID") { |v| params[:translation_group_id] = v }
|
|
44
|
+
opts.on("--intervention-type TYPE") { |v| params[:intervention_type] = v }
|
|
45
|
+
end.parse!(args)
|
|
46
|
+
|
|
47
|
+
output(client.get(BASE_PATH, params: params))
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def schema(_args = [])
|
|
51
|
+
output(client.get("#{BASE_PATH}/schema"))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def show(args = [])
|
|
55
|
+
id = args.shift
|
|
56
|
+
abort "Usage: holivia intervention show <id>" unless id
|
|
57
|
+
|
|
58
|
+
output(client.get("#{BASE_PATH}/#{id}"))
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def create(args = [])
|
|
62
|
+
options = {}
|
|
63
|
+
OptionParser.new do |opts|
|
|
64
|
+
opts.banner = "Usage: holivia intervention create [options]"
|
|
65
|
+
add_write_options(opts, options)
|
|
66
|
+
end.parse!(args)
|
|
67
|
+
options = options.merge(piped_json)
|
|
68
|
+
|
|
69
|
+
abort "No options provided. Use --help for usage." if options.empty?
|
|
70
|
+
output(client.post(BASE_PATH, body: build_body(options)))
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def update(args = [])
|
|
74
|
+
id = args.shift
|
|
75
|
+
abort "Usage: holivia intervention update <id> [options]" unless id
|
|
76
|
+
|
|
77
|
+
options = {}
|
|
78
|
+
OptionParser.new do |opts|
|
|
79
|
+
opts.banner = "Usage: holivia intervention update <id> [options]"
|
|
80
|
+
add_write_options(opts, options)
|
|
81
|
+
end.parse!(args)
|
|
82
|
+
options = options.merge(piped_json)
|
|
83
|
+
|
|
84
|
+
abort "No options provided. Use --help for usage." if options.empty?
|
|
85
|
+
output(client.patch("#{BASE_PATH}/#{id}", body: build_body(options)))
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def publish(args = [])
|
|
89
|
+
transition(args, "publish")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def unpublish(args = [])
|
|
93
|
+
transition(args, "unpublish")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def delete(args = [])
|
|
97
|
+
id = args.shift
|
|
98
|
+
abort "Usage: holivia intervention delete <id>" unless id
|
|
99
|
+
|
|
100
|
+
client.delete("#{BASE_PATH}/#{id}")
|
|
101
|
+
output(deleted: true, id: id.to_i)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
private
|
|
105
|
+
|
|
106
|
+
def add_write_options(opts, options) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
107
|
+
opts.on("--translation-group-id UUID") { |v| options[:translation_group_id] = v }
|
|
108
|
+
opts.on("--locale LOCALE") { |v| options[:locale] = v }
|
|
109
|
+
opts.on("--title TITLE") { |v| options[:title] = v }
|
|
110
|
+
opts.on("--description DESC") { |v| options[:description] = v }
|
|
111
|
+
opts.on("--program PROGRAM") { |v| options[:program] = v }
|
|
112
|
+
opts.on("--intervention-type TYPE") { |v| options[:intervention_type] = v }
|
|
113
|
+
opts.on("--duration DURATION") { |v| options[:duration] = v }
|
|
114
|
+
opts.on("--category CATEGORY") { |v| options[:category] = v }
|
|
115
|
+
opts.on("--short-outcome TEXT") { |v| append_array_value(options, :short_outcomes, v) }
|
|
116
|
+
opts.on("--long-outcome TEXT") { |v| append_array_value(options, :long_outcomes, v) }
|
|
117
|
+
opts.on("--modality MODALITY") { |v| append_array_value(options, :modalities, v) }
|
|
118
|
+
opts.on("--audience AUDIENCE") { |v| append_array_value(options, :audience, v) }
|
|
119
|
+
opts.on("--cover-image FILE") { |v| options[:cover_image] = v }
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def append_array_value(options, key, value)
|
|
123
|
+
options[key] ||= []
|
|
124
|
+
options[key] << value
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def transition(args, event)
|
|
128
|
+
id = args.shift
|
|
129
|
+
abort "Usage: holivia intervention #{event} <id>" unless id
|
|
130
|
+
|
|
131
|
+
output(client.patch("#{BASE_PATH}/#{id}/#{event}"))
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def build_body(options)
|
|
135
|
+
options = options.dup
|
|
136
|
+
attach_cover_image(options)
|
|
137
|
+
options
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def attach_cover_image(options)
|
|
141
|
+
path = options[:cover_image]
|
|
142
|
+
return unless path
|
|
143
|
+
|
|
144
|
+
options[:cover_image] = Faraday::Multipart::FilePart.new(path, detect_mime(path))
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def detect_mime(path)
|
|
148
|
+
IMAGE_MIME_TYPES.fetch(File.extname(path).downcase, "application/octet-stream")
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
data/lib/holivia/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Holivia
|
|
@@ -65,8 +65,10 @@ 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/communication_item.rb
|
|
68
69
|
- lib/holivia/commands/env.rb
|
|
69
70
|
- lib/holivia/commands/format.rb
|
|
71
|
+
- lib/holivia/commands/intervention_item.rb
|
|
70
72
|
- lib/holivia/commands/item.rb
|
|
71
73
|
- lib/holivia/commands/objective.rb
|
|
72
74
|
- lib/holivia/commands/selfcare.rb
|