=begin #Svix API #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: 1.1.1 Generated by: https://openapi-generator.tech Generator version: 7.9.0 =end require 'cgi' module Svix class StatisticsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Aggregate App Stats # Creates a background task to calculate the message destinations for all applications in the environment. Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to retrieve the results of the operation. # @param app_usage_stats_in [AppUsageStatsIn] # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [AppUsageStatsOut] def v1_statistics_aggregate_app_stats(app_usage_stats_in, opts = {}) data, _status_code, _headers = v1_statistics_aggregate_app_stats_with_http_info(app_usage_stats_in, opts) data end # Aggregate App Stats # Creates a background task to calculate the message destinations for all applications in the environment. Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to retrieve the results of the operation. # @param app_usage_stats_in [AppUsageStatsIn] # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [Array<(AppUsageStatsOut, Integer, Hash)>] AppUsageStatsOut data, response status code and response headers def v1_statistics_aggregate_app_stats_with_http_info(app_usage_stats_in, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: StatisticsApi.v1_statistics_aggregate_app_stats ...' end # verify the required parameter 'app_usage_stats_in' is set if @api_client.config.client_side_validation && app_usage_stats_in.nil? fail ArgumentError, "Missing the required parameter 'app_usage_stats_in' when calling StatisticsApi.v1_statistics_aggregate_app_stats" end # resource path local_var_path = '/api/v1/stats/usage/app' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # 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 header_params[:'idempotency-key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(app_usage_stats_in) # return_type return_type = opts[:debug_return_type] || 'AppUsageStatsOut' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"StatisticsApi.v1_statistics_aggregate_app_stats", :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, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: StatisticsApi#v1_statistics_aggregate_app_stats\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Aggregate Event Types # Creates a background task to calculate the listed event types for all apps in the organization. Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to retrieve the results of the operation. # @param [Hash] opts the optional parameters # @return [AggregateEventTypesOut] def v1_statistics_aggregate_event_types(opts = {}) data, _status_code, _headers = v1_statistics_aggregate_event_types_with_http_info(opts) data end # Aggregate Event Types # Creates a background task to calculate the listed event types for all apps in the organization. Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to retrieve the results of the operation. # @param [Hash] opts the optional parameters # @return [Array<(AggregateEventTypesOut, Integer, Hash)>] AggregateEventTypesOut data, response status code and response headers def v1_statistics_aggregate_event_types_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: StatisticsApi.v1_statistics_aggregate_event_types ...' end # resource path local_var_path = '/api/v1/stats/usage/event-types' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'AggregateEventTypesOut' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"StatisticsApi.v1_statistics_aggregate_event_types", :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(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: StatisticsApi#v1_statistics_aggregate_event_types\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get App Attempt Stats # Returns application-level statistics on message attempts # @param app_id [String] The app's ID or UID # @param [Hash] opts the optional parameters # @option opts [Time] :start_date Filter the range to data starting from this date # @option opts [Time] :end_date Filter the range to data ending by this date # @return [AttemptStatisticsResponse] def v1_stats_app_attempts(app_id, opts = {}) data, _status_code, _headers = v1_stats_app_attempts_with_http_info(app_id, opts) data end # Get App Attempt Stats # Returns application-level statistics on message attempts # @param app_id [String] The app's ID or UID # @param [Hash] opts the optional parameters # @option opts [Time] :start_date Filter the range to data starting from this date # @option opts [Time] :end_date Filter the range to data ending by this date # @return [Array<(AttemptStatisticsResponse, Integer, Hash)>] AttemptStatisticsResponse data, response status code and response headers def v1_stats_app_attempts_with_http_info(app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: StatisticsApi.v1_stats_app_attempts ...' end # verify the required parameter 'app_id' is set if @api_client.config.client_side_validation && app_id.nil? fail ArgumentError, "Missing the required parameter 'app_id' when calling StatisticsApi.v1_stats_app_attempts" end if @api_client.config.client_side_validation && app_id.to_s.length > 256 fail ArgumentError, 'invalid value for "app_id" when calling StatisticsApi.v1_stats_app_attempts, the character length must be smaller than or equal to 256.' end if @api_client.config.client_side_validation && app_id.to_s.length < 1 fail ArgumentError, 'invalid value for "app_id" when calling StatisticsApi.v1_stats_app_attempts, the character length must be great than or equal to 1.' end pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/) if @api_client.config.client_side_validation && app_id !~ pattern fail ArgumentError, "invalid value for 'app_id' when calling StatisticsApi.v1_stats_app_attempts, must conform to the pattern #{pattern}." end # resource path local_var_path = '/api/v1/stats/app/{app_id}/attempt'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'startDate'] = opts[:'start_date'] if !opts[:'start_date'].nil? query_params[:'endDate'] = opts[:'end_date'] if !opts[:'end_date'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'AttemptStatisticsResponse' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"StatisticsApi.v1_stats_app_attempts", :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, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: StatisticsApi#v1_stats_app_attempts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Ep Stats # Returns endpoint-level statistics on message attempts # @param app_id [String] The app's ID or UID # @param endpoint_id [String] The ep's ID or UID # @param [Hash] opts the optional parameters # @option opts [Time] :start_date Filter the range to data starting from this date # @option opts [Time] :end_date Filter the range to data ending by this date # @return [AttemptStatisticsResponse] def v1_stats_endpoint_attempts(app_id, endpoint_id, opts = {}) data, _status_code, _headers = v1_stats_endpoint_attempts_with_http_info(app_id, endpoint_id, opts) data end # Get Ep Stats # Returns endpoint-level statistics on message attempts # @param app_id [String] The app's ID or UID # @param endpoint_id [String] The ep's ID or UID # @param [Hash] opts the optional parameters # @option opts [Time] :start_date Filter the range to data starting from this date # @option opts [Time] :end_date Filter the range to data ending by this date # @return [Array<(AttemptStatisticsResponse, Integer, Hash)>] AttemptStatisticsResponse data, response status code and response headers def v1_stats_endpoint_attempts_with_http_info(app_id, endpoint_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: StatisticsApi.v1_stats_endpoint_attempts ...' end # verify the required parameter 'app_id' is set if @api_client.config.client_side_validation && app_id.nil? fail ArgumentError, "Missing the required parameter 'app_id' when calling StatisticsApi.v1_stats_endpoint_attempts" end if @api_client.config.client_side_validation && app_id.to_s.length > 256 fail ArgumentError, 'invalid value for "app_id" when calling StatisticsApi.v1_stats_endpoint_attempts, the character length must be smaller than or equal to 256.' end if @api_client.config.client_side_validation && app_id.to_s.length < 1 fail ArgumentError, 'invalid value for "app_id" when calling StatisticsApi.v1_stats_endpoint_attempts, the character length must be great than or equal to 1.' end pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/) if @api_client.config.client_side_validation && app_id !~ pattern fail ArgumentError, "invalid value for 'app_id' when calling StatisticsApi.v1_stats_endpoint_attempts, must conform to the pattern #{pattern}." end # verify the required parameter 'endpoint_id' is set if @api_client.config.client_side_validation && endpoint_id.nil? fail ArgumentError, "Missing the required parameter 'endpoint_id' when calling StatisticsApi.v1_stats_endpoint_attempts" end if @api_client.config.client_side_validation && endpoint_id.to_s.length > 256 fail ArgumentError, 'invalid value for "endpoint_id" when calling StatisticsApi.v1_stats_endpoint_attempts, the character length must be smaller than or equal to 256.' end if @api_client.config.client_side_validation && endpoint_id.to_s.length < 1 fail ArgumentError, 'invalid value for "endpoint_id" when calling StatisticsApi.v1_stats_endpoint_attempts, the character length must be great than or equal to 1.' end pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/) if @api_client.config.client_side_validation && endpoint_id !~ pattern fail ArgumentError, "invalid value for 'endpoint_id' when calling StatisticsApi.v1_stats_endpoint_attempts, must conform to the pattern #{pattern}." end # resource path local_var_path = '/api/v1/stats/app/{app_id}/ep/{endpoint_id}/attempt'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'endpoint_id' + '}', CGI.escape(endpoint_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'startDate'] = opts[:'start_date'] if !opts[:'start_date'].nil? query_params[:'endDate'] = opts[:'end_date'] if !opts[:'end_date'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'AttemptStatisticsResponse' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"StatisticsApi.v1_stats_endpoint_attempts", :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, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: StatisticsApi#v1_stats_endpoint_attempts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end