holivia 0.5.0 → 0.7.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: 83d3ab262bb3fc4381d4ca420e6186ef577ce8e40db802b0658209e2ea0599b5
4
- data.tar.gz: 36813fba6ea7c7cdb25d6b5cbfc97905226959e956fa02a146c9d60a54357898
3
+ metadata.gz: 61c8a59293a0b4cfb43dca7bad3c64694c75582875dff6198efea295712a1477
4
+ data.tar.gz: 9795ce32e8ada6e69eeedbb24549f711120ec6caa491d89fb86605bd2ecbb4a2
5
5
  SHA512:
6
- metadata.gz: 36d0c89c7d469290018d121ada800c8bf4da4fcc6af6918930c5907c283786b5aded11979050a0f6ef9fb19c127bdebb789e3b014eb09c842c568eb404421f05
7
- data.tar.gz: 8e9086a2a046deec0170ec502391c8cda726963933d8597159aa98ce498e21d88a0e6aebe059606ae07387cad8655be6f88449ed3035cee1d6a161dfff316044
6
+ metadata.gz: 8e68ebf330b241d4eae1d048d415adb2f6f6b551d63bed270e0ab17610535672e323a26a4c85b904e338613d48b87f88f59a9920866fc6f9dd3299229907f348
7
+ data.tar.gz: 9b431f54025a5420fada21b6769063b06f1da5e02cb1b5e09dc1b28bcadc534847758441fad1090b945c412c99fe9aeb24ae8c433792eaad2e4a69aba6a5c186
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.0] - 2026-07-02
4
+
5
+ - Add `holivia communication` commands for communication library CRUD, publishing, schema discovery, and document/cover uploads
6
+
7
+ ## [0.6.0] - 2026-06-05
8
+
9
+ - Add `holivia appointment video-diagnostics <id>` for appointment video diagnostics
10
+
3
11
  ## [0.5.0] - 2026-05-06
4
12
 
5
13
  - Add `--state` flag on `selfcare create` and `selfcare update` for AASM-driven lifecycle transitions
data/README.md CHANGED
@@ -1,43 +1,254 @@
1
1
  # Holivia
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ Ruby client and command-line interface for the Holivia API.
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/holivia`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ The `holivia` executable is primarily used to manage Holivia backoffice data from the terminal: environments, authentication, selfcare content, objectives, communication library items, and appointment diagnostics.
6
+
7
+ Coding agents can use [`SKILL.md`](SKILL.md) as a downloadable usage guide for operating this CLI safely.
8
+
9
+ ## Requirements
10
+
11
+ - Ruby 3.1 or newer
12
+ - A Holivia account with API access
6
13
 
7
14
  ## Installation
8
15
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
16
+ Install the CLI from RubyGems:
17
+
18
+ ```bash
19
+ gem install holivia
20
+ ```
21
+
22
+ If you want to use the gem from a Ruby application, add it to your bundle:
23
+
24
+ ```bash
25
+ bundle add holivia
26
+ ```
27
+
28
+ After installation, verify the executable is available:
29
+
30
+ ```bash
31
+ holivia version
32
+ ```
33
+
34
+ ## Setup
35
+
36
+ The CLI stores environment configuration in `~/.holivia/config.yml`.
37
+
38
+ Show the current environment:
39
+
40
+ ```bash
41
+ holivia env
42
+ ```
43
+
44
+ Add an API environment:
45
+
46
+ ```bash
47
+ holivia env add staging --url https://staging.example.com
48
+ ```
49
+
50
+ Switch to an environment:
51
+
52
+ ```bash
53
+ holivia env use staging
54
+ ```
55
+
56
+ List configured environments:
57
+
58
+ ```bash
59
+ holivia env list
60
+ ```
61
+
62
+ Enable debug logging for the current environment when troubleshooting requests:
10
63
 
11
- Install the gem and add to the application's Gemfile by executing:
64
+ ```bash
65
+ holivia env debug --true
66
+ ```
67
+
68
+ Disable it again with:
12
69
 
13
70
  ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
71
+ holivia env debug --false
15
72
  ```
16
73
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
74
+ ## Authentication
75
+
76
+ Log in interactively:
18
77
 
19
78
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
79
+ holivia login
21
80
  ```
22
81
 
23
- ## Usage
82
+ Or pass credentials directly:
83
+
84
+ ```bash
85
+ holivia login --email user@example.com --password secret
86
+ ```
87
+
88
+ Credentials are stored per environment in `~/.holivia/credentials.<env>.json`. Access tokens are sent as bearer tokens, and the CLI automatically refreshes credentials after a `401` response when a refresh token is available.
89
+
90
+ Log out and remove stored credentials for the current environment:
91
+
92
+ ```bash
93
+ holivia logout
94
+ ```
95
+
96
+ ## Basic Usage
97
+
98
+ Show all available commands:
99
+
100
+ ```bash
101
+ holivia --help
102
+ ```
103
+
104
+ Discover valid selfcare enum values and item parameters:
105
+
106
+ ```bash
107
+ holivia selfcare schema
108
+ ```
109
+
110
+ List selfcare contents:
111
+
112
+ ```bash
113
+ holivia selfcare index
114
+ ```
115
+
116
+ Show one selfcare content:
117
+
118
+ ```bash
119
+ holivia selfcare show 123
120
+ ```
121
+
122
+ Create a selfcare content from flags:
123
+
124
+ ```bash
125
+ holivia selfcare create \
126
+ --title "Breathing exercise" \
127
+ --locale fr \
128
+ --content-type exercise \
129
+ --duration 300 \
130
+ --state draft
131
+ ```
24
132
 
25
- TODO: Write usage instructions here
133
+ Create a full selfcare content tree from JSON:
134
+
135
+ ```bash
136
+ holivia selfcare compose --file examples/compose.json
137
+ ```
138
+
139
+ You can print a compose template with:
140
+
141
+ ```bash
142
+ holivia selfcare compose --example
143
+ ```
144
+
145
+ Create and update commands also accept JSON from standard input:
146
+
147
+ ```bash
148
+ printf '{"title":"Breathing exercise","locale":"fr"}' | holivia selfcare create
149
+ ```
150
+
151
+ List objectives:
152
+
153
+ ```bash
154
+ holivia objective index
155
+ ```
156
+
157
+ Filter objectives by code:
158
+
159
+ ```bash
160
+ holivia objective index --code anxiety
161
+ ```
162
+
163
+ Show video diagnostics for an appointment:
164
+
165
+ ```bash
166
+ holivia appointment video-diagnostics 42
167
+ ```
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
+ ## Files And Uploads
193
+
194
+ Selfcare create and update commands can upload images with `--image <path>`.
195
+
196
+ ```bash
197
+ holivia selfcare update 123 --image cover.png
198
+ ```
199
+
200
+ Slide item create and update commands can upload audio with `--audio <path>`.
201
+
202
+ ```bash
203
+ holivia selfcare item create --slide-id 456 --item-type AudioItem --audio meditation.mp3
204
+ ```
205
+
206
+ 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>`.
207
+
208
+ 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>`.
26
209
 
27
210
  ## Development
28
211
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
212
+ After checking out the repo, run:
213
+
214
+ ```bash
215
+ bin/setup
216
+ ```
217
+
218
+ Run the test suite with:
219
+
220
+ ```bash
221
+ rake spec
222
+ ```
223
+
224
+ Open an interactive console with:
225
+
226
+ ```bash
227
+ bin/console
228
+ ```
229
+
230
+ Install this gem onto your local machine with:
231
+
232
+ ```bash
233
+ bundle exec rake install
234
+ ```
235
+
236
+ To release a new version, update the version number in `lib/holivia/version.rb`, then run:
237
+
238
+ ```bash
239
+ bundle exec rake release
240
+ ```
30
241
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
242
+ This creates a git tag, pushes commits and tags, and publishes the `.gem` file to [RubyGems.org](https://rubygems.org).
32
243
 
33
244
  ## Contributing
34
245
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/holivia. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/holivia/blob/master/CODE_OF_CONDUCT.md).
246
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Holivia-Team/holivia-ruby.
36
247
 
37
248
  ## License
38
249
 
39
250
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
251
 
41
- ## Code of Conduct
252
+ ## Code Of Conduct
42
253
 
43
- Everyone interacting in the Holivia project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/holivia/blob/master/CODE_OF_CONDUCT.md).
254
+ Everyone interacting in the Holivia project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/Holivia-Team/holivia-ruby/blob/master/CODE_OF_CONDUCT.md).
data/SKILL.md ADDED
@@ -0,0 +1,339 @@
1
+ # Holivia CLI Skill
2
+
3
+ Use this skill when you need to operate the Holivia API through the `holivia` command-line tool.
4
+
5
+ The CLI manages Holivia backoffice data: environments, authentication, selfcare contents, objectives, selfcare-objective associations, and appointment video diagnostics.
6
+
7
+ ## Preconditions
8
+
9
+ - Ruby 3.1 or newer is available.
10
+ - The CLI is installed with `gem install holivia`, or you are running inside this repository with `bundle exec exe/holivia`.
11
+ - The user has provided the correct Holivia API base URL and account credentials, or they have already authenticated locally.
12
+
13
+ Use `holivia` in examples below. If working from a checkout before installation, replace it with `bundle exec exe/holivia`.
14
+
15
+ ## Safety Rules
16
+
17
+ - Never invent API URLs, credentials, IDs, enum values, or content model fields.
18
+ - Never print, store, or commit passwords, access tokens, refresh tokens, or files under `~/.holivia/credentials.*.json`.
19
+ - Prefer interactive `holivia login` when a human can enter credentials. Use `--password` only when the user explicitly provides it for automation.
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
+ - 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
+ - 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
+ ## Installation
25
+
26
+ Install the released CLI:
27
+
28
+ ```bash
29
+ gem install holivia
30
+ ```
31
+
32
+ Verify it is available:
33
+
34
+ ```bash
35
+ holivia version
36
+ ```
37
+
38
+ When working from this repository without installing the gem:
39
+
40
+ ```bash
41
+ bundle install
42
+ bundle exec exe/holivia version
43
+ ```
44
+
45
+ ## Environment Setup
46
+
47
+ The CLI stores environment configuration at `~/.holivia/config.yml`.
48
+
49
+ Show the active environment:
50
+
51
+ ```bash
52
+ holivia env
53
+ ```
54
+
55
+ List environments:
56
+
57
+ ```bash
58
+ holivia env list
59
+ ```
60
+
61
+ Add or update an environment:
62
+
63
+ ```bash
64
+ holivia env add staging --url https://api.example.com
65
+ ```
66
+
67
+ Switch environments:
68
+
69
+ ```bash
70
+ holivia env use staging
71
+ ```
72
+
73
+ Enable request debug logging for troubleshooting:
74
+
75
+ ```bash
76
+ holivia env debug --true
77
+ ```
78
+
79
+ Disable request debug logging:
80
+
81
+ ```bash
82
+ holivia env debug --false
83
+ ```
84
+
85
+ Debug logging may expose request details. Do not enable it in shared logs unless needed.
86
+
87
+ ## Authentication
88
+
89
+ Credentials are stored per environment at `~/.holivia/credentials.<env>.json`. The CLI sends the access token as a bearer token and refreshes credentials automatically after a `401` response when possible.
90
+
91
+ Interactive login:
92
+
93
+ ```bash
94
+ holivia login
95
+ ```
96
+
97
+ Non-interactive login:
98
+
99
+ ```bash
100
+ holivia login --email user@example.com --password secret
101
+ ```
102
+
103
+ Logout for the current environment:
104
+
105
+ ```bash
106
+ holivia logout
107
+ ```
108
+
109
+ ## Discovery Workflow
110
+
111
+ Start with help and environment checks:
112
+
113
+ ```bash
114
+ holivia --help
115
+ holivia env
116
+ ```
117
+
118
+ For selfcare content work, always discover the live schema first:
119
+
120
+ ```bash
121
+ holivia selfcare schema
122
+ ```
123
+
124
+ Use the schema response for:
125
+
126
+ - content types
127
+ - format types
128
+ - item types
129
+ - allowed states
130
+ - objective tiers
131
+ - item-specific permitted params
132
+
133
+ ## Selfcare Content
134
+
135
+ List contents:
136
+
137
+ ```bash
138
+ holivia selfcare index
139
+ ```
140
+
141
+ Show one content:
142
+
143
+ ```bash
144
+ holivia selfcare show 123
145
+ ```
146
+
147
+ Create a content with flags:
148
+
149
+ ```bash
150
+ holivia selfcare create \
151
+ --title "Breathing exercise" \
152
+ --locale fr \
153
+ --content-type exercise \
154
+ --duration 300 \
155
+ --state draft
156
+ ```
157
+
158
+ Update a content:
159
+
160
+ ```bash
161
+ holivia selfcare update 123 --title "Updated title" --state published
162
+ ```
163
+
164
+ Upload or replace an image:
165
+
166
+ ```bash
167
+ holivia selfcare update 123 --image cover.png
168
+ ```
169
+
170
+ Accepted image extensions are `.jpg`, `.jpeg`, `.png`, `.webp`, and `.gif`.
171
+
172
+ ## Compose Workflow
173
+
174
+ Use compose to create a complete selfcare content tree atomically from JSON.
175
+
176
+ Print the built-in template:
177
+
178
+ ```bash
179
+ holivia selfcare compose --example
180
+ ```
181
+
182
+ Create from a file:
183
+
184
+ ```bash
185
+ holivia selfcare compose --file payload.json
186
+ ```
187
+
188
+ Create from stdin:
189
+
190
+ ```bash
191
+ printf '{"title":"Example","locale":"fr"}' | holivia selfcare compose
192
+ ```
193
+
194
+ Compose is JSON-only and does not upload files. To attach an image, compose first, read the returned content id, then run:
195
+
196
+ ```bash
197
+ holivia selfcare update <id> --image cover.png
198
+ ```
199
+
200
+ Audio items require file upload and must be added after compose with `holivia selfcare item create`.
201
+
202
+ ## Incremental Content Workflow
203
+
204
+ Create a content:
205
+
206
+ ```bash
207
+ holivia selfcare create --title "Example" --locale fr --content-type exercise --duration 300 --state draft
208
+ ```
209
+
210
+ Add a format:
211
+
212
+ ```bash
213
+ holivia selfcare format create --selfcare-content-id 123 --format-type text
214
+ ```
215
+
216
+ Add a slide:
217
+
218
+ ```bash
219
+ holivia selfcare slide create --content-format-id 456 --title "Intro" --duration 60
220
+ ```
221
+
222
+ Add a rich text item:
223
+
224
+ ```bash
225
+ holivia selfcare item create --slide-id 789 --item-type RichTextItem --content "Welcome"
226
+ ```
227
+
228
+ Add an audio item:
229
+
230
+ ```bash
231
+ holivia selfcare item create --slide-id 789 --item-type AudioItem --audio meditation.mp3
232
+ ```
233
+
234
+ Accepted audio extensions are `.mp3`, `.mp4`, `.wav`, `.ogg`, `.flac`, `.aac`, `.m4a`, and `.webm`.
235
+
236
+ Update an item:
237
+
238
+ ```bash
239
+ holivia selfcare item update 321 --content "Updated content"
240
+ ```
241
+
242
+ Most create and update commands accept either flags or JSON from stdin. Prefer JSON for complex payloads.
243
+
244
+ ## Objectives
245
+
246
+ List objectives:
247
+
248
+ ```bash
249
+ holivia objective index
250
+ ```
251
+
252
+ Paginate objectives:
253
+
254
+ ```bash
255
+ holivia objective index --page 1 --per-page 50
256
+ ```
257
+
258
+ Filter objectives by code:
259
+
260
+ ```bash
261
+ holivia objective index --code anxiety
262
+ ```
263
+
264
+ Show one objective:
265
+
266
+ ```bash
267
+ holivia objective show 123
268
+ ```
269
+
270
+ Objective translated fields are returned in the default locale, currently `fr`.
271
+
272
+ ## Selfcare Objective Associations
273
+
274
+ List associations:
275
+
276
+ ```bash
277
+ holivia selfcare objective index --selfcare-content-id 123
278
+ ```
279
+
280
+ Show one association:
281
+
282
+ ```bash
283
+ holivia selfcare objective show 456
284
+ ```
285
+
286
+ Associate an objective to selfcare content:
287
+
288
+ ```bash
289
+ holivia selfcare objective create --selfcare-content-id 123 --objective-id 789 --tier main
290
+ ```
291
+
292
+ Update an association tier:
293
+
294
+ ```bash
295
+ holivia selfcare objective update 456 --tier secondary
296
+ ```
297
+
298
+ Delete an association:
299
+
300
+ ```bash
301
+ holivia selfcare objective delete 456
302
+ ```
303
+
304
+ Inline alternative for compose or selfcare update JSON payloads:
305
+
306
+ ```json
307
+ {
308
+ "objectives": [
309
+ { "objective_id": 789, "tier": "main" }
310
+ ]
311
+ }
312
+ ```
313
+
314
+ On update, an empty `objectives` array clears associations. Omitting the key leaves associations unchanged.
315
+
316
+ ## Appointments
317
+
318
+ Show video diagnostics for an appointment:
319
+
320
+ ```bash
321
+ holivia appointment video-diagnostics 42
322
+ ```
323
+
324
+ ## Errors
325
+
326
+ - `401` means authentication failed or credentials could not be refreshed. Re-run `holivia login` for the active environment.
327
+ - `404` means the requested resource was not found in the active environment.
328
+ - `422` validation errors include structured details such as a payload path and field errors. Use those details to correct the request.
329
+
330
+ ## Agent Checklist
331
+
332
+ Before making API changes:
333
+
334
+ - Run `holivia env` and verify the active URL/environment.
335
+ - Run `holivia selfcare schema` before selfcare create/update/compose work.
336
+ - Use existing IDs from list/show commands or explicit user input.
337
+ - Prefer draft states unless the user explicitly requests publishing.
338
+ - Use JSON files or stdin for complex payloads.
339
+ - Summarize created or updated resource IDs after the command succeeds.
@@ -49,6 +49,20 @@ 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
+ Appointments:
64
+ holivia appointment video-diagnostics <id> Show video diagnostics for an appointment
65
+
52
66
  Selfcare Content Objectives:
53
67
  holivia selfcare objective index [--page N --per-page N --selfcare-content-id ID --objective-id ID]
54
68
  List a selfcare content's associated objectives
@@ -86,6 +100,8 @@ module Holivia
86
100
  Accepted audio formats: MP3, MP4, WAV, OGG, FLAC, AAC, M4A, WebM. Max size: 100 MB.
87
101
  Image uploads use --image <path> on selfcare create/update (sent as multipart/form-data).
88
102
  Accepted image formats: JPEG, PNG, WebP, GIF. Max size: 5 MB.
103
+ Communication uploads use --document <path> and optional --cover-image <path>.
104
+ The API validates accepted communication upload formats and file sizes.
89
105
  Compose is JSON-only — to attach an image to a composed tree, PATCH the returned id:
90
106
  holivia selfcare update <id> --image <path>
91
107
 
data/lib/holivia/cli.rb CHANGED
@@ -9,10 +9,12 @@ require_relative "commands/slide"
9
9
  require_relative "commands/env"
10
10
  require_relative "commands/item"
11
11
  require_relative "commands/objective"
12
+ require_relative "commands/appointment"
13
+ require_relative "commands/communication_item"
12
14
 
13
15
  module Holivia
14
16
  class CLI
15
- def self.start(args) # rubocop:disable Metrics/CyclomaticComplexity
17
+ def self.start(args) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
16
18
  command = args.shift
17
19
  case command
18
20
  when "login" then Commands::Auth.new.login(args)
@@ -20,6 +22,8 @@ module Holivia
20
22
  when "env" then Commands::Env.route(args)
21
23
  when "selfcare" then Commands::Selfcare.route(args)
22
24
  when "objective" then Commands::Objective.route(args)
25
+ when "appointment" then Commands::Appointment.route(args)
26
+ when "communication" then Commands::CommunicationItem.route(args)
23
27
  when "version", "--version", "-v" then puts "holivia #{Holivia::VERSION}"
24
28
  when "--help", "-h", nil then puts Help::HELP_TEXT
25
29
  else warn "Unknown command: #{command}"
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Holivia
6
+ module Commands
7
+ class Appointment < Base
8
+ BASE_PATH = "/api/v1/backoffice/appointments"
9
+
10
+ def self.route(args)
11
+ subcommand = args.shift
12
+ case subcommand
13
+ when "video-diagnostics" then new.video_diagnostics(args)
14
+ else warn "Unknown appointment command: #{subcommand}"
15
+ exit 1
16
+ end
17
+ end
18
+
19
+ def video_diagnostics(args = [])
20
+ id = args.shift
21
+ abort "Usage: holivia appointment video-diagnostics <id>" unless id
22
+
23
+ output(client.get("#{BASE_PATH}/#{id}/video_diagnostics"))
24
+ end
25
+ end
26
+ end
27
+ end
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Holivia
4
- VERSION = "0.5.0"
4
+ VERSION = "0.7.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.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Holivia
@@ -52,6 +52,7 @@ files:
52
52
  - LICENSE.txt
53
53
  - README.md
54
54
  - Rakefile
55
+ - SKILL.md
55
56
  - example_content.xml
56
57
  - examples/compose.json
57
58
  - exe/holivia
@@ -61,8 +62,10 @@ files:
61
62
  - lib/holivia/cli.rb
62
63
  - lib/holivia/cli/help.rb
63
64
  - lib/holivia/client.rb
65
+ - lib/holivia/commands/appointment.rb
64
66
  - lib/holivia/commands/auth.rb
65
67
  - lib/holivia/commands/base.rb
68
+ - lib/holivia/commands/communication_item.rb
66
69
  - lib/holivia/commands/env.rb
67
70
  - lib/holivia/commands/format.rb
68
71
  - lib/holivia/commands/item.rb