=begin
#IPGeolocation.io - IP intelligence products

#Ipgeolocation provides a set of APIs to make ip based decisions.

The version of the OpenAPI document: 2.0

Generated by: https://openapi-generator.tech
Generator version: 7.13.0

=end

require 'cgi'

module IpgeolocationSdk
  class UserAgentApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Get details of user-agent
    # User Agent Parser API provides the accurate browser, device, and operating system details from a User Agent String. It also provides information about crawlers and attack sources. You can use these details to customize user experience, prevent crawlers and attackers from accessing your website. 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :user_agent 
    # @option opts [String] :output Desired output format (json or xml).
    # @return [UserAgentData]
    def get_user_agent_details(opts = {})
      data, _status_code, _headers = get_user_agent_details_with_http_info(opts)
      data
    end

    # Get details of user-agent
    # User Agent Parser API provides the accurate browser, device, and operating system details from a User Agent String. It also provides information about crawlers and attack sources. You can use these details to customize user experience, prevent crawlers and attackers from accessing your website. 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :user_agent 
    # @option opts [String] :output Desired output format (json or xml).
    # @return [Array<(UserAgentData, Integer, Hash)>] UserAgentData data, response status code and response headers
    def get_user_agent_details_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserAgentApi.get_user_agent_details ...'
      end
      # resource path
      local_var_path = '/user-agent'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'output'] = opts[:'output'] if !opts[:'output'].nil?
      # query_params[:'userAgent'] = opts[:'user_agent'] if !opts[:'user_agent'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml']) unless header_params['Accept']
      header_params[:'User-Agent'] = opts[:'user_agent'] if !opts[:'user_agent'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'UserAgentData'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

      new_options = opts.merge(
        :operation => :"UserAgentApi.get_user_agent_details",
        :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: UserAgentApi#get_user_agent_details\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Handle multiple user-agent string lookups
    # This endpoint allows you to perform the parsing of multiple User-Angent strings (max. 50,000) at the same time. The requests count per round is equal to total User-Agent strings passed. This feature is `only available for paid plans`.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :output Desired output format (json or xml).
    # @option opts [ParseBulkUserAgentStringsRequest] :parse_bulk_user_agent_strings_request 
    # @return [Array<UserAgentData>]
    def parse_bulk_user_agent_strings(opts = {})
      data, _status_code, _headers = parse_bulk_user_agent_strings_with_http_info(opts)
      data
    end

    # Handle multiple user-agent string lookups
    # This endpoint allows you to perform the parsing of multiple User-Angent strings (max. 50,000) at the same time. The requests count per round is equal to total User-Agent strings passed. This feature is &#x60;only available for paid plans&#x60;.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :output Desired output format (json or xml).
    # @option opts [ParseBulkUserAgentStringsRequest] :parse_bulk_user_agent_strings_request 
    # @return [Array<(Array<UserAgentData>, Integer, Hash)>] Array<UserAgentData> data, response status code and response headers
    def parse_bulk_user_agent_strings_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: UserAgentApi.parse_bulk_user_agent_strings ...'
      end
      # Verify the required parameter 'user_agents' in opts is set 
      if @api_client.config.client_side_validation && (!opts[:user_agents].is_a?(Array) || opts[:user_agents].empty?)
        fail ArgumentError, "Missing the required parameter 'user_agents' (non-empty Array) when calling UserAgentApi.parse_bulk_user_agent_strings"
      end
      # resource path
      local_var_path = '/user-agent-bulk'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'output'] = opts[:'output'] if !opts[:'output'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml']) 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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body({
        uaStrings: opts[:user_agents]
      })

      # return_type
      return_type = opts[:debug_return_type] || 'Array<UserAgentData>'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

      new_options = opts.merge(
        :operation => :"UserAgentApi.parse_bulk_user_agent_strings",
        :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: UserAgentApi#parse_bulk_user_agent_strings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
