Class: AssemblyAI::AsyncRequestClient
- Inherits:
-
Object
- Object
- AssemblyAI::AsyncRequestClient
- 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::AsyncRequestClient constructor
Constructor Details
#initialize(api_key:, environment: AssemblyAI::Environment::DEFAULT, base_url: nil, max_retries: nil, timeout_in_seconds: nil, user_agent: nil) ⇒ AssemblyAI::AsyncRequestClient
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/requests.rb', line 71 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.adapter :async_http 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)
60 61 62 |
# File 'lib/requests.rb', line 60 def base_url @base_url end |
#conn ⇒ Faraday (readonly)
58 59 60 |
# File 'lib/requests.rb', line 58 def conn @conn end |
#default_environment ⇒ String (readonly)
62 63 64 |
# File 'lib/requests.rb', line 62 def default_environment @default_environment end |
#headers ⇒ Hash{String => String} (readonly)
56 57 58 |
# File 'lib/requests.rb', line 56 def headers @headers end |
Instance Method Details
#get_url(request_options: nil) ⇒ String
93 94 95 |
# File 'lib/requests.rb', line 93 def get_url(request_options: nil) &.base_url || @default_environment || @base_url end |