# coding: utf-8

"""
    LocationIQ

    LocationIQ provides flexible enterprise-grade location based solutions. We work with developers, startups and enterprises worldwide serving billions of requests everyday. This page provides an overview of the technical aspects of our API and will help you get started.  # noqa: E501

    The version of the OpenAPI document: 1.1.0
    Generated by: https://openapi-generator.tech
"""


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from locationiq.api_client import ApiClient
from locationiq.exceptions import (
    ApiTypeError,
    ApiValueError
)


class AutocompleteApi(object):
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def autocomplete(self, q, normalizecity, **kwargs):  # noqa: E501
        """autocomplete  # noqa: E501

        The Autocomplete API is a variant of the Search API that returns place predictions in response to an HTTP request.  The request specifies a textual search string and optional geographic bounds.  The service can be used to provide autocomplete functionality for text-based geographic searches, by returning places such as businesses, addresses and points of interest as a user types. The Autocomplete API can match on full words as well as substrings. Applications can therefore send queries as the user types, to provide on-the-fly place predictions.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.autocomplete(q, normalizecity, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str q: Address to geocode (required)
        :param int normalizecity: For responses with no city value in the address section, the next available element in this order - city_district, locality, town, borough, municipality, village, hamlet, quarter, neighbourhood - from the address section will be normalized to city. Defaults to 1 for SDKs. (required)
        :param int limit: Limit the number of returned results. Default is 10.
        :param str viewbox: The preferred area to find search results.  To restrict results to those within the viewbox, use along with the bounded option. Tuple of 4 floats. Any two corner points of the box - `max_lon,max_lat,min_lon,min_lat` or `min_lon,min_lat,max_lon,max_lat` - are accepted in any order as long as they span a real box. 
        :param int bounded: Restrict the results to only items contained with the viewbox
        :param str countrycodes: Limit search to a list of countries.
        :param str accept_language: Preferred language order for showing search results, overrides the value specified in the Accept-Language HTTP header. Defaults to en. To use native language for the response when available, use accept-language=native
        :param str tag: Restricts the autocomplete search results to elements of specific OSM class and type.  Example - To restrict results to only class place and type city: tag=place:city, To restrict the results to all of OSM class place: tag=place
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: list[object]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.autocomplete_with_http_info(q, normalizecity, **kwargs)  # noqa: E501

    def autocomplete_with_http_info(self, q, normalizecity, **kwargs):  # noqa: E501
        """autocomplete  # noqa: E501

        The Autocomplete API is a variant of the Search API that returns place predictions in response to an HTTP request.  The request specifies a textual search string and optional geographic bounds.  The service can be used to provide autocomplete functionality for text-based geographic searches, by returning places such as businesses, addresses and points of interest as a user types. The Autocomplete API can match on full words as well as substrings. Applications can therefore send queries as the user types, to provide on-the-fly place predictions.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.autocomplete_with_http_info(q, normalizecity, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str q: Address to geocode (required)
        :param int normalizecity: For responses with no city value in the address section, the next available element in this order - city_district, locality, town, borough, municipality, village, hamlet, quarter, neighbourhood - from the address section will be normalized to city. Defaults to 1 for SDKs. (required)
        :param int limit: Limit the number of returned results. Default is 10.
        :param str viewbox: The preferred area to find search results.  To restrict results to those within the viewbox, use along with the bounded option. Tuple of 4 floats. Any two corner points of the box - `max_lon,max_lat,min_lon,min_lat` or `min_lon,min_lat,max_lon,max_lat` - are accepted in any order as long as they span a real box. 
        :param int bounded: Restrict the results to only items contained with the viewbox
        :param str countrycodes: Limit search to a list of countries.
        :param str accept_language: Preferred language order for showing search results, overrides the value specified in the Accept-Language HTTP header. Defaults to en. To use native language for the response when available, use accept-language=native
        :param str tag: Restricts the autocomplete search results to elements of specific OSM class and type.  Example - To restrict results to only class place and type city: tag=place:city, To restrict the results to all of OSM class place: tag=place
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(list[object], status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['q', 'normalizecity', 'limit', 'viewbox', 'bounded', 'countrycodes', 'accept_language', 'tag']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method autocomplete" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'q' is set
        if self.api_client.client_side_validation and ('q' not in local_var_params or  # noqa: E501
                                                        local_var_params['q'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `q` when calling `autocomplete`")  # noqa: E501
        # verify the required parameter 'normalizecity' is set
        if self.api_client.client_side_validation and ('normalizecity' not in local_var_params or  # noqa: E501
                                                        local_var_params['normalizecity'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `normalizecity` when calling `autocomplete`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'q' in local_var_params and local_var_params['q'] is not None:  # noqa: E501
            query_params.append(('q', local_var_params['q']))  # noqa: E501
        if 'limit' in local_var_params and local_var_params['limit'] is not None:  # noqa: E501
            query_params.append(('limit', local_var_params['limit']))  # noqa: E501
        if 'viewbox' in local_var_params and local_var_params['viewbox'] is not None:  # noqa: E501
            query_params.append(('viewbox', local_var_params['viewbox']))  # noqa: E501
        if 'bounded' in local_var_params and local_var_params['bounded'] is not None:  # noqa: E501
            query_params.append(('bounded', local_var_params['bounded']))  # noqa: E501
        if 'countrycodes' in local_var_params and local_var_params['countrycodes'] is not None:  # noqa: E501
            query_params.append(('countrycodes', local_var_params['countrycodes']))  # noqa: E501
        if 'normalizecity' in local_var_params and local_var_params['normalizecity'] is not None:  # noqa: E501
            query_params.append(('normalizecity', local_var_params['normalizecity']))  # noqa: E501
        if 'accept_language' in local_var_params and local_var_params['accept_language'] is not None:  # noqa: E501
            query_params.append(('accept-language', local_var_params['accept_language']))  # noqa: E501
        if 'tag' in local_var_params and local_var_params['tag'] is not None:  # noqa: E501
            query_params.append(('tag', local_var_params['tag']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['key']  # noqa: E501

        return self.api_client.call_api(
            '/autocomplete.php', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[object]',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)
