Class: CandidApiClient::AsyncRequestClient
- Inherits:
-
Object
- Object
- CandidApiClient::AsyncRequestClient
- Defined in:
- lib/requests.rb
Instance Attribute Summary collapse
- #base_url ⇒ String readonly
- #conn ⇒ Faraday readonly
- #default_environment ⇒ String readonly
- #token ⇒ String, Method readonly
Instance Method Summary collapse
- #get_headers ⇒ Hash{String => String}
- #get_url(environment:, request_options: nil) ⇒ String
- #initialize(base_url: nil, environment: CandidApiClient::Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) ⇒ CandidApiClient::AsyncRequestClient constructor
Constructor Details
#initialize(base_url: nil, environment: CandidApiClient::Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) ⇒ CandidApiClient::AsyncRequestClient
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/requests.rb', line 68 def initialize(base_url: nil, environment: CandidApiClient::Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, token: nil) @default_environment = environment @token = token @conn = Faraday.new 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)
56 57 58 |
# File 'lib/requests.rb', line 56 def base_url @base_url end |
#conn ⇒ Faraday (readonly)
54 55 56 |
# File 'lib/requests.rb', line 54 def conn @conn end |
#default_environment ⇒ String (readonly)
60 61 62 |
# File 'lib/requests.rb', line 60 def default_environment @default_environment end |
#token ⇒ String, Method (readonly)
58 59 60 |
# File 'lib/requests.rb', line 58 def token @token end |
Instance Method Details
#get_headers ⇒ Hash{String => String}
89 90 91 92 93 |
# File 'lib/requests.rb', line 89 def get_headers headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "candidhealth", "X-Fern-SDK-Version": "0.35.1" } headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless token.nil? headers end |
#get_url(environment:, request_options: nil) ⇒ String
84 85 86 |
# File 'lib/requests.rb', line 84 def get_url(environment:, request_options: nil) &.base_url || @default_environment[environment] || @base_url end |