Class: NewDemoApiClient::AsyncMacroClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ NewDemoApiClient::AsyncMacroClient

Parameters:



218
219
220
# File 'lib/test_sdk/macro/client.rb', line 218

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientNewDemoApiClient::AsyncRequestClient (readonly)



214
215
216
# File 'lib/test_sdk/macro/client.rb', line 214

def request_client
  @request_client
end

Instance Method Details

#get_components(segmentation:, slug:, request_options: nil) ⇒ Array<NewDemoApiClient::WeatherComponents>

Returns the individual components of the weather indicator and some of the

underlying inputs of those component gauges for the given segmentation slug.

Examples:

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

Parameters:

Returns:



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/test_sdk/macro/client.rb', line 356

def get_components(segmentation:, slug:, request_options: nil)
  Async do
    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/data/weather/#{segmentation}/#{slug}/components"
    end
    parsed_json = JSON.parse(response.body)
    parsed_json&.map do |item|
      item = item.to_json
      NewDemoApiClient::WeatherComponents.from_json(json_object: item)
    end
  end
end

#get_gauge(segmentation:, slug: nil, request_options: nil) ⇒ Array<NewDemoApiClient::WeatherGauge>

Returns the overall weather indicator, combined across all stages, for the given

segmentation slug(s).
If no slug is provided, the endpoint will return the gauge for all available
segmentations.

Examples:

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

Parameters:

Returns:



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/test_sdk/macro/client.rb', line 318

def get_gauge(segmentation:, slug: nil, request_options: nil)
  Async do
    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
      req.params = { **(request_options&.additional_query_parameters || {}), "slug": slug }.compact
      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/data/weather/#{segmentation}/gauges"
    end
    parsed_json = JSON.parse(response.body)
    parsed_json&.map do |item|
      item = item.to_json
      NewDemoApiClient::WeatherGauge.from_json(json_object: item)
    end
  end
end

#get_market_context(segmentation:, slug:, request_options: nil) ⇒ Array<NewDemoApiClient::WeatherMarketContext>

Returns simplified contextual metrics about relevant stages and market activity

for the given segmentation slug.

Examples:

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

Parameters:

Returns:



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/test_sdk/macro/client.rb', line 396

def get_market_context(segmentation:, slug:, request_options: nil)
  Async do
    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/data/weather/#{segmentation}/#{slug}/market-context"
    end
    parsed_json = JSON.parse(response.body)
    parsed_json&.map do |item|
      item = item.to_json
      NewDemoApiClient::WeatherMarketContext.from_json(json_object: item)
    end
  end
end

#get_metadata(segmentation:, request_options: nil) ⇒ Array<NewDemoApiClient::WeatherMetadata>

Returns segmentation metadata for each of the classes of segmentations “geo” and

"sector".
The geography ("geo") segmentation type refers to major geographic
segmentations.
The "sector" segmentation type refers to major business model categories in the
USA geography.
The metadata includes parameters used to generate the respective indicators, and
the metadata needed to
retrieve the series from the API.

Examples:

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

Parameters:

Returns:



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/test_sdk/macro/client.rb', line 276

def (segmentation:, request_options: nil)
  Async do
    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/data/weather/#{segmentation}/metadata"
    end
    parsed_json = JSON.parse(response.body)
    parsed_json&.map do |item|
      item = item.to_json
      NewDemoApiClient::WeatherMetadata.from_json(json_object: item)
    end
  end
end

#get_segmentations(request_options: nil) ⇒ Array<String>

Returns the available segmentations for the weather module.

Examples:

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

Parameters:

Returns:

  • (Array<String>)


233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/test_sdk/macro/client.rb', line 233

def get_segmentations(request_options: nil)
  Async do
    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/data/weather/segmentations"
    end
    parsed_json = JSON.parse(response.body)
    parsed_json
  end
end