=begin
#BillForward REST 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

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=end

require "uri"

module BillForward
  class AnalyticsApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end

    # Gets outstanding debts per account, within a date range.
    # {\"nickname\" : \"Get account debts\",\"response\" : \"getAccountDebts.html\"}
    # @param debts_per_account The payments-per-account object.
    # @param [Hash] opts the optional parameters
    # @return [AccountPaymentsResultPagedMetadata]
    def get_account_debts(debts_per_account, opts = {})
      data, _status_code, _headers = get_account_debts_with_http_info(debts_per_account, opts)
      return data
    end

    # Gets outstanding debts per account, within a date range.
    # {\&quot;nickname\&quot; : \&quot;Get account debts\&quot;,\&quot;response\&quot; : \&quot;getAccountDebts.html\&quot;}
    # @param debts_per_account The payments-per-account object.
    # @param [Hash] opts the optional parameters
    # @return [Array<(AccountPaymentsResultPagedMetadata, Fixnum, Hash)>] AccountPaymentsResultPagedMetadata data, response status code and response headers
    def get_account_debts_with_http_info(debts_per_account, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_account_debts ..."
      end
      # verify the required parameter 'debts_per_account' is set
      fail ArgumentError, "Missing the required parameter 'debts_per_account' when calling AnalyticsApi.get_account_debts" if debts_per_account.nil?
      # resource path
      local_var_path = "/analytics/payments/accounts/outstanding".sub('{format}','json')

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = ['application/json']
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(debts_per_account)
      auth_names = []
      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 => 'AccountPaymentsResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_account_debts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets an account's life-time value, as of a given end date.
    # {\"nickname\":\"Get account life-time value\",\"response\":\"getAccountLTV.html\"}
    # @param account_id The id of the account.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return. (default to 0)
    # @option opts [Integer] :records The maximum number of amendments to return. (default to 8766)
    # @option opts [String] :order_by Specify a field used to order the result set. (default to created)
    # @option opts [String] :order The direction of any ordering, either ASC or DESC. (default to ASC)
    # @return [AccountLTVResultPagedMetadata]
    def get_account_ltv(account_id, end_datetime, opts = {})
      data, _status_code, _headers = get_account_ltv_with_http_info(account_id, end_datetime, opts)
      return data
    end

    # Gets an account&#39;s life-time value, as of a given end date.
    # {\&quot;nickname\&quot;:\&quot;Get account life-time value\&quot;,\&quot;response\&quot;:\&quot;getAccountLTV.html\&quot;}
    # @param account_id The id of the account.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return.
    # @option opts [Integer] :records The maximum number of amendments to return.
    # @option opts [String] :order_by Specify a field used to order the result set.
    # @option opts [String] :order The direction of any ordering, either ASC or DESC.
    # @return [Array<(AccountLTVResultPagedMetadata, Fixnum, Hash)>] AccountLTVResultPagedMetadata data, response status code and response headers
    def get_account_ltv_with_http_info(account_id, end_datetime, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_account_ltv ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling AnalyticsApi.get_account_ltv" if account_id.nil?
      # verify the required parameter 'end_datetime' is set
      fail ArgumentError, "Missing the required parameter 'end_datetime' when calling AnalyticsApi.get_account_ltv" if end_datetime.nil?
      if opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
        fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
      end
      # resource path
      local_var_path = "/analytics/account-ltv/{account-id}/{end-datetime}".sub('{format}','json').sub('{' + 'account-id' + '}', account_id.to_s).sub('{' + 'end-datetime' + '}', end_datetime.to_s)

      # query parameters
      query_params = {}
      query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
      query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
      query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = []
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      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 => 'AccountLTVResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_account_ltv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets hourly payments per product, within a date range.
    # {\"nickname\" : \"Get payments per account\",\"response\" : \"getAccountPayments.html\"}
    # @param payments_per_account The payments-per-account object.
    # @param [Hash] opts the optional parameters
    # @return [AccountPaymentsResultPagedMetadata]
    def get_account_payments(payments_per_account, opts = {})
      data, _status_code, _headers = get_account_payments_with_http_info(payments_per_account, opts)
      return data
    end

    # Gets hourly payments per product, within a date range.
    # {\&quot;nickname\&quot; : \&quot;Get payments per account\&quot;,\&quot;response\&quot; : \&quot;getAccountPayments.html\&quot;}
    # @param payments_per_account The payments-per-account object.
    # @param [Hash] opts the optional parameters
    # @return [Array<(AccountPaymentsResultPagedMetadata, Fixnum, Hash)>] AccountPaymentsResultPagedMetadata data, response status code and response headers
    def get_account_payments_with_http_info(payments_per_account, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_account_payments ..."
      end
      # verify the required parameter 'payments_per_account' is set
      fail ArgumentError, "Missing the required parameter 'payments_per_account' when calling AnalyticsApi.get_account_payments" if payments_per_account.nil?
      # resource path
      local_var_path = "/analytics/payments/accounts".sub('{format}','json')

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = ['application/json']
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(payments_per_account)
      auth_names = []
      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 => 'AccountPaymentsResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_account_payments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets all payments managed by BillForward, within a date range.
    # {\"nickname\":\"Get managed payments\",\"response\":\"getManagedPayments.html\"}
    # @param start_datetime The UTC DateTime specifying the start of the result period.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return. (default to 0)
    # @option opts [Integer] :records The maximum number of amendments to return. (default to 8766)
    # @option opts [String] :order_by Specify a field used to order the result set. (default to created)
    # @option opts [String] :order The direction of any ordering, either ASC or DESC. (default to ASC)
    # @return [BillforwardManagedPaymentsResultPagedMetadata]
    def get_billforward_managed_payments(start_datetime, end_datetime, opts = {})
      data, _status_code, _headers = get_billforward_managed_payments_with_http_info(start_datetime, end_datetime, opts)
      return data
    end

    # Gets all payments managed by BillForward, within a date range.
    # {\&quot;nickname\&quot;:\&quot;Get managed payments\&quot;,\&quot;response\&quot;:\&quot;getManagedPayments.html\&quot;}
    # @param start_datetime The UTC DateTime specifying the start of the result period.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return.
    # @option opts [Integer] :records The maximum number of amendments to return.
    # @option opts [String] :order_by Specify a field used to order the result set.
    # @option opts [String] :order The direction of any ordering, either ASC or DESC.
    # @return [Array<(BillforwardManagedPaymentsResultPagedMetadata, Fixnum, Hash)>] BillforwardManagedPaymentsResultPagedMetadata data, response status code and response headers
    def get_billforward_managed_payments_with_http_info(start_datetime, end_datetime, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_billforward_managed_payments ..."
      end
      # verify the required parameter 'start_datetime' is set
      fail ArgumentError, "Missing the required parameter 'start_datetime' when calling AnalyticsApi.get_billforward_managed_payments" if start_datetime.nil?
      # verify the required parameter 'end_datetime' is set
      fail ArgumentError, "Missing the required parameter 'end_datetime' when calling AnalyticsApi.get_billforward_managed_payments" if end_datetime.nil?
      if opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
        fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
      end
      # resource path
      local_var_path = "/analytics/billforward-managed-payments/{start-datetime}/{end-datetime}".sub('{format}','json').sub('{' + 'start-datetime' + '}', start_datetime.to_s).sub('{' + 'end-datetime' + '}', end_datetime.to_s)

      # query parameters
      query_params = {}
      query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
      query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
      query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = []
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      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 => 'BillforwardManagedPaymentsResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_billforward_managed_payments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets churn, within a date range.
    # {\"nickname\":\"Get churn\",\"response\":\"getChurn.html\"}
    # @param start_datetime The UTC DateTime specifying the start of the result period.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return. (default to 0)
    # @option opts [Integer] :records The maximum number of amendments to return. (default to 8766)
    # @option opts [String] :order_by Specify a field used to order the result set. (default to created)
    # @option opts [String] :order The direction of any ordering, either ASC or DESC. (default to ASC)
    # @return [CassChurnResultPagedMetadata]
    def get_churn(start_datetime, end_datetime, opts = {})
      data, _status_code, _headers = get_churn_with_http_info(start_datetime, end_datetime, opts)
      return data
    end

    # Gets churn, within a date range.
    # {\&quot;nickname\&quot;:\&quot;Get churn\&quot;,\&quot;response\&quot;:\&quot;getChurn.html\&quot;}
    # @param start_datetime The UTC DateTime specifying the start of the result period.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return.
    # @option opts [Integer] :records The maximum number of amendments to return.
    # @option opts [String] :order_by Specify a field used to order the result set.
    # @option opts [String] :order The direction of any ordering, either ASC or DESC.
    # @return [Array<(CassChurnResultPagedMetadata, Fixnum, Hash)>] CassChurnResultPagedMetadata data, response status code and response headers
    def get_churn_with_http_info(start_datetime, end_datetime, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_churn ..."
      end
      # verify the required parameter 'start_datetime' is set
      fail ArgumentError, "Missing the required parameter 'start_datetime' when calling AnalyticsApi.get_churn" if start_datetime.nil?
      # verify the required parameter 'end_datetime' is set
      fail ArgumentError, "Missing the required parameter 'end_datetime' when calling AnalyticsApi.get_churn" if end_datetime.nil?
      if opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
        fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
      end
      # resource path
      local_var_path = "/analytics/churn/{start-datetime}/{end-datetime}".sub('{format}','json').sub('{' + 'start-datetime' + '}', start_datetime.to_s).sub('{' + 'end-datetime' + '}', end_datetime.to_s)

      # query parameters
      query_params = {}
      query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
      query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
      query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = []
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      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 => 'CassChurnResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_churn\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets debts within a date range.
    # {\"nickname\":\"Get debts\",\"response\":\"getDebts.html\"}
    # @param start_datetime The UTC DateTime specifying the start of the result period.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return. (default to 0)
    # @option opts [Integer] :records The maximum number of amendments to return. (default to 8766)
    # @option opts [String] :order_by Specify a field used to order the result set. (default to created)
    # @option opts [String] :order The direction of any ordering, either ASC or DESC. (default to ASC)
    # @return [DebtsResultPagedMetadata]
    def get_debts(start_datetime, end_datetime, opts = {})
      data, _status_code, _headers = get_debts_with_http_info(start_datetime, end_datetime, opts)
      return data
    end

    # Gets debts within a date range.
    # {\&quot;nickname\&quot;:\&quot;Get debts\&quot;,\&quot;response\&quot;:\&quot;getDebts.html\&quot;}
    # @param start_datetime The UTC DateTime specifying the start of the result period.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return.
    # @option opts [Integer] :records The maximum number of amendments to return.
    # @option opts [String] :order_by Specify a field used to order the result set.
    # @option opts [String] :order The direction of any ordering, either ASC or DESC.
    # @return [Array<(DebtsResultPagedMetadata, Fixnum, Hash)>] DebtsResultPagedMetadata data, response status code and response headers
    def get_debts_with_http_info(start_datetime, end_datetime, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_debts ..."
      end
      # verify the required parameter 'start_datetime' is set
      fail ArgumentError, "Missing the required parameter 'start_datetime' when calling AnalyticsApi.get_debts" if start_datetime.nil?
      # verify the required parameter 'end_datetime' is set
      fail ArgumentError, "Missing the required parameter 'end_datetime' when calling AnalyticsApi.get_debts" if end_datetime.nil?
      if opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
        fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
      end
      # resource path
      local_var_path = "/analytics/payments/outstanding/{start-datetime}/{end-datetime}".sub('{format}','json').sub('{' + 'start-datetime' + '}', start_datetime.to_s).sub('{' + 'end-datetime' + '}', end_datetime.to_s)

      # query parameters
      query_params = {}
      query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
      query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
      query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = []
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      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 => 'DebtsResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_debts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets payments within a date range.
    # {\"nickname\":\"Get all payments\",\"response\":\"getPayments.html\"}
    # @param start_datetime The UTC DateTime specifying the start of the result period.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return. (default to 0)
    # @option opts [Integer] :records The maximum number of amendments to return. (default to 8766)
    # @option opts [String] :order_by Specify a field used to order the result set. (default to created)
    # @option opts [String] :order The direction of any ordering, either ASC or DESC. (default to ASC)
    # @return [CassPaymentResultPagedMetadata]
    def get_payments(start_datetime, end_datetime, opts = {})
      data, _status_code, _headers = get_payments_with_http_info(start_datetime, end_datetime, opts)
      return data
    end

    # Gets payments within a date range.
    # {\&quot;nickname\&quot;:\&quot;Get all payments\&quot;,\&quot;response\&quot;:\&quot;getPayments.html\&quot;}
    # @param start_datetime The UTC DateTime specifying the start of the result period.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return.
    # @option opts [Integer] :records The maximum number of amendments to return.
    # @option opts [String] :order_by Specify a field used to order the result set.
    # @option opts [String] :order The direction of any ordering, either ASC or DESC.
    # @return [Array<(CassPaymentResultPagedMetadata, Fixnum, Hash)>] CassPaymentResultPagedMetadata data, response status code and response headers
    def get_payments_with_http_info(start_datetime, end_datetime, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_payments ..."
      end
      # verify the required parameter 'start_datetime' is set
      fail ArgumentError, "Missing the required parameter 'start_datetime' when calling AnalyticsApi.get_payments" if start_datetime.nil?
      # verify the required parameter 'end_datetime' is set
      fail ArgumentError, "Missing the required parameter 'end_datetime' when calling AnalyticsApi.get_payments" if end_datetime.nil?
      if opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
        fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
      end
      # resource path
      local_var_path = "/analytics/payments/{start-datetime}/{end-datetime}".sub('{format}','json').sub('{' + 'start-datetime' + '}', start_datetime.to_s).sub('{' + 'end-datetime' + '}', end_datetime.to_s)

      # query parameters
      query_params = {}
      query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
      query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
      query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = []
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      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 => 'CassPaymentResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_payments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets hourly payments per product, within a date range.
    # {\"nickname\" : \"Get payments per product\",\"response\" : \"getProductPayments.html\"}
    # @param payments_per_product The payments-per-product object.
    # @param [Hash] opts the optional parameters
    # @return [ProductPaymentsResultPagedMetadata]
    def get_product_payments(payments_per_product, opts = {})
      data, _status_code, _headers = get_product_payments_with_http_info(payments_per_product, opts)
      return data
    end

    # Gets hourly payments per product, within a date range.
    # {\&quot;nickname\&quot; : \&quot;Get payments per product\&quot;,\&quot;response\&quot; : \&quot;getProductPayments.html\&quot;}
    # @param payments_per_product The payments-per-product object.
    # @param [Hash] opts the optional parameters
    # @return [Array<(ProductPaymentsResultPagedMetadata, Fixnum, Hash)>] ProductPaymentsResultPagedMetadata data, response status code and response headers
    def get_product_payments_with_http_info(payments_per_product, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_product_payments ..."
      end
      # verify the required parameter 'payments_per_product' is set
      fail ArgumentError, "Missing the required parameter 'payments_per_product' when calling AnalyticsApi.get_product_payments" if payments_per_product.nil?
      # resource path
      local_var_path = "/analytics/payments-per-product".sub('{format}','json')

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = ['application/json']
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(payments_per_product)
      auth_names = []
      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 => 'ProductPaymentsResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_product_payments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets hourly payments per product, within a date range.
    # {\"nickname\" : \"Get payments per rate plan\",\"response\" : \"getRatePlanPayments.html\"}
    # @param payments_per_product_rate_plan The payments-per-product-rate-plan object.
    # @param [Hash] opts the optional parameters
    # @return [ProductRatePlanPaymentsResultPagedMetadata]
    def get_product_rate_plan_payments(payments_per_product_rate_plan, opts = {})
      data, _status_code, _headers = get_product_rate_plan_payments_with_http_info(payments_per_product_rate_plan, opts)
      return data
    end

    # Gets hourly payments per product, within a date range.
    # {\&quot;nickname\&quot; : \&quot;Get payments per rate plan\&quot;,\&quot;response\&quot; : \&quot;getRatePlanPayments.html\&quot;}
    # @param payments_per_product_rate_plan The payments-per-product-rate-plan object.
    # @param [Hash] opts the optional parameters
    # @return [Array<(ProductRatePlanPaymentsResultPagedMetadata, Fixnum, Hash)>] ProductRatePlanPaymentsResultPagedMetadata data, response status code and response headers
    def get_product_rate_plan_payments_with_http_info(payments_per_product_rate_plan, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_product_rate_plan_payments ..."
      end
      # verify the required parameter 'payments_per_product_rate_plan' is set
      fail ArgumentError, "Missing the required parameter 'payments_per_product_rate_plan' when calling AnalyticsApi.get_product_rate_plan_payments" if payments_per_product_rate_plan.nil?
      # resource path
      local_var_path = "/analytics/payments/product-rate-plan".sub('{format}','json')

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = ['application/json']
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(payments_per_product_rate_plan)
      auth_names = []
      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 => 'ProductRatePlanPaymentsResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_product_rate_plan_payments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets a subscription's life-time value, as of a given end date.
    # {\"nickname\":\"Get sub life-time value\",\"response\":\"getSubscriptionLTV.html\"}
    # @param subscription_id The id of the subscription.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return. (default to 0)
    # @option opts [Integer] :records The maximum number of amendments to return. (default to 8766)
    # @option opts [String] :order_by Specify a field used to order the result set. (default to created)
    # @option opts [String] :order The direction of any ordering, either ASC or DESC. (default to ASC)
    # @return [SubscriptionLTVResultPagedMetadata]
    def get_subscription_ltv(subscription_id, end_datetime, opts = {})
      data, _status_code, _headers = get_subscription_ltv_with_http_info(subscription_id, end_datetime, opts)
      return data
    end

    # Gets a subscription&#39;s life-time value, as of a given end date.
    # {\&quot;nickname\&quot;:\&quot;Get sub life-time value\&quot;,\&quot;response\&quot;:\&quot;getSubscriptionLTV.html\&quot;}
    # @param subscription_id The id of the subscription.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return.
    # @option opts [Integer] :records The maximum number of amendments to return.
    # @option opts [String] :order_by Specify a field used to order the result set.
    # @option opts [String] :order The direction of any ordering, either ASC or DESC.
    # @return [Array<(SubscriptionLTVResultPagedMetadata, Fixnum, Hash)>] SubscriptionLTVResultPagedMetadata data, response status code and response headers
    def get_subscription_ltv_with_http_info(subscription_id, end_datetime, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_subscription_ltv ..."
      end
      # verify the required parameter 'subscription_id' is set
      fail ArgumentError, "Missing the required parameter 'subscription_id' when calling AnalyticsApi.get_subscription_ltv" if subscription_id.nil?
      # verify the required parameter 'end_datetime' is set
      fail ArgumentError, "Missing the required parameter 'end_datetime' when calling AnalyticsApi.get_subscription_ltv" if end_datetime.nil?
      if opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
        fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
      end
      # resource path
      local_var_path = "/analytics/subscription-ltv/{subscription-id}/{end-datetime}".sub('{format}','json').sub('{' + 'subscription-id' + '}', subscription_id.to_s).sub('{' + 'end-datetime' + '}', end_datetime.to_s)

      # query parameters
      query_params = {}
      query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
      query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
      query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = []
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      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 => 'SubscriptionLTVResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_subscription_ltv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets upgrades, within a date range.
    # {\"nickname\":\"Get upgrades\",\"response\":\"getUpgrades.html\"}
    # @param start_datetime The UTC DateTime specifying the start of the result period.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return. (default to 0)
    # @option opts [Integer] :records The maximum number of amendments to return. (default to 8766)
    # @option opts [String] :order_by Specify a field used to order the result set. (default to created)
    # @option opts [String] :order The direction of any ordering, either ASC or DESC. (default to ASC)
    # @return [CassUpgradeResultPagedMetadata]
    def get_upgrades(start_datetime, end_datetime, opts = {})
      data, _status_code, _headers = get_upgrades_with_http_info(start_datetime, end_datetime, opts)
      return data
    end

    # Gets upgrades, within a date range.
    # {\&quot;nickname\&quot;:\&quot;Get upgrades\&quot;,\&quot;response\&quot;:\&quot;getUpgrades.html\&quot;}
    # @param start_datetime The UTC DateTime specifying the start of the result period.
    # @param end_datetime The UTC DateTime specifying the end of the result period.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :organizations A list of organization-IDs used to restrict the scope of API calls.
    # @option opts [Integer] :offset The offset from the first amendment to return.
    # @option opts [Integer] :records The maximum number of amendments to return.
    # @option opts [String] :order_by Specify a field used to order the result set.
    # @option opts [String] :order The direction of any ordering, either ASC or DESC.
    # @return [Array<(CassUpgradeResultPagedMetadata, Fixnum, Hash)>] CassUpgradeResultPagedMetadata data, response status code and response headers
    def get_upgrades_with_http_info(start_datetime, end_datetime, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: AnalyticsApi.get_upgrades ..."
      end
      # verify the required parameter 'start_datetime' is set
      fail ArgumentError, "Missing the required parameter 'start_datetime' when calling AnalyticsApi.get_upgrades" if start_datetime.nil?
      # verify the required parameter 'end_datetime' is set
      fail ArgumentError, "Missing the required parameter 'end_datetime' when calling AnalyticsApi.get_upgrades" if end_datetime.nil?
      if opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
        fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
      end
      # resource path
      local_var_path = "/analytics/upgrades/{start-datetime}/{end-datetime}".sub('{format}','json').sub('{' + 'start-datetime' + '}', start_datetime.to_s).sub('{' + 'end-datetime' + '}', end_datetime.to_s)

      # query parameters
      query_params = {}
      query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
      query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
      query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = []
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      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 => 'CassUpgradeResultPagedMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: AnalyticsApi#get_upgrades\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
