# coding: utf-8

"""
    Intrinio API

    Welcome to the Intrinio API! Through our Marketplace, we offer a wide selection of financial data feeds sourced by our own proprietary processes as well as from many data vendors. The primary application of the Intrinio API is for use in third-party applications and integrations or for end-users utilizing the Excel add-in and Google Sheets add-on. The Intrinio API uses HTTPS verbs and a RESTful endpoint structure, which makes it easy to request data from Intrinio. Responses are delivered in JSON format. If you need additional help in using the API, go to our home page (https://intrinio.com) and click on the chat icon in the lower right corner.  # noqa: E501

    OpenAPI spec version: 2.0.1
    
    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 intrinio_sdk.api_client import ApiClient


class FilingApi(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 filter_filings(self, company, **kwargs):  # noqa: E501
        """Filter Filings  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.filter_filings(company, async=True)
        >>> result = thread.get()

        :param async bool
        :param str company: Filings for the given `company` identifier (ticker, CIK, LEI, Intrinio ID) (required)
        :param str report_type: Filter by report type
        :param date start_date: Filed on or after the given date
        :param date end_date: Filed before or after the given date
        :param str next_page: Gets the next page of data from a previous API call
        :return: list[Filing]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.filter_filings_with_http_info(company, **kwargs)  # noqa: E501
        else:
            (data) = self.filter_filings_with_http_info(company, **kwargs)  # noqa: E501
            return data

    def filter_filings_with_http_info(self, company, **kwargs):  # noqa: E501
        """Filter Filings  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.filter_filings_with_http_info(company, async=True)
        >>> result = thread.get()

        :param async bool
        :param str company: Filings for the given `company` identifier (ticker, CIK, LEI, Intrinio ID) (required)
        :param str report_type: Filter by report type
        :param date start_date: Filed on or after the given date
        :param date end_date: Filed before or after the given date
        :param str next_page: Gets the next page of data from a previous API call
        :return: list[Filing]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['company', 'report_type', 'start_date', 'end_date', 'next_page']  # noqa: E501
        all_params.append('async')
        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 filter_filings" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'company' is set
        if ('company' not in params or
                params['company'] is None):
            raise ValueError("Missing the required parameter `company` when calling `filter_filings`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'company' in params:
            query_params.append(('company', params['company']))  # noqa: E501
        if 'report_type' in params:
            query_params.append(('report_type', params['report_type']))  # noqa: E501
        if 'start_date' in params:
            query_params.append(('start_date', params['start_date']))  # noqa: E501
        if 'end_date' in params:
            query_params.append(('end_date', params['end_date']))  # noqa: E501
        if 'next_page' in params:
            query_params.append(('next_page', params['next_page']))  # 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 = ['HttpHeaderApiKey']  # noqa: E501

        return self.api_client.call_api(
            '/filings/filter', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[Filing]',  # noqa: E501
            auth_settings=auth_settings,
            async=params.get('async'),
            _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)

    def get_all_filings(self, **kwargs):  # noqa: E501
        """Get All Filings  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_all_filings(async=True)
        >>> result = thread.get()

        :param async bool
        :param str next_page: Gets the next page of data from a previous API call
        :return: list[Filing]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_all_filings_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_all_filings_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_all_filings_with_http_info(self, **kwargs):  # noqa: E501
        """Get All Filings  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_all_filings_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param str next_page: Gets the next page of data from a previous API call
        :return: list[Filing]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['next_page']  # noqa: E501
        all_params.append('async')
        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 get_all_filings" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'next_page' in params:
            query_params.append(('next_page', params['next_page']))  # 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 = ['HttpHeaderApiKey']  # noqa: E501

        return self.api_client.call_api(
            '/filings', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[Filing]',  # noqa: E501
            auth_settings=auth_settings,
            async=params.get('async'),
            _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)

    def get_filing_by_id(self, id, **kwargs):  # noqa: E501
        """Get a Filing by ID  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_filing_by_id(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The Intrinio ID of the Filing (required)
        :return: Filing
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_filing_by_id_with_http_info(id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_filing_by_id_with_http_info(id, **kwargs)  # noqa: E501
            return data

    def get_filing_by_id_with_http_info(self, id, **kwargs):  # noqa: E501
        """Get a Filing by ID  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_filing_by_id_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The Intrinio ID of the Filing (required)
        :return: Filing
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id']  # noqa: E501
        all_params.append('async')
        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 get_filing_by_id" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params or
                params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `get_filing_by_id`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']  # noqa: E501

        query_params = []

        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 = ['HttpHeaderApiKey']  # noqa: E501

        return self.api_client.call_api(
            '/filings/{id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Filing',  # noqa: E501
            auth_settings=auth_settings,
            async=params.get('async'),
            _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)
