Class: KlaviyoAPI::MetricsApi
- Inherits:
-
Object
- Object
- KlaviyoAPI::MetricsApi
- Defined in:
- lib/klaviyo-api-sdk/api/metrics_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#get_flows_triggered_by_metric(id, opts = {}) ⇒ Hash<String, Object>
(also: #get_flow_triggers_for_metric, #get_metric_flow_triggers)
Get Flows Triggered by Metric Get all flows where the given metric is being used as the trigger.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `flows:read` `metrics:read`. -
#get_flows_triggered_by_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #get_flow_triggers_for_metric_with_http_info, #get_metric_flow_triggers_with_http_info)
Get Flows Triggered by Metric Get all flows where the given metric is being used as the trigger.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `flows:read` `metrics:read`.
-
#get_ids_for_flows_triggered_by_metric(id, opts = {}) ⇒ Hash<String, Object>
(also: #get_flow_trigger_ids_for_metric, #get_metric_relationships_flow_triggers)
Get IDs for Flows Triggered by Metric Get the IDs of all flows where the given metric is being used as the trigger.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `flows:read` `metrics:read`. -
#get_ids_for_flows_triggered_by_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #get_flow_trigger_ids_for_metric_with_http_info, #get_metric_relationships_flow_triggers_with_http_info)
Get IDs for Flows Triggered by Metric Get the IDs of all flows where the given metric is being used as the trigger.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `flows:read` `metrics:read`.
-
#get_metric(id, opts = {}) ⇒ Hash<String, Object>
Get Metric Get a metric with the given metric ID.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `metrics:read`. -
#get_metric_for_metric_property(id, opts = {}) ⇒ Hash<String, Object>
(also: #get_metric_property_metric)
Get Metric for Metric Property Get the metric for the given metric property ID.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`. -
#get_metric_for_metric_property_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #get_metric_property_metric_with_http_info)
Get Metric for Metric Property Get the metric for the given metric property ID.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` Scopes: `metrics:read`.
-
#get_metric_id_for_metric_property(id, opts = {}) ⇒ Hash<String, Object>
(also: #get_metric_property_relationships_metric)
Get Metric ID for Metric Property Get the ID of the metric for the given metric property.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`. -
#get_metric_id_for_metric_property_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #get_metric_property_relationships_metric_with_http_info)
Get Metric ID for Metric Property Get the ID of the metric for the given metric property.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` Scopes: `metrics:read`.
-
#get_metric_property(id, opts = {}) ⇒ Hash<String, Object>
Get Metric Property Get a metric property with the given metric property ID.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`. -
#get_metric_property_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Metric Property Get a metric property with the given metric property ID.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` Scopes: `metrics:read`.
-
#get_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Metric Get a metric with the given metric ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `metrics:read`.
-
#get_metrics(opts = {}) ⇒ Hash<String, Object>
Get Metrics Get all metrics in an account.
-
#get_metrics_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Metrics Get all metrics in an account.
-
#get_properties_for_metric(id, opts = {}) ⇒ Hash<String, Object>
(also: #get_metric_metric_properties, #get_metric_properties)
Get Properties for Metric Get the metric properties for the given metric ID.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`. -
#get_properties_for_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #get_metric_metric_properties_with_http_info, #get_metric_properties_with_http_info)
Get Properties for Metric Get the metric properties for the given metric ID.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` Scopes: `metrics:read`.
-
#get_property_ids_for_metric(id, opts = {}) ⇒ Hash<String, Object>
(also: #get_metric_relationships_metric_properties, #get_metric_relationships_properties)
Get Property IDs for Metric Get the IDs of metric properties for the given metric.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`. -
#get_property_ids_for_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #get_metric_relationships_metric_properties_with_http_info, #get_metric_relationships_properties_with_http_info)
Get Property IDs for Metric Get the IDs of metric properties for the given metric.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` Scopes: `metrics:read`.
-
#initialize(api_client = ApiClient.default) ⇒ MetricsApi
constructor
A new instance of MetricsApi.
-
#query_metric_aggregates(metric_aggregate_query, opts = {}) ⇒ Hash<String, Object>
(also: #create_metric_aggregate)
Query Metric Aggregates Query and aggregate event data associated with a metric, including native Klaviyo metrics, integration-specific metrics, and custom events.
-
#query_metric_aggregates_with_http_info(metric_aggregate_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #create_metric_aggregate_with_http_info)
Query Metric Aggregates Query and aggregate event data associated with a metric, including native Klaviyo metrics, integration-specific metrics, and custom events.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ MetricsApi
Returns a new instance of MetricsApi.
19 20 21 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#get_flows_triggered_by_metric(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_flow_triggers_for_metric, get_metric_flow_triggers
Get Flows Triggered by Metric Get all flows where the given metric is being used as the trigger.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `flows:read` `metrics:read`
28 29 30 31 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 28 def get_flows_triggered_by_metric(id, opts = {}) data, _status_code, _headers = get_flows_triggered_by_metric_with_http_info(id, opts) data end |
#get_flows_triggered_by_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_flow_triggers_for_metric_with_http_info, get_metric_flow_triggers_with_http_info
Get Flows Triggered by Metric Get all flows where the given metric is being used as the trigger.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `flows:read` `metrics:read`
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 45 def get_flows_triggered_by_metric_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_flows_triggered_by_metric ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_flows_triggered_by_metric" end allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"] if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/metrics/{id}/flow-triggers'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] = opts.merge( :operation => :"MetricsApi.get_flows_triggered_by_metric", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#get_flows_triggered_by_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_ids_for_flows_triggered_by_metric(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_flow_trigger_ids_for_metric, get_metric_relationships_flow_triggers
Get IDs for Flows Triggered by Metric Get the IDs of all flows where the given metric is being used as the trigger.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `flows:read` `metrics:read`
111 112 113 114 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 111 def get_ids_for_flows_triggered_by_metric(id, opts = {}) data, _status_code, _headers = get_ids_for_flows_triggered_by_metric_with_http_info(id, opts) data end |
#get_ids_for_flows_triggered_by_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_flow_trigger_ids_for_metric_with_http_info, get_metric_relationships_flow_triggers_with_http_info
Get IDs for Flows Triggered by Metric Get the IDs of all flows where the given metric is being used as the trigger.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `flows:read` `metrics:read`
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 127 def get_ids_for_flows_triggered_by_metric_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_ids_for_flows_triggered_by_metric ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_ids_for_flows_triggered_by_metric" end # resource path local_var_path = '/api/metrics/{id}/relationships/flow-triggers'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] = opts.merge( :operation => :"MetricsApi.get_ids_for_flows_triggered_by_metric", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#get_ids_for_flows_triggered_by_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_metric(id, opts = {}) ⇒ Hash<String, Object>
Get Metric Get a metric with the given metric ID.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `metrics:read`
191 192 193 194 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 191 def get_metric(id, opts = {}) data, _status_code, _headers = get_metric_with_http_info(id, opts) data end |
#get_metric_for_metric_property(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_metric_property_metric
Get Metric for Metric Property Get the metric for the given metric property ID.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`
275 276 277 278 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 275 def get_metric_for_metric_property(id, opts = {}) data, _status_code, _headers = get_metric_for_metric_property_with_http_info(id, opts) data end |
#get_metric_for_metric_property_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_metric_property_metric_with_http_info
Get Metric for Metric Property Get the metric for the given metric property ID.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` Scopes: `metrics:read`
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 289 def get_metric_for_metric_property_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_for_metric_property ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_metric_for_metric_property" end allowable_values = ["name", "created", "updated", "integration"] if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/metric-properties/{id}/metric'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] = opts.merge( :operation => :"MetricsApi.get_metric_for_metric_property", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#get_metric_for_metric_property\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_metric_id_for_metric_property(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_metric_property_relationships_metric
Get Metric ID for Metric Property Get the ID of the metric for the given metric property.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`
352 353 354 355 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 352 def get_metric_id_for_metric_property(id, opts = {}) data, _status_code, _headers = get_metric_id_for_metric_property_with_http_info(id, opts) data end |
#get_metric_id_for_metric_property_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_metric_property_relationships_metric_with_http_info
Get Metric ID for Metric Property Get the ID of the metric for the given metric property.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` Scopes: `metrics:read`
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 365 def get_metric_id_for_metric_property_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_id_for_metric_property ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_metric_id_for_metric_property" end # resource path local_var_path = '/api/metric-properties/{id}/relationships/metric'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] = opts.merge( :operation => :"MetricsApi.get_metric_id_for_metric_property", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#get_metric_id_for_metric_property\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_metric_property(id, opts = {}) ⇒ Hash<String, Object>
Get Metric Property Get a metric property with the given metric property ID.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`
427 428 429 430 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 427 def get_metric_property(id, opts = {}) data, _status_code, _headers = get_metric_property_with_http_info(id, opts) data end |
#get_metric_property_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Metric Property Get a metric property with the given metric property ID.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` Scopes: `metrics:read`
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 441 def get_metric_property_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_property ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_metric_property" end allowable_values = ["sample_values"] if @api_client.config.client_side_validation && opts[:'additional_fields_metric_property'] && !opts[:'additional_fields_metric_property'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"additional_fields_metric_property\", must include one of #{allowable_values}" end allowable_values = ["label", "property", "inferred_type", "sample_values"] if @api_client.config.client_side_validation && opts[:'fields_metric_property'] && !opts[:'fields_metric_property'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_metric_property\", must include one of #{allowable_values}" end allowable_values = ["name", "created", "updated", "integration"] if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}" end allowable_values = ["metric"] if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/metric-properties/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'additional-fields[metric-property]'] = @api_client.build_collection_param(opts[:'additional_fields_metric_property'], :csv) if !opts[:'additional_fields_metric_property'].nil? query_params[:'fields[metric-property]'] = @api_client.build_collection_param(opts[:'fields_metric_property'], :csv) if !opts[:'fields_metric_property'].nil? query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil? query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] = opts.merge( :operation => :"MetricsApi.get_metric_property", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#get_metric_property\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Metric Get a metric with the given metric ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `metrics:read`
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 204 def get_metric_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_metric" end allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"] if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}" end allowable_values = ["name", "created", "updated", "integration"] if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}" end allowable_values = ["flow-triggers"] if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/metrics/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil? query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil? query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] = opts.merge( :operation => :"MetricsApi.get_metric", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#get_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_metrics(opts = {}) ⇒ Hash<String, Object>
Get Metrics Get all metrics in an account. Requests can be filtered by the following fields: integration ‘name`, integration `category` Returns a maximum of 200 results per page.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` Scopes: `metrics:read`
520 521 522 523 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 520 def get_metrics(opts = {}) data, _status_code, _headers = get_metrics_with_http_info(opts) data end |
#get_metrics_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Metrics Get all metrics in an account. Requests can be filtered by the following fields: integration `name`, integration `category` Returns a maximum of 200 results per page.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `metrics:read`
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 534 def get_metrics_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_metrics ...' end allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"] if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}" end allowable_values = ["name", "created", "updated", "integration"] if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}" end allowable_values = ["flow-triggers"] if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/metrics' # query parameters query_params = opts[:query_params] || {} query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil? query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil? query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil? query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil? query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] = opts.merge( :operation => :"MetricsApi.get_metrics", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#get_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_properties_for_metric(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_metric_metric_properties, get_metric_properties
Get Properties for Metric Get the metric properties for the given metric ID.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`
604 605 606 607 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 604 def get_properties_for_metric(id, opts = {}) data, _status_code, _headers = get_properties_for_metric_with_http_info(id, opts) data end |
#get_properties_for_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_metric_metric_properties_with_http_info, get_metric_properties_with_http_info
Get Properties for Metric Get the metric properties for the given metric ID.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` Scopes: `metrics:read`
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 622 def get_properties_for_metric_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_properties_for_metric ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_properties_for_metric" end allowable_values = ["sample_values"] if @api_client.config.client_side_validation && opts[:'additional_fields_metric_property'] && !opts[:'additional_fields_metric_property'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"additional_fields_metric_property\", must include one of #{allowable_values}" end allowable_values = ["label", "property", "inferred_type", "sample_values"] if @api_client.config.client_side_validation && opts[:'fields_metric_property'] && !opts[:'fields_metric_property'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_metric_property\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/metrics/{id}/metric-properties'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'additional-fields[metric-property]'] = @api_client.build_collection_param(opts[:'additional_fields_metric_property'], :csv) if !opts[:'additional_fields_metric_property'].nil? query_params[:'fields[metric-property]'] = @api_client.build_collection_param(opts[:'fields_metric_property'], :csv) if !opts[:'fields_metric_property'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] = opts.merge( :operation => :"MetricsApi.get_properties_for_metric", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#get_properties_for_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_property_ids_for_metric(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_metric_relationships_metric_properties, get_metric_relationships_properties
Get Property IDs for Metric Get the IDs of metric properties for the given metric.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`
693 694 695 696 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 693 def get_property_ids_for_metric(id, opts = {}) data, _status_code, _headers = get_property_ids_for_metric_with_http_info(id, opts) data end |
#get_property_ids_for_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_metric_relationships_metric_properties_with_http_info, get_metric_relationships_properties_with_http_info
Get Property IDs for Metric Get the IDs of metric properties for the given metric.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` Scopes: `metrics:read`
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 709 def get_property_ids_for_metric_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_property_ids_for_metric ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_property_ids_for_metric" end # resource path local_var_path = '/api/metrics/{id}/relationships/metric-properties'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] = opts.merge( :operation => :"MetricsApi.get_property_ids_for_metric", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#get_property_ids_for_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#query_metric_aggregates(metric_aggregate_query, opts = {}) ⇒ Hash<String, Object> Also known as: create_metric_aggregate
Query Metric Aggregates Query and aggregate event data associated with a metric, including native Klaviyo metrics, integration-specific metrics, and custom events. Queries must be passed in the JSON body of your ‘POST` request. To request campaign and flow performance data that matches the data shown in Klaviyo’s UI, we recommend the [Reporting API](developers.klaviyo.com/en/reference/reporting_api_overview). Results can be filtered and grouped by time, event, or profile dimensions. To learn more about how to use this endpoint, check out our new [Using the Query Metric Aggregates Endpoint guide](developers.klaviyo.com/en/docs/using-the-query-metric-aggregates-endpoint). For a comprehensive list of request body parameters, native Klaviyo metrics, and their associated attributes for grouping and filtering, please refer to the [metrics attributes guide](developers.klaviyo.com/en/docs/supported_metrics_and_attributes).
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `metrics:read`
770 771 772 773 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 770 def query_metric_aggregates(metric_aggregate_query, opts = {}) data, _status_code, _headers = query_metric_aggregates_with_http_info(metric_aggregate_query, opts) data end |
#query_metric_aggregates_with_http_info(metric_aggregate_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: create_metric_aggregate_with_http_info
Query Metric Aggregates Query and aggregate event data associated with a metric, including native Klaviyo metrics, integration-specific metrics, and custom events. Queries must be passed in the JSON body of your `POST` request. To request campaign and flow performance data that matches the data shown in Klaviyo's UI, we recommend the [Reporting API](developers.klaviyo.com/en/reference/reporting_api_overview). Results can be filtered and grouped by time, event, or profile dimensions. To learn more about how to use this endpoint, check out our new [Using the Query Metric Aggregates Endpoint guide](developers.klaviyo.com/en/docs/using-the-query-metric-aggregates-endpoint). For a comprehensive list of request body parameters, native Klaviyo metrics, and their associated attributes for grouping and filtering, please refer to the [metrics attributes guide](developers.klaviyo.com/en/docs/supported_metrics_and_attributes).<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` Scopes: `metrics:read`
783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 |
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 783 def query_metric_aggregates_with_http_info(metric_aggregate_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.query_metric_aggregates ...' end # verify the required parameter 'metric_aggregate_query' is set if @api_client.config.client_side_validation && metric_aggregate_query.nil? fail ArgumentError, "Missing the required parameter 'metric_aggregate_query' when calling MetricsApi.query_metric_aggregates" end # resource path local_var_path = '/api/metric-aggregates' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/vnd.api+json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(metric_aggregate_query) # return_type return_type = opts[:debug_return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] = opts.merge( :operation => :"MetricsApi.query_metric_aggregates", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsApi#query_metric_aggregates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |