# coding: utf-8

"""
    CodeChef API

    CodeChef API to support different applications.  # noqa: E501

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


class SubmissionApi(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 submissions_get(self, **kwargs):  # noqa: E501
        """Get submissions for particular user, problemCode, result and year.  # noqa: E501

        Takes result (result code), problemCode, year, username as condition parameters.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.submissions_get(async=True)
        >>> result = thread.get()

        :param async bool
        :param str result: Search submission by result, eg. AC, WA, RE etc.
        :param int year: Search submission by year, eg. 2012
        :param str username: Search submission by username, eg. hacker_ratty
        :param str language: Search submission by language, eg. C++ 4.3.2
        :param str problem_code: Code for problem, eg. SALARY
        :param str contest_code: Code of contest, eg. JAN13
        :param int limit: limit for no. of submissions. Default = 10, max = 20
        :param int offset: starting index for list. Default = 0
        :param str fields: Possible fields are- id, date, username, problemCode, language, contestCode, result, time, memory.   Multiple fields can be entered using comma.
        :return: InlineResponse20013
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.submissions_get_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.submissions_get_with_http_info(**kwargs)  # noqa: E501
            return data

    def submissions_get_with_http_info(self, **kwargs):  # noqa: E501
        """Get submissions for particular user, problemCode, result and year.  # noqa: E501

        Takes result (result code), problemCode, year, username as condition parameters.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.submissions_get_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param str result: Search submission by result, eg. AC, WA, RE etc.
        :param int year: Search submission by year, eg. 2012
        :param str username: Search submission by username, eg. hacker_ratty
        :param str language: Search submission by language, eg. C++ 4.3.2
        :param str problem_code: Code for problem, eg. SALARY
        :param str contest_code: Code of contest, eg. JAN13
        :param int limit: limit for no. of submissions. Default = 10, max = 20
        :param int offset: starting index for list. Default = 0
        :param str fields: Possible fields are- id, date, username, problemCode, language, contestCode, result, time, memory.   Multiple fields can be entered using comma.
        :return: InlineResponse20013
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['result', 'year', 'username', 'language', 'problem_code', 'contest_code', 'limit', 'offset', 'fields']  # 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 submissions_get" % key
                )
            params[key] = val
        del params['kwargs']

        if 'year' in params and params['year'] < 2009:  # noqa: E501
            raise ValueError("Invalid value for parameter `year` when calling `submissions_get`, must be a value greater than or equal to `2009`")  # noqa: E501
        if 'limit' in params and params['limit'] > 20:  # noqa: E501
            raise ValueError("Invalid value for parameter `limit` when calling `submissions_get`, must be a value less than or equal to `20`")  # noqa: E501
        collection_formats = {}

        path_params = {}

        query_params = []
        if 'result' in params:
            query_params.append(('result', params['result']))  # noqa: E501
        if 'year' in params:
            query_params.append(('year', params['year']))  # noqa: E501
        if 'username' in params:
            query_params.append(('username', params['username']))  # noqa: E501
        if 'language' in params:
            query_params.append(('language', params['language']))  # noqa: E501
        if 'problem_code' in params:
            query_params.append(('problemCode', params['problem_code']))  # noqa: E501
        if 'contest_code' in params:
            query_params.append(('contestCode', params['contest_code']))  # noqa: E501
        if 'limit' in params:
            query_params.append(('limit', params['limit']))  # noqa: E501
        if 'offset' in params:
            query_params.append(('offset', params['offset']))  # noqa: E501
        if 'fields' in params:
            query_params.append(('fields', params['fields']))  # 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

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

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

        return self.api_client.call_api(
            '/submissions/', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='InlineResponse20013',  # 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 submissions_submission_id_get(self, submission_id, **kwargs):  # noqa: E501
        """Get details of a submission.  # noqa: E501

        Takes SubmissionId as the parameter and fetches details of a submission.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.submissions_submission_id_get(submission_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int submission_id: (required)
        :param str fields: Possible fields are- id, date, username, problemCode, language, contestCode, result, time, memory. Multiple fields can be entered using comma.
        :return: InlineResponse20012
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.submissions_submission_id_get_with_http_info(submission_id, **kwargs)  # noqa: E501
        else:
            (data) = self.submissions_submission_id_get_with_http_info(submission_id, **kwargs)  # noqa: E501
            return data

    def submissions_submission_id_get_with_http_info(self, submission_id, **kwargs):  # noqa: E501
        """Get details of a submission.  # noqa: E501

        Takes SubmissionId as the parameter and fetches details of a submission.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.submissions_submission_id_get_with_http_info(submission_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int submission_id: (required)
        :param str fields: Possible fields are- id, date, username, problemCode, language, contestCode, result, time, memory. Multiple fields can be entered using comma.
        :return: InlineResponse20012
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

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

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

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

        return self.api_client.call_api(
            '/submissions/{submissionId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='InlineResponse20012',  # 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)
