=begin #Subskribe API #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: 1.0.0 Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.41 =end require 'uri' module SubskribeDevClient class UsageApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Add and apply bulk payments to invoices CSV # Bulk upload payments to invoices in CSV file # @param [Hash] opts the optional parameters # @option opts [File] :file # @return [BulkPaymentUploadResult] def add_and_apply_bulk_payments_csv(opts = {}) data, _status_code, _headers = add_and_apply_bulk_payments_csv_with_http_info(opts) data end # Add and apply bulk payments to invoices CSV # Bulk upload payments to invoices in CSV file # @param [Hash] opts the optional parameters # @option opts [File] :file # @return [Array<(BulkPaymentUploadResult, Fixnum, Hash)>] BulkPaymentUploadResult data, response status code and response headers def add_and_apply_bulk_payments_csv_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.add_and_apply_bulk_payments_csv ...' end # resource path local_var_path = '/settlements/addAndApplyPaymentsInBulk/csv' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['file'] = opts[:'file'] if !opts[:'file'].nil? # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'BulkPaymentUploadResult') if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#add_and_apply_bulk_payments_csv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Add usage record # Load usage records into the system # @param [Hash] opts the optional parameters # @option opts [RawUsagesData] :body # @return [UsageBatchInsertResult] def add_usage(opts = {}) data, _status_code, _headers = add_usage_with_http_info(opts) data end # Add usage record # Load usage records into the system # @param [Hash] opts the optional parameters # @option opts [RawUsagesData] :body # @return [Array<(UsageBatchInsertResult, Fixnum, Hash)>] UsageBatchInsertResult data, response status code and response headers def add_usage_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.add_usage ...' end # resource path local_var_path = '/v2/usage' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'UsageBatchInsertResult') if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#add_usage\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get aggregated usage # Retrieve the current aggregated usage data for a subscription between 2 instants # @param subscription_id # @param from # @param to # @param [Hash] opts the optional parameters # @return [Array] def get_usage_aggregates_for_subscription(subscription_id, from, to, opts = {}) data, _status_code, _headers = get_usage_aggregates_for_subscription_with_http_info(subscription_id, from, to, opts) data end # Get aggregated usage # Retrieve the current aggregated usage data for a subscription between 2 instants # @param subscription_id # @param from # @param to # @param [Hash] opts the optional parameters # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def get_usage_aggregates_for_subscription_with_http_info(subscription_id, from, to, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.get_usage_aggregates_for_subscription ...' end # verify the required parameter 'subscription_id' is set if @api_client.config.client_side_validation && subscription_id.nil? fail ArgumentError, "Missing the required parameter 'subscription_id' when calling UsageApi.get_usage_aggregates_for_subscription" end # verify the required parameter 'from' is set if @api_client.config.client_side_validation && from.nil? fail ArgumentError, "Missing the required parameter 'from' when calling UsageApi.get_usage_aggregates_for_subscription" end # verify the required parameter 'to' is set if @api_client.config.client_side_validation && to.nil? fail ArgumentError, "Missing the required parameter 'to' when calling UsageApi.get_usage_aggregates_for_subscription" end # resource path local_var_path = '/v2/usage/{subscriptionId}'.sub('{' + 'subscriptionId' + '}', subscription_id.to_s) # query parameters query_params = {} query_params[:'from'] = from query_params[:'to'] = to # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Array') if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#get_usage_aggregates_for_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get usage arrival checkpoint # Retrieve the latest usage record upload to the system as epoch seconds # @param [Hash] opts the optional parameters # @return [nil] def get_usage_arrival_time_checkpoint(opts = {}) get_usage_arrival_time_checkpoint_with_http_info(opts) nil end # Get usage arrival checkpoint # Retrieve the latest usage record upload to the system as epoch seconds # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def get_usage_arrival_time_checkpoint_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.get_usage_arrival_time_checkpoint ...' end # resource path local_var_path = '/v2/usage/aggregate/usageArrivalTimeCheckpoint' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#get_usage_arrival_time_checkpoint\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all prepaid drawdown usage stats # Retrieve the current prepaid drawdown statistics for all subscriptions for a time range # @param from # @param to # @param [Hash] opts the optional parameters # @return [Array] def get_usage_stats_for_all_subscriptions(from, to, opts = {}) data, _status_code, _headers = get_usage_stats_for_all_subscriptions_with_http_info(from, to, opts) data end # Get all prepaid drawdown usage stats # Retrieve the current prepaid drawdown statistics for all subscriptions for a time range # @param from # @param to # @param [Hash] opts the optional parameters # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def get_usage_stats_for_all_subscriptions_with_http_info(from, to, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.get_usage_stats_for_all_subscriptions ...' end # verify the required parameter 'from' is set if @api_client.config.client_side_validation && from.nil? fail ArgumentError, "Missing the required parameter 'from' when calling UsageApi.get_usage_stats_for_all_subscriptions" end # verify the required parameter 'to' is set if @api_client.config.client_side_validation && to.nil? fail ArgumentError, "Missing the required parameter 'to' when calling UsageApi.get_usage_stats_for_all_subscriptions" end # resource path local_var_path = '/v2/usage/stats' # query parameters query_params = {} query_params[:'from'] = from query_params[:'to'] = to # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Array') if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#get_usage_stats_for_all_subscriptions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all prepaid drawdown usage stats CSV # Retrieve the current prepaid drawdown statistics for all subscriptions for a time range in CSV format # @param from # @param to # @param [Hash] opts the optional parameters # @return [nil] def get_usage_stats_for_all_subscriptions_csv(from, to, opts = {}) get_usage_stats_for_all_subscriptions_csv_with_http_info(from, to, opts) nil end # Get all prepaid drawdown usage stats CSV # Retrieve the current prepaid drawdown statistics for all subscriptions for a time range in CSV format # @param from # @param to # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def get_usage_stats_for_all_subscriptions_csv_with_http_info(from, to, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.get_usage_stats_for_all_subscriptions_csv ...' end # verify the required parameter 'from' is set if @api_client.config.client_side_validation && from.nil? fail ArgumentError, "Missing the required parameter 'from' when calling UsageApi.get_usage_stats_for_all_subscriptions_csv" end # verify the required parameter 'to' is set if @api_client.config.client_side_validation && to.nil? fail ArgumentError, "Missing the required parameter 'to' when calling UsageApi.get_usage_stats_for_all_subscriptions_csv" end # resource path local_var_path = '/v2/usage/stats/csv' # query parameters query_params = {} query_params[:'from'] = from query_params[:'to'] = to # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream', 'application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#get_usage_stats_for_all_subscriptions_csv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get prepaid drawdown usage stats for subscription # Retrieve the current prepaid drawdown statistics for a subscription # @param subscription_id ID of subscription to retrieve usages stats for # @param [Hash] opts the optional parameters # @return [Array] def get_usage_stats_for_subscription(subscription_id, opts = {}) data, _status_code, _headers = get_usage_stats_for_subscription_with_http_info(subscription_id, opts) data end # Get prepaid drawdown usage stats for subscription # Retrieve the current prepaid drawdown statistics for a subscription # @param subscription_id ID of subscription to retrieve usages stats for # @param [Hash] opts the optional parameters # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def get_usage_stats_for_subscription_with_http_info(subscription_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.get_usage_stats_for_subscription ...' end # verify the required parameter 'subscription_id' is set if @api_client.config.client_side_validation && subscription_id.nil? fail ArgumentError, "Missing the required parameter 'subscription_id' when calling UsageApi.get_usage_stats_for_subscription" end # resource path local_var_path = '/v2/usage/stats/{subscriptionId}'.sub('{' + 'subscriptionId' + '}', subscription_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Array') if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#get_usage_stats_for_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get prepaid drawdown usage stats CSV # Retrieve the current prepaid drawdown statistics for a subscription in CSV format # @param subscription_id # @param [Hash] opts the optional parameters # @return [nil] def get_usage_stats_for_subscription_csv(subscription_id, opts = {}) get_usage_stats_for_subscription_csv_with_http_info(subscription_id, opts) nil end # Get prepaid drawdown usage stats CSV # Retrieve the current prepaid drawdown statistics for a subscription in CSV format # @param subscription_id # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def get_usage_stats_for_subscription_csv_with_http_info(subscription_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.get_usage_stats_for_subscription_csv ...' end # verify the required parameter 'subscription_id' is set if @api_client.config.client_side_validation && subscription_id.nil? fail ArgumentError, "Missing the required parameter 'subscription_id' when calling UsageApi.get_usage_stats_for_subscription_csv" end # resource path local_var_path = '/v2/usage/stats/{subscriptionId}/csv'.sub('{' + 'subscriptionId' + '}', subscription_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream', 'application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#get_usage_stats_for_subscription_csv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get prepaid drawdown usage stats PDF # Retrieve the current prepaid drawdown statistics for a subscription in PDF format # @param subscription_id # @param [Hash] opts the optional parameters # @return [nil] def get_usage_stats_for_subscription_pdf(subscription_id, opts = {}) get_usage_stats_for_subscription_pdf_with_http_info(subscription_id, opts) nil end # Get prepaid drawdown usage stats PDF # Retrieve the current prepaid drawdown statistics for a subscription in PDF format # @param subscription_id # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def get_usage_stats_for_subscription_pdf_with_http_info(subscription_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.get_usage_stats_for_subscription_pdf ...' end # verify the required parameter 'subscription_id' is set if @api_client.config.client_side_validation && subscription_id.nil? fail ArgumentError, "Missing the required parameter 'subscription_id' when calling UsageApi.get_usage_stats_for_subscription_pdf" end # resource path local_var_path = '/v2/usage/stats/{subscriptionId}/pdf'.sub('{' + 'subscriptionId' + '}', subscription_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream', 'application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#get_usage_stats_for_subscription_pdf\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Aggregate raw usage # Trigger the process to aggregate any remaining raw usage records # @param [Hash] opts the optional parameters # @return [nil] def perform_on_demand_usage_aggregation(opts = {}) perform_on_demand_usage_aggregation_with_http_info(opts) nil end # Aggregate raw usage # Trigger the process to aggregate any remaining raw usage records # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def perform_on_demand_usage_aggregation_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.perform_on_demand_usage_aggregation ...' end # resource path local_var_path = '/v2/usage/aggregate' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#perform_on_demand_usage_aggregation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Upload usage record CSV # Upload usage records in CSV file. Each row of the file represents a single usage record # @param [Hash] opts the optional parameters # @option opts [File] :file # @return [UsageBatchInsertResult] def upload_subscription_usage_csv(opts = {}) data, _status_code, _headers = upload_subscription_usage_csv_with_http_info(opts) data end # Upload usage record CSV # Upload usage records in CSV file. Each row of the file represents a single usage record # @param [Hash] opts the optional parameters # @option opts [File] :file # @return [Array<(UsageBatchInsertResult, Fixnum, Hash)>] UsageBatchInsertResult data, response status code and response headers def upload_subscription_usage_csv_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UsageApi.upload_subscription_usage_csv ...' end # resource path local_var_path = '/v2/usage/csv' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['file'] = opts[:'file'] if !opts[:'file'].nil? # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'UsageBatchInsertResult') if @api_client.config.debugging @api_client.config.logger.debug "API called: UsageApi#upload_subscription_usage_csv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end