Class: KlaviyoBeta::MetricsApi
- Inherits:
-
Object
- Object
- KlaviyoBeta::MetricsApi
- Defined in:
- lib/klaviyo_sdk_beta/api/metrics_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#get_metric(id, opts = {}) ⇒ Hash<String, Object>
Get Metric Get a specific Metric by id
*Rate limits*:
Burst: `10/s`
Steady: `150/m`. -
#get_metric_aggregate(metric_aggregate_query, opts = {}) ⇒ Hash<String, Object>
Get Metric Aggregate Query & aggregate event data associated with specific metrics, optionally filtering & grouping results by time, event or profile dimensions.
-
#get_metric_aggregate_with_http_info(metric_aggregate_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Metric Aggregate Query & aggregate event data associated with specific metrics, optionally filtering & grouping results by time, event or profile dimensions.
-
#get_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Metric Get a specific Metric by id<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m`.
-
#get_metrics(opts = {}) ⇒ Hash<String, Object>
Get Metrics Returns a list of all Metric objects in an account, that can optionally be filtered by integration name and/or category.
*Rate limits*:
Burst: `10/s`
Steady: `150/m`. -
#get_metrics_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Metrics Returns a list of all Metric objects in an account, that can optionally be filtered by integration name and/or category.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m`.
-
#initialize(api_client = ApiClient.default) ⇒ MetricsApi
constructor
A new instance of MetricsApi.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ MetricsApi
Returns a new instance of MetricsApi.
19 20 21 |
# File 'lib/klaviyo_sdk_beta/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_sdk_beta/api/metrics_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#get_metric(id, opts = {}) ⇒ Hash<String, Object>
Get Metric Get a specific Metric by id
*Rate limits*:
Burst: `10/s`
Steady: `150/m`
28 29 30 31 |
# File 'lib/klaviyo_sdk_beta/api/metrics_api.rb', line 28 def get_metric(id, opts = {}) data, _status_code, _headers = get_metric_with_http_info(id, opts) data end |
#get_metric_aggregate(metric_aggregate_query, opts = {}) ⇒ Hash<String, Object>
Get Metric Aggregate Query & aggregate event data associated with specific metrics, optionally filtering & grouping results by time, event or profile dimensions. </br> This endpoint lets you form queries in your `POST` request body rather than query parameters for simpler query syntax. </br> **Request body parameters** (all nested under `attributes`): * `return_fields`: Provide fields to limit the returned data * `sort`: Provide a sort key (e.g. `"-timestamp"`) * `page_cursor`: Optional pagination cursor to iterate over large result sets * `measurement`: Measurement key, e.g `"sum"`, `"sum_value"`, `"count"` * `interval`: Aggregation interval, e.g. `"hour"`,`"day"`,`"week"`,`"month"` * `page_size`: Limit the number of returned results * `by`: Optional attribute(s) used for grouping by the aggregation function * `metric_id`: The metric ID used in the aggregation * `filter`: List of filters, must include time range using ISO 8601 format (`"YYYY-MM-DDTHH:MM:SS.mmmmmm"`) * `timezone`: The timezone used for processing the query </br> For a comprehensive list of native Klaviyo metrics and their associated attributes for grouping & filtering, please refer to our [Native Klaviyo Metrics & Attributes](developers.klaviyo.com/en/reference/klaviyo-metrics-attributes) guide for our V1 APIs.
*Rate limits*:
Burst: `3/s`
Steady: `60/m`
99 100 101 102 |
# File 'lib/klaviyo_sdk_beta/api/metrics_api.rb', line 99 def get_metric_aggregate(metric_aggregate_query, opts = {}) data, _status_code, _headers = get_metric_aggregate_with_http_info(metric_aggregate_query, opts) data end |
#get_metric_aggregate_with_http_info(metric_aggregate_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Metric Aggregate Query & aggregate event data associated with specific metrics, optionally filtering & grouping results by time, event or profile dimensions. </br> This endpoint lets you form queries in your `POST` request body rather than query parameters for simpler query syntax. </br> **Request body parameters** (all nested under `attributes`): * `return_fields`: Provide fields to limit the returned data * `sort`: Provide a sort key (e.g. `"-timestamp"`) * `page_cursor`: Optional pagination cursor to iterate over large result sets * `measurement`: Measurement key, e.g `"sum"`, `"sum_value"`, `"count"` * `interval`: Aggregation interval, e.g. `"hour"`,`"day"`,`"week"`,`"month"` * `page_size`: Limit the number of returned results * `by`: Optional attribute(s) used for grouping by the aggregation function * `metric_id`: The metric ID used in the aggregation * `filter`: List of filters, must include time range using ISO 8601 format (`"YYYY-MM-DDTHH:MM:SS.mmmmmm"`) * `timezone`: The timezone used for processing the query </br> For a comprehensive list of native Klaviyo metrics and their associated attributes for grouping & filtering, please refer to our [Native Klaviyo Metrics & Attributes](developers.klaviyo.com/en/reference/klaviyo-metrics-attributes) guide for our V1 APIs.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m`
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 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 |
# File 'lib/klaviyo_sdk_beta/api/metrics_api.rb', line 109 def get_metric_aggregate_with_http_info(metric_aggregate_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_aggregate ...' 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.get_metric_aggregate" 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['API_REVISION'] || "2022-09-07.pre" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/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'] = opts.merge( :operation => :"MetricsApi.get_metric_aggregate", :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#get_metric_aggregate\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 specific Metric by id<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m`
39 40 41 42 43 44 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 |
# File 'lib/klaviyo_sdk_beta/api/metrics_api.rb', line 39 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", "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/metrics/{id}/'.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['API_REVISION'] || "2022-09-07.pre" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/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'] = 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 Returns a list of all Metric objects in an account, that can optionally be filtered by integration name and/or category.
*Rate limits*:
Burst: `10/s`
Steady: `150/m`
170 171 172 173 |
# File 'lib/klaviyo_sdk_beta/api/metrics_api.rb', line 170 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 Returns a list of all Metric objects in an account, that can optionally be filtered by integration name and/or category.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m`
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 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 |
# File 'lib/klaviyo_sdk_beta/api/metrics_api.rb', line 181 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", "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/metrics/' # 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? 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['API_REVISION'] || "2022-09-07.pre" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/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'] = 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 |