Class: OmniSocials::Resources::Folders
- Inherits:
-
Object
- Object
- OmniSocials::Resources::Folders
- Defined in:
- lib/omnisocials/resources/folders.rb
Overview
Folders resource: organize media library files into folders.
Instance Method Summary collapse
-
#create(name:, parent_id: nil) ⇒ Object
POST /folders - create a folder (optionally nested under parent_id).
-
#delete(folder_id) ⇒ Object
DELETE /folders/id - delete a folder.
-
#initialize(client) ⇒ Folders
constructor
A new instance of Folders.
-
#list ⇒ Object
GET /folders - list media folders (with per-folder file counts).
-
#update(folder_id, name: nil, parent_id: OmniSocials::NOT_GIVEN) ⇒ Object
PATCH /folders/id - rename and/or move a folder.
Constructor Details
#initialize(client) ⇒ Folders
Returns a new instance of Folders.
7 8 9 |
# File 'lib/omnisocials/resources/folders.rb', line 7 def initialize(client) @client = client end |
Instance Method Details
#create(name:, parent_id: nil) ⇒ Object
POST /folders - create a folder (optionally nested under parent_id).
17 18 19 20 |
# File 'lib/omnisocials/resources/folders.rb', line 17 def create(name:, parent_id: nil) body = Internal.drop_nil({ "name" => name, "parent_id" => parent_id }) @client.request("POST", "/folders", json: body) end |
#delete(folder_id) ⇒ Object
DELETE /folders/id - delete a folder. Returns nil (204).
The folder's media is NOT deleted: files move to the root and subfolders move up to the deleted folder's parent.
36 37 38 |
# File 'lib/omnisocials/resources/folders.rb', line 36 def delete(folder_id) @client.request("DELETE", "/folders/#{folder_id}") end |
#list ⇒ Object
GET /folders - list media folders (with per-folder file counts).
12 13 14 |
# File 'lib/omnisocials/resources/folders.rb', line 12 def list @client.request("GET", "/folders") end |
#update(folder_id, name: nil, parent_id: OmniSocials::NOT_GIVEN) ⇒ Object
PATCH /folders/id - rename and/or move a folder.
Pass parent_id: nil explicitly to move the folder to the top level; omit it to leave the parent unchanged.
26 27 28 29 30 |
# File 'lib/omnisocials/resources/folders.rb', line 26 def update(folder_id, name: nil, parent_id: OmniSocials::NOT_GIVEN) body = Internal.drop_nil({ "name" => name }) body["parent_id"] = parent_id unless parent_id.is_a?(NotGiven) @client.request("PATCH", "/folders/#{folder_id}", json: body) end |