Class: NewDemoApiClient::MacroClient
- Inherits:
-
Object
- Object
- NewDemoApiClient::MacroClient
- Defined in:
- lib/test_sdk/macro/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#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.
-
#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).
-
#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.
-
#get_metadata(segmentation:, request_options: nil) ⇒ Array<NewDemoApiClient::WeatherMetadata>
Returns segmentation metadata for each of the classes of segmentations “geo” and “sector”.
-
#get_segmentations(request_options: nil) ⇒ Array<String>
Returns the available segmentations for the weather module.
- #initialize(request_client:) ⇒ NewDemoApiClient::MacroClient constructor
Constructor Details
#initialize(request_client:) ⇒ NewDemoApiClient::MacroClient
18 19 20 |
# File 'lib/test_sdk/macro/client.rb', line 18 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ NewDemoApiClient::RequestClient (readonly)
14 15 16 |
# File 'lib/test_sdk/macro/client.rb', line 14 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.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/test_sdk/macro/client.rb', line 149 def get_components(segmentation:, slug:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(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 |
#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.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/test_sdk/macro/client.rb', line 113 def get_gauge(segmentation:, slug: nil, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "slug": slug }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(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 |
#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.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/test_sdk/macro/client.rb', line 187 def get_market_context(segmentation:, slug:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(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 |
#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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/test_sdk/macro/client.rb', line 73 def (segmentation:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(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 |
#get_segmentations(request_options: nil) ⇒ Array<String>
Returns the available segmentations for the weather module.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/test_sdk/macro/client.rb', line 33 def get_segmentations(request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/data/weather/segmentations" end JSON.parse(response.body) end |