Class: SchwarmCli::Client::SkillFiles
- Inherits:
-
Resource
- Object
- Resource
- SchwarmCli::Client::SkillFiles
show all
- Defined in:
- lib/schwarm_cli/client/skill_files.rb
Overview
The skill_files endpoint expects path as a top-level form param plus a multipart-attached ‘file` (Active Storage), NOT a JSON body wrapped in `{…}`. Build a multipart form for create/update.
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Instance Method Details
#create(skill_id:, path:, content:) ⇒ Object
20
21
22
|
# File 'lib/schwarm_cli/client/skill_files.rb', line 20
def create(skill_id:, path:, content:)
post("/api/v2/skills/#{skill_id}/files", multipart_body(path:, content:)).body
end
|
#destroy(skill_id:, id:) ⇒ Object
31
32
33
34
|
# File 'lib/schwarm_cli/client/skill_files.rb', line 31
def destroy(skill_id:, id:)
delete("/api/v2/skills/#{skill_id}/files/#{id}")
nil
end
|
#find(skill_id:, id:) ⇒ Object
16
17
18
|
# File 'lib/schwarm_cli/client/skill_files.rb', line 16
def find(skill_id:, id:)
get("/api/v2/skills/#{skill_id}/files/#{id}").body
end
|
#list(skill_id:, page: nil, per_page: nil) ⇒ Object
11
12
13
14
|
# File 'lib/schwarm_cli/client/skill_files.rb', line 11
def list(skill_id:, page: nil, per_page: nil)
params = { page:, per_page: }.compact
get("/api/v2/skills/#{skill_id}/files", params).body
end
|
#update(skill_id:, id:, path: nil, content: nil) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/schwarm_cli/client/skill_files.rb', line 24
def update(skill_id:, id:, path: nil, content: nil)
body = {}
body[:path] = path if path
body[:file] = file_part(path:, content:) if content
patch("/api/v2/skills/#{skill_id}/files/#{id}", body).body
end
|