Class: NewDemoApiClient::AsyncClient

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, base_url: nil, environment: NewDemoApiClient::Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil) ⇒ NewDemoApiClient::AsyncClient

Parameters:

  • base_url (String) (defaults to: nil)
  • environment (NewDemoApiClient::Environment) (defaults to: NewDemoApiClient::Environment::DEFAULT)
  • max_retries (Long) (defaults to: nil)

    The number of times to retry a failed request, defaults to 2.

  • timeout_in_seconds (Long) (defaults to: nil)
  • token (String)


138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/test_sdk.rb', line 138

def initialize(token:, base_url: nil, environment: NewDemoApiClient::Environment::DEFAULT, max_retries: nil,
               timeout_in_seconds: nil)
  @async_request_client = NewDemoApiClient::AsyncRequestClient.new(
    base_url: base_url,
    environment: environment,
    max_retries: max_retries,
    timeout_in_seconds: timeout_in_seconds,
    token: token
  )
  @user = NewDemoApiClient::AsyncUserClient.new(request_client: @async_request_client)
  @group = NewDemoApiClient::AsyncGroupClient.new(request_client: @async_request_client)
  @macro = NewDemoApiClient::AsyncMacroClient.new(request_client: @async_request_client)
  @company = NewDemoApiClient::AsyncCompanyClient.new(request_client: @async_request_client)
  @deal = NewDemoApiClient::AsyncDealClient.new(request_client: @async_request_client)
  @file = NewDemoApiClient::AsyncFileClient.new(request_client: @async_request_client)
  @financials = NewDemoApiClient::AsyncFinancialsClient.new(request_client: @async_request_client)
  @product = NewDemoApiClient::AsyncProductClient.new(request_client: @async_request_client)
  @talent = NewDemoApiClient::AsyncTalentClient.new(request_client: @async_request_client)
  @unit_economics = NewDemoApiClient::AsyncUnitEconomicsClient.new(request_client: @async_request_client)
  @metadata = NewDemoApiClient::AsyncMetadataClient.new(request_client: @async_request_client)
  @benchmark = NewDemoApiClient::AsyncBenchmarkClient.new(request_client: @async_request_client)
end

Instance Attribute Details

#benchmarkNewDemoApiClient::AsyncBenchmarkClient (readonly)



130
131
132
# File 'lib/test_sdk.rb', line 130

def benchmark
  @benchmark
end

#companyNewDemoApiClient::AsyncCompanyClient (readonly)



114
115
116
# File 'lib/test_sdk.rb', line 114

def company
  @company
end

#dealNewDemoApiClient::AsyncDealClient (readonly)



116
117
118
# File 'lib/test_sdk.rb', line 116

def deal
  @deal
end

#fileNewDemoApiClient::AsyncFileClient (readonly)



118
119
120
# File 'lib/test_sdk.rb', line 118

def file
  @file
end

#financialsNewDemoApiClient::AsyncFinancialsClient (readonly)



120
121
122
# File 'lib/test_sdk.rb', line 120

def financials
  @financials
end

#groupNewDemoApiClient::AsyncGroupClient (readonly)



110
111
112
# File 'lib/test_sdk.rb', line 110

def group
  @group
end

#macroNewDemoApiClient::AsyncMacroClient (readonly)



112
113
114
# File 'lib/test_sdk.rb', line 112

def macro
  @macro
end

#metadataNewDemoApiClient::AsyncMetadataClient (readonly)



128
129
130
# File 'lib/test_sdk.rb', line 128

def 
  @metadata
end

#productNewDemoApiClient::AsyncProductClient (readonly)



122
123
124
# File 'lib/test_sdk.rb', line 122

def product
  @product
end

#talentNewDemoApiClient::AsyncTalentClient (readonly)



124
125
126
# File 'lib/test_sdk.rb', line 124

def talent
  @talent
end

#unit_economicsNewDemoApiClient::AsyncUnitEconomicsClient (readonly)



126
127
128
# File 'lib/test_sdk.rb', line 126

def unit_economics
  @unit_economics
end

#userNewDemoApiClient::AsyncUserClient (readonly)



108
109
110
# File 'lib/test_sdk.rb', line 108

def user
  @user
end

Instance Method Details

#healthz(request_options: nil) ⇒ NewDemoApiClient::HealthzResponse

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.healthz

Parameters:

Returns:



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/test_sdk.rb', line 170

def healthz(request_options: nil)
  response = @async_request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@async_request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@async_request_client.get_url(request_options: request_options)}/api/v1/healthz"
  end
  NewDemoApiClient::HealthzResponse.from_json(json_object: response.body)
end