Skip to content

Commit

Permalink
Nest list_by_url inside TranscriptsClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Swimburger committed Feb 28, 2024
1 parent 5e7777a commit 8eac017
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions lib/assemblyai/transcripts/list_by_url_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@
require "async"

module AssemblyAI
# Retrieve a list of transcripts you created
#
# @param url [String] The URL to retrieve the transcript list from
# @param request_options [RequestOptions]
# @return [Transcripts::TranscriptList]
def list_by_url(url: nil, request_options: nil)
if url.nil?
url = "/v2/transcript"
end
response = @request_client.conn.get(url) do |req|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact

# :nodoc:
class TranscriptsClient
# Retrieve a list of transcripts you created
#
# @param url [String] The URL to retrieve the transcript list from
# @param request_options [RequestOptions]
# @return [Transcripts::TranscriptList]
def list_by_url(url: nil, request_options: nil)
if url.nil?
url = "/v2/transcript"
end
response = @request_client.conn.get(url) do |req|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
end
Transcripts::TranscriptList.from_json(json_object: response.body)
end
Transcripts::TranscriptList.from_json(json_object: response.body)
end

# :nodoc:
Expand Down

0 comments on commit 8eac017

Please sign in to comment.