# coding: utf-8

"""
    RegObs API

      ## Introduction    RegObs is a tool for collecting observations and events   related to natural hazards. It is currently used by the   Norwegian flood, landslide and avalanche warning service in   Norway, but the data is openly available for anyone through this API.    Regobs has been developed by the Norwegian Water resources and   Energy Directorate (NVE), in collaboration with the Norwegian   Meteorological Institute (MET) and the Norwegian Public Roads   Administration (NPRA).    You can check out our representation of the data at [regobs.no](http://regobs.no).    ## Authentication    Some endpoints require an api key.  You can get an API key by sending an email to   [raek@nve.no](mailto:raek@nve.no?subject=RegObs%20API%20Key).  To use the api key with the swagger ui, fill in the api\\_key input above.   It should then be included with every request in the   `regObs_apptoken` header.    ## Getting started    Get the last 10 observations using python:    ```python  import requests  r = requests.post('https://api.regobs.no/v4/Search',       data={'NumberOfRecords': 10},      headers={'Content-Type': 'application/json'}  )  data = r.json()  print(len(data))  # 10  ```      # noqa: E501

    OpenAPI spec version: v4
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from varsom_regobs_client.api_client import ApiClient


class LocationApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

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

    def location_within_radius(self, latitude, longitude, radius, **kwargs):  # noqa: E501
        """location_within_radius  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.location_within_radius(latitude, longitude, radius, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param float latitude: (required)
        :param float longitude: (required)
        :param int radius: (required)
        :param list[int] geo_hazard_type_ids:
        :param str observer_guid:
        :param int return_count:
        :return: list[ObsLocationsResponseDtoV2]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.location_within_radius_with_http_info(latitude, longitude, radius, **kwargs)  # noqa: E501
        else:
            (data) = self.location_within_radius_with_http_info(latitude, longitude, radius, **kwargs)  # noqa: E501
            return data

    def location_within_radius_with_http_info(self, latitude, longitude, radius, **kwargs):  # noqa: E501
        """location_within_radius  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.location_within_radius_with_http_info(latitude, longitude, radius, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param float latitude: (required)
        :param float longitude: (required)
        :param int radius: (required)
        :param list[int] geo_hazard_type_ids:
        :param str observer_guid:
        :param int return_count:
        :return: list[ObsLocationsResponseDtoV2]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['latitude', 'longitude', 'radius', 'geo_hazard_type_ids', 'observer_guid', 'return_count']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method location_within_radius" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'latitude' is set
        if ('latitude' not in params or
                params['latitude'] is None):
            raise ValueError("Missing the required parameter `latitude` when calling `location_within_radius`")  # noqa: E501
        # verify the required parameter 'longitude' is set
        if ('longitude' not in params or
                params['longitude'] is None):
            raise ValueError("Missing the required parameter `longitude` when calling `location_within_radius`")  # noqa: E501
        # verify the required parameter 'radius' is set
        if ('radius' not in params or
                params['radius'] is None):
            raise ValueError("Missing the required parameter `radius` when calling `location_within_radius`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'latitude' in params:
            query_params.append(('latitude', params['latitude']))  # noqa: E501
        if 'longitude' in params:
            query_params.append(('longitude', params['longitude']))  # noqa: E501
        if 'radius' in params:
            query_params.append(('radius', params['radius']))  # noqa: E501
        if 'geo_hazard_type_ids' in params:
            query_params.append(('geoHazardTypeIds', params['geo_hazard_type_ids']))  # noqa: E501
            collection_formats['geoHazardTypeIds'] = 'multi'  # noqa: E501
        if 'observer_guid' in params:
            query_params.append(('observerGuid', params['observer_guid']))  # noqa: E501
        if 'return_count' in params:
            query_params.append(('returnCount', params['return_count']))  # 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', 'text/json', 'application/xml', 'text/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

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