=begin
#geoprox-server

#Geoprox server implementation providing a HTTP API for geospatial queries and position tracking

The version of the OpenAPI document: 0.5.0
Contact: singhezra@gmail.com
Generated by: https://openapi-generator.tech
Generator version: 7.7.0

=end

require 'cgi'

module GeoproxClient
  class GeohashApiApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Decode geohash into coordinates.
    # Decode geohash by path param, returns coordinates with precision estimates.
    # @param ghash [String] Geohash encoded region
    # @param [Hash] opts the optional parameters
    # @return [DecodeGeohashResponse]
    def decode_geohash(ghash, opts = {})
      data, _status_code, _headers = decode_geohash_with_http_info(ghash, opts)
      data
    end

    # Decode geohash into coordinates.
    # Decode geohash by path param, returns coordinates with precision estimates.
    # @param ghash [String] Geohash encoded region
    # @param [Hash] opts the optional parameters
    # @return [Array<(DecodeGeohashResponse, Integer, Hash)>] DecodeGeohashResponse data, response status code and response headers
    def decode_geohash_with_http_info(ghash, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: GeohashApiApi.decode_geohash ...'
      end
      # verify the required parameter 'ghash' is set
      if @api_client.config.client_side_validation && ghash.nil?
        fail ArgumentError, "Missing the required parameter 'ghash' when calling GeohashApiApi.decode_geohash"
      end
      # resource path
      local_var_path = '/api/v1/geohash/{ghash}'.sub('{' + 'ghash' + '}', CGI.escape(ghash.to_s))

      # 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'])

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

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

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

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

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

    # Encode coordinates into geohash
    # Encode coordinates by query params, returns geohash.
    # @param lat [Float] Latitude
    # @param lng [Float] Longitude
    # @param depth [Integer] Determines geohash length
    # @param [Hash] opts the optional parameters
    # @return [EncodeLatLngResponse]
    def encode_latlng(lat, lng, depth, opts = {})
      data, _status_code, _headers = encode_latlng_with_http_info(lat, lng, depth, opts)
      data
    end

    # Encode coordinates into geohash
    # Encode coordinates by query params, returns geohash.
    # @param lat [Float] Latitude
    # @param lng [Float] Longitude
    # @param depth [Integer] Determines geohash length
    # @param [Hash] opts the optional parameters
    # @return [Array<(EncodeLatLngResponse, Integer, Hash)>] EncodeLatLngResponse data, response status code and response headers
    def encode_latlng_with_http_info(lat, lng, depth, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: GeohashApiApi.encode_latlng ...'
      end
      # verify the required parameter 'lat' is set
      if @api_client.config.client_side_validation && lat.nil?
        fail ArgumentError, "Missing the required parameter 'lat' when calling GeohashApiApi.encode_latlng"
      end
      # verify the required parameter 'lng' is set
      if @api_client.config.client_side_validation && lng.nil?
        fail ArgumentError, "Missing the required parameter 'lng' when calling GeohashApiApi.encode_latlng"
      end
      # verify the required parameter 'depth' is set
      if @api_client.config.client_side_validation && depth.nil?
        fail ArgumentError, "Missing the required parameter 'depth' when calling GeohashApiApi.encode_latlng"
      end
      if @api_client.config.client_side_validation && depth < 0
        fail ArgumentError, 'invalid value for "depth" when calling GeohashApiApi.encode_latlng, must be greater than or equal to 0.'
      end

      # resource path
      local_var_path = '/api/v1/geohash'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'lat'] = lat
      query_params[:'lng'] = lng
      query_params[:'depth'] = depth

      # header parameters
      header_params = opts[:header_params] || {}
      # 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] || 'EncodeLatLngResponse'

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

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

    # Neighboring regions
    # Returns geohash neighbors in all cardinal directions.
    # @param ghash [String] Geohash encoded region
    # @param [Hash] opts the optional parameters
    # @return [GeohashNeighborsResponse]
    def get_neighbors(ghash, opts = {})
      data, _status_code, _headers = get_neighbors_with_http_info(ghash, opts)
      data
    end

    # Neighboring regions
    # Returns geohash neighbors in all cardinal directions.
    # @param ghash [String] Geohash encoded region
    # @param [Hash] opts the optional parameters
    # @return [Array<(GeohashNeighborsResponse, Integer, Hash)>] GeohashNeighborsResponse data, response status code and response headers
    def get_neighbors_with_http_info(ghash, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: GeohashApiApi.get_neighbors ...'
      end
      # verify the required parameter 'ghash' is set
      if @api_client.config.client_side_validation && ghash.nil?
        fail ArgumentError, "Missing the required parameter 'ghash' when calling GeohashApiApi.get_neighbors"
      end
      # resource path
      local_var_path = '/api/v1/geohash/{ghash}/neighbors'.sub('{' + 'ghash' + '}', CGI.escape(ghash.to_s))

      # 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'])

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

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

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

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

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