Class: AssemblyAI::RequestClient
- Inherits:
-
Object
- Object
- AssemblyAI::RequestClient
- Defined in:
- lib/requests.rb
Instance Attribute Summary collapse
- #base_url ⇒ String readonly
- #conn ⇒ Faraday readonly
- #default_environment ⇒ String readonly
- #headers ⇒ Hash{String => String} readonly
Instance Method Summary collapse
- #get_url(request_options: nil) ⇒ String
- #initialize(api_key:, environment: AssemblyAI::Environment::DEFAULT, base_url: nil, max_retries: nil, timeout_in_seconds: nil, user_agent: nil) ⇒ AssemblyAI::RequestClient constructor
Constructor Details
#initialize(api_key:, environment: AssemblyAI::Environment::DEFAULT, base_url: nil, max_retries: nil, timeout_in_seconds: nil, user_agent: nil) ⇒ AssemblyAI::RequestClient
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/requests.rb', line 28 def initialize(api_key:, environment: AssemblyAI::Environment::DEFAULT, base_url: nil, max_retries: nil, timeout_in_seconds: nil, user_agent: nil) @default_environment = environment @base_url = environment || base_url @headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "assemblyai", "X-Fern-SDK-Version": AssemblyAI::Gemconfig::VERSION, "Authorization": api_key.to_s, "User-Agent": AssemblyAI::UserAgent.merge(AssemblyAI::DefaultUserAgent.instance.user_agent, user_agent).serialize } @conn = Faraday.new(headers: @headers) do |faraday| faraday.request :json faraday.response :raise_error, include_request: true faraday.request :retry, { max: max_retries } unless max_retries.nil? faraday..timeout = timeout_in_seconds unless timeout_in_seconds.nil? end end |
Instance Attribute Details
#base_url ⇒ String (readonly)
17 18 19 |
# File 'lib/requests.rb', line 17 def base_url @base_url end |
#conn ⇒ Faraday (readonly)
15 16 17 |
# File 'lib/requests.rb', line 15 def conn @conn end |
#default_environment ⇒ String (readonly)
19 20 21 |
# File 'lib/requests.rb', line 19 def default_environment @default_environment end |
#headers ⇒ Hash{String => String} (readonly)
13 14 15 |
# File 'lib/requests.rb', line 13 def headers @headers end |
Instance Method Details
#get_url(request_options: nil) ⇒ String
49 50 51 |
# File 'lib/requests.rb', line 49 def get_url(request_options: nil) &.base_url || @default_environment || @base_url end |