Skip to content

Commit

Permalink
Merge pull request #6 from Fingertips/manfred-documents
Browse files Browse the repository at this point in the history
Allow users to create and list documents for channels
  • Loading branch information
Manfred authored Jul 11, 2024
2 parents 12b741d + b9910dc commit fcd5252
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/teletube/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ module Teletube
end

def get_documents
handle_response(@http.get(path: "/api/v1/videos/#{@context.params["video_id"]}/documents"))
if @context.params.has_key?("video_id")
handle_response(@http.get(path: "/api/v1/videos/#{@context.params["video_id"]}/documents"))
elsif @context.params.has_key?("channel_id")
handle_response(@http.get(path: "/api/v1/channels/#{@context.params["channel_id"]}/documents"))
end
end

def create_document
Expand Down
8 changes: 7 additions & 1 deletion src/teletube/option_parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,20 @@ module Teletube

parser.on("documents", "Interact with documents.") do
context.resource = "documents"
parser.on("list", "List all documents uploaded for a video.") do
parser.on("list", "List all documents uploaded for a channel or video.") do
context.command = "list"
parser.on("--channel-id ID", "The identifier of the channel.") do |video_id|
context.params["channel_id"] = JSON::Any.new(video_id)
end
parser.on("--video-id ID", "The identifier of the video.") do |video_id|
context.params["video_id"] = JSON::Any.new(video_id)
end
end
parser.on("create", "Create a file.") do
context.command = "create"
parser.on("--channel-id ID", "The identifier of the channel.") do |video_id|
context.params["channel_id"] = JSON::Any.new(video_id)
end
parser.on("--video-id ID", "The identifier of the video.") do |video_id|
context.params["video_id"] = JSON::Any.new(video_id)
end
Expand Down

0 comments on commit fcd5252

Please sign in to comment.