Class: NewDemoApiClient::Client

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::Client

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)


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/test_sdk.rb', line 53

def initialize(token:, base_url: nil, environment: NewDemoApiClient::Environment::DEFAULT, max_retries: nil,
               timeout_in_seconds: nil)
  @request_client = NewDemoApiClient::RequestClient.new(
    base_url: base_url,
    environment: environment,
    max_retries: max_retries,
    timeout_in_seconds: timeout_in_seconds,
    token: token
  )
  @user = NewDemoApiClient::UserClient.new(request_client: @request_client)
  @group = NewDemoApiClient::GroupClient.new(request_client: @request_client)
  @macro = NewDemoApiClient::MacroClient.new(request_client: @request_client)
  @company = NewDemoApiClient::CompanyClient.new(request_client: @request_client)
  @deal = NewDemoApiClient::DealClient.new(request_client: @request_client)
  @file = NewDemoApiClient::FileClient.new(request_client: @request_client)
  @financials = NewDemoApiClient::FinancialsClient.new(request_client: @request_client)
  @product = NewDemoApiClient::ProductClient.new(request_client: @request_client)
  @talent = NewDemoApiClient::TalentClient.new(request_client: @request_client)
  @unit_economics = NewDemoApiClient::UnitEconomicsClient.new(request_client: @request_client)
  @metadata = NewDemoApiClient::MetadataClient.new(request_client: @request_client)
  @benchmark = NewDemoApiClient::BenchmarkClient.new(request_client: @request_client)
end

Instance Attribute Details

#benchmarkNewDemoApiClient::BenchmarkClient (readonly)



45
46
47
# File 'lib/test_sdk.rb', line 45

def benchmark
  @benchmark
end

#companyNewDemoApiClient::CompanyClient (readonly)



29
30
31
# File 'lib/test_sdk.rb', line 29

def company
  @company
end

#dealNewDemoApiClient::DealClient (readonly)



31
32
33
# File 'lib/test_sdk.rb', line 31

def deal
  @deal
end

#fileNewDemoApiClient::FileClient (readonly)



33
34
35
# File 'lib/test_sdk.rb', line 33

def file
  @file
end

#financialsNewDemoApiClient::FinancialsClient (readonly)



35
36
37
# File 'lib/test_sdk.rb', line 35

def financials
  @financials
end

#groupNewDemoApiClient::GroupClient (readonly)



25
26
27
# File 'lib/test_sdk.rb', line 25

def group
  @group
end

#macroNewDemoApiClient::MacroClient (readonly)



27
28
29
# File 'lib/test_sdk.rb', line 27

def macro
  @macro
end

#metadataNewDemoApiClient::MetadataClient (readonly)



43
44
45
# File 'lib/test_sdk.rb', line 43

def 
  @metadata
end

#productNewDemoApiClient::ProductClient (readonly)



37
38
39
# File 'lib/test_sdk.rb', line 37

def product
  @product
end

#talentNewDemoApiClient::TalentClient (readonly)



39
40
41
# File 'lib/test_sdk.rb', line 39

def talent
  @talent
end

#unit_economicsNewDemoApiClient::UnitEconomicsClient (readonly)



41
42
43
# File 'lib/test_sdk.rb', line 41

def unit_economics
  @unit_economics
end

#userNewDemoApiClient::UserClient (readonly)



23
24
25
# File 'lib/test_sdk.rb', line 23

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:



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/test_sdk.rb', line 85

def healthz(request_options: nil)
  response = @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 || {}),
  **@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 "#{@request_client.get_url(request_options: request_options)}/api/v1/healthz"
  end
  NewDemoApiClient::HealthzResponse.from_json(json_object: response.body)
end